Documentation ¶
Overview ¶
Package bot implements an IRC bot with plugins.
Index ¶
- func Channels(channels []string) func(*botImpl)
- func CommandPrefix(commandPrefix string) func(impl *botImpl)
- func Host(host string) func(*botImpl)
- func Ident(ident string) func(*botImpl)
- func Nick(nick string) func(*botImpl)
- func Password(password string) func(*botImpl)
- func Proxy(proxy string) func(*botImpl)
- func RealName(realName string) func(*botImpl)
- func SSL(ssl bool) func(*botImpl)
- type Bot
- type Command
- type Commands
- type Event
- type Handler
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Channels ¶
func Channels(channels []string) func(*botImpl)
Channels is an option to configure the channels for the bot to join.
func CommandPrefix ¶ added in v1.0.2
func CommandPrefix(commandPrefix string) func(impl *botImpl)
CommandPrefix is an option to configure the prefix of commands (default is !).
func Host ¶
func Host(host string) func(*botImpl)
Host is an option to configure the IRC server host.
func Password ¶
func Password(password string) func(*botImpl)
Password is an option to configure the IRC server password.
func Proxy ¶
func Proxy(proxy string) func(*botImpl)
Proxy is an option to configure a proxy to connect to the IRC server.
Types ¶
type Bot ¶
type Bot interface { Run() // Run bot, reconnect if disconnect. Quit(msg string) // Quit bot from IRC with a msg. Commands() *Commands // For plugins to Add/Del commands. Action(t, msg string) // Shortcut to Conn().Action() Connected() bool // Shortcut to Conn().Connected() HandleFunc(n string, h client.HandlerFunc) client.Remover // Shortcut to Conn().HandleFunc() Invite(nick, channel string) // Shortcut to Conn().Nick() Join(c string) // Shortcut to Conn().Join() Me() *state.Nick // Shortcut to Conn().Me() Mode(t string, m ...string) // Shortcut to Conn().Mode() Nick(nick string) // Shortcut to Conn().Nick() Notice(t, msg string) // Shortcut to Conn().Notice() Part(c string, m ...string) // Shortcut to Conn().Part() Privmsg(t, msg string) // Shortcut to Conn().Privmsg() Conn() *client.Conn // Conn returns the underlying goirc client connection. Channels() []string // Channels returns list of channels which bot has joined. CommandPrefix() string // Return's the bot's prefix used to specify commands }
Bot represents an IRC bot, with IRC client object, settings, commands.
func NewBotOptions ¶
NewBotOptions creates a new Bot implementation with options.
type Command ¶
type Command struct { Help string // Help string for help command. Handler Handler // Handler to call. Pub bool // Command can be accessed publicly on a channel. NoExclamation bool // Disallow calling command as "!command". Priv bool // Command can be accessed privately in query. Hidden bool // Hide command from list of all available commands. }
Command represents a command that plugins can add.
type Commands ¶
Commands holds commands by their name.
func (*Commands) Del ¶
Del allows plugins to remove commands added with Add (no error if not present).
func (*Commands) Handle ¶
Handle parses a line, matches with commands and dispatches to handler. A command can be triggered
- in public on a channel with: /msg #chan !cmd [args] or directly at a bot: /msg #chan bot: cmd [args] works also with a comma: /msg #chan bot, cmd [args]
- in private in a query: /msg bot cmd [args]
type Event ¶
type Event struct { Bot Bot Target string // Channel if public, nick if private. Args string // Command args (excluding command name). Line *client.Line }
Event is given to a command's Handler when a command matched by name.