Documentation ¶
Overview ¶
Package irc defines some utility types and functions for an IRC bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Name string // Channel's name. Key string // Authentication key for protected channel. }
Channel defines a single IRC channel.
type Profile ¶
type Profile interface { // Root defines the root directory with the bot's configuration data. Root() string // Channels yields all channels the bot should join on startup. Channels() []Channel // Address defines the host and port of the server/network to connect to. Address() string // Nickname yields the bot's nickname. Nickname() string // SetNickname sets the bot's nickname. This is generally only called // when the bot logs in and finds its name alredy in use. If the nick // can not be regained, this function is used to alter it to something // which is still available. SetNickname(string) // NickservPassword defines the bot's nickserv password. This will be // used to register the bot when it logs in. It is only relevant if the // bot has a registered nickname and nickserv exists on the server. NickservPassword() string // SetNickservPassword sets the bot's nickserv password. This is be // used to register the bot when it logs in. It is only relevant if the // bot has a registered nickname and nickserv exists on the server. SetNickservPassword(string) // CommandPrefix this is the prefix used for all bot commands. Whenever // the bot reads incoming PRIVMSG data, it looks for this prefix to // determine if a command call was issued or not. CommandPrefix() string // Save saves the profile to disk. Save() error // Load loads the profile from disk. Load() error // IsWhitelisted returns true if the given hostmask is in the whitelist. // This means the user to whom it belongs is allowed to execute restricted // commands. This performs a case-insensitive comparison. IsWhitelisted(string) bool // Whitelist returns a copy of the current whitelist. Whitelist() []string // WhitelistAdd adds the given hostmask to the whitelist, // provided it does not already exist. WhitelistAdd(string) // WhitelistRemove removes the given hostmask from the whitelist, // provided it exists. WhitelistRemove(string) // IsMe returns true if the given name equals the bot's nickname. // This is used in request handlers to quickly check if a request // is targeted specifically at this bot or not. IsMe(string) bool // ForkArgs returns a list of command line arguments which should be // passed to a forked child process. ForkArgs() []string }
Profile defines bot configuration data.
func NewProfile ¶
NewProfile creates a new profile for the given root directory.
type Request ¶
type Request struct { SenderName string // Nick name of sender. SenderMask string // Hostmask of sender. Type string // Type of message: "001", "PRIVMSG", "PING", etc. Target string // Receiver of reply. Data string // Message content. }
Request defines a single incoming message from a server.
func (*Request) Fields ¶
Fields returns the message payload, but skips the first n words. The result is returned as a slice of individual words.
func (*Request) FromChannel ¶
FromChannel returns true if this request came from a channel context instead of a user or service.
type RequestFunc ¶
type RequestFunc func(ResponseWriter, *Request)
RequestFunc defines a handler for a request binding.
type ResponseWriter ¶
type ResponseWriter interface { io.WriteCloser }
ResponseWriter repersents a network stream, used to write response data to.
var Connection ResponseWriter
Connection is the stream to write to.
Directories ¶
Path | Synopsis |
---|---|
Package cmd allows the definition of command handlers to be called by users from either a channel or a private message.
|
Package cmd allows the definition of command handlers to be called by users from either a channel or a private message. |
Package proto defines convenience functions for IRC protocol requests.
|
Package proto defines convenience functions for IRC protocol requests. |