Documentation
¶
Index ¶
- Constants
- Variables
- type CallbackMap
- type Channel
- type Configuration
- type Connection
- func (c *Connection) Action(target, message string)
- func (c *Connection) AddCallback(name string, callback IRCCallback) string
- func (c *Connection) Connect() (err error)
- func (c *Connection) Ctcp(target, args string)
- func (c *Connection) CtcpReply(target, args string)
- func (c *Connection) GetTopic(channel string)
- func (c *Connection) Invite(nickname, channel string)
- func (c *Connection) Join(channel string)
- func (c *Connection) JoinChannels()
- func (c *Connection) Kick(channel, nickname, reason string)
- func (c *Connection) LoginNickserv()
- func (c *Connection) MainLoop()
- func (c *Connection) Mode(target string, modes ...string)
- func (c *Connection) Names(target string)
- func (c *Connection) Nick(nickname string)
- func (c *Connection) Notice(target, message string)
- func (c *Connection) Noticef(target, format string, a ...interface{})
- func (c *Connection) Part(channel string, message ...string)
- func (c *Connection) Pass(password string)
- func (c *Connection) Privmsg(target, message string)
- func (c *Connection) Privmsgf(target, format string, a ...interface{})
- func (c *Connection) Quit(message ...string)
- func (c *Connection) Raw(s string)
- func (c *Connection) Rawf(format string, a ...interface{})
- func (c *Connection) RemoveCallback(name string, id string) bool
- func (c *Connection) RunCallbacks(message *Message)
- func (c *Connection) ServerPing()
- func (c *Connection) SetTopic(channel, topic string)
- func (c *Connection) SetupCallbacks()
- func (c *Connection) SetupPlugins(plugins []PluginConfiguration)
- func (c *Connection) Shutdown()
- func (c *Connection) User(ident, realname string)
- func (c *Connection) Who(target string)
- func (c *Connection) Whois(nickname string)
- type IRCCallback
- type Message
- type PluginConfiguration
- type ServerConfiguration
- type User
Constants ¶
const ( NickservName = "nickserv" // IRC defines a maximum "line" length of 512 characters, including \r\n, // the command and all parameters. On Azzurra the limit seems to be lower... MaximumCommandLength = 460 SleepBetweenReconnects = time.Minute * 5 )
the number of *Loop() methods on Connection; it's used for synchronization and must be updated accordingly.
Variables ¶
var ( ErrInvalidServerLine = errors.New("Invalid server line: wrong number of tokens") CTCPChar = "\001" )
Functions ¶
This section is empty.
Types ¶
type CallbackMap ¶ added in v0.2.0
type CallbackMap map[string]map[string]IRCCallback
type Configuration ¶
type Configuration struct {
Servers []ServerConfiguration
Plugins []PluginConfiguration
}
func ReadConfig ¶
func ReadConfig(filename string) *Configuration
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
A connection to the IRC server, also the main data structure of the IRC bot.
func NewConnection ¶
func NewConnection(config ServerConfiguration, botConfig *Configuration, mdb *markov.MarkovDB) *Connection
func (*Connection) AddCallback ¶
func (c *Connection) AddCallback(name string, callback IRCCallback) string
func (*Connection) Connect ¶
func (c *Connection) Connect() (err error)
Connect to the server, launch all internal goroutines.
func (*Connection) GetTopic ¶
func (c *Connection) GetTopic(channel string)
func (*Connection) JoinChannels ¶
func (c *Connection) JoinChannels()
func (*Connection) MainLoop ¶
func (c *Connection) MainLoop()
func (*Connection) Noticef ¶
func (c *Connection) Noticef(target, format string, a ...interface{})
func (*Connection) Part ¶
func (c *Connection) Part(channel string, message ...string)
PART command
optional argument: the part message
func (*Connection) Privmsgf ¶
func (c *Connection) Privmsgf(target, format string, a ...interface{})
PRIVMSG with format string
func (*Connection) Quit ¶
func (c *Connection) Quit(message ...string)
QUIT command
optional argument: quit message
func (*Connection) Rawf ¶
func (c *Connection) Rawf(format string, a ...interface{})
send a "raw" formatted line to the server
func (*Connection) RemoveCallback ¶
func (c *Connection) RemoveCallback(name string, id string) bool
func (*Connection) RunCallbacks ¶
func (c *Connection) RunCallbacks(message *Message)
Execute registered callbacks for message
func (*Connection) SetTopic ¶
func (c *Connection) SetTopic(channel, topic string)
func (*Connection) SetupPlugins ¶
func (c *Connection) SetupPlugins(plugins []PluginConfiguration)
Add callbacks for every configured plugin.
func (*Connection) Shutdown ¶
func (c *Connection) Shutdown()
func (*Connection) User ¶
func (c *Connection) User(ident, realname string)
USER command http://tools.ietf.org/html/rfc2812#section-3.1.3
Parameters: <user> <mode> <unused> <realname>
type IRCCallback ¶ added in v0.2.0
type IRCCallback func(message *Message)
type Message ¶
Each line from the IRC server is parsed into a Message struct.
Src => "irc.example.com" or "nick!ident@host" Raw => "nick!ident@host PRIVMSG #channel :hello world"
func (*Message) IsFromChannel ¶
Returns true if the Message generated inside a IRC channel
Channel types: https://www.alien.net.au/irc/chantypes.html
func (*Message) ReplyTarget ¶
Returns a channel name when the message was sent to a public channel or a nickname when the message was sent privately.