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.
Password string // Chanserv password.
}
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
// TKSKey defines the TLS key file. Along with TLSCert, it defines the
// components needed to establish an encrypted connection to the server.
TLSKey() string
// TLSCert defines the TLS certificate file. Along with TLSKey, it
// defines the components needed to establish an encrypted connection
// to the server.
TLSCert() string
// CAPemData defines one ore more, PEM encoded, server root certificates.
// This is optional and is used to replace the client's existing root CA
// pool. This can be useful if you are connecting to a server whos
// certificate is not present in any system wide CA pools.
CAPemData() 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)
// OperPassword defines the bot's OPER password. If present, this will
// register the bot as a server operator.
OperPassword() string
// Some connections may be secured and require a password to connect to.
ConnectionPassword() 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)
// IsNick 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.
IsNick(string) bool
// ForkArgs returns a list of command line arguments which should be
// passed to a forked child process.
ForkArgs() []string
// Logging returns true if incoming data logging is enabled.
Logging() bool
// Logging determines if logging of incoming data should be enabled or not.
SetLogging(bool)
}
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.
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. |
Click to show internal directories.
Click to hide internal directories.