Documentation ¶
Overview ¶
Package bort provides the base for an IRC bot with plugin capability.
The bot consists of the bort command, which handles the IRC connection, and the bortplug command, which handles plugins. The bortplug command can be stopped, recompiled with different or reconfigured plugins, and restarted while the bort command stays commected to the IRC server.
Plugins may implement commands, respond to matched text, or push messages asynchronously. Plugins are compiled into the bortplug command. To enable a plugin, add 'import _ "plugin_import_path"' to cmd/bortplug/plugins.go.
Bort looks for a JSON configuration file in ~/.config/bort/bort.conf, which can be overridden with a command line parameter. Bort prioritizes command line parameter values, followed by configuration file, and finally, default values. Plugins have access to the configuration file data, and may look for values of an appropriate key.
Index ¶
- Constants
- func GetConfig(cfg interface{}) error
- func LoadConfig(cfg interface{}, cfgFile string) error
- func PluginInit(outboxSize uint)
- func Push(msg *Message) error
- func RegisterCommand(cmd, help string, handle HandleFunc) error
- func RegisterMatcher(types MessageType, match string, handle HandleFunc) (uint64, error)
- func RegisterSetup(fn SetupFunc)
- func UnregisterCommand(cmd string) bool
- func UnregisterMatcher(id uint64) bool
- type HandleFunc
- type Message
- type MessageType
- type Plugin
- type SetupFunc
Constants ¶
const (
// default address for bort/bortplug communication
DefaultAddress = ":8075"
)
Variables ¶
This section is empty.
Functions ¶
func GetConfig ¶
func GetConfig(cfg interface{}) error
GetConfig populates cfg with data from the configuration file
func LoadConfig ¶
LoadConfig loads the given or default config file
func PluginInit ¶
func PluginInit(outboxSize uint)
PluginInit calls plugin setup functions, sets up the push queue, and generates plugin help text.
func RegisterCommand ¶
func RegisterCommand(cmd, help string, handle HandleFunc) error
RegisterCommand registers a command handler for the given name. help is a one line description of the plugin's purpose.
func RegisterMatcher ¶
func RegisterMatcher(types MessageType, match string, handle HandleFunc) (uint64, error)
RegisterMatcher registers a match handler for the given regular expression. types is a bitmask that specifies which message types to consider. The text matched (or that of the first capturing group, if any) will be placed in the Match field of the message passed to handle.
func RegisterSetup ¶
func RegisterSetup(fn SetupFunc)
RegisterSetup registers a function to be run once bort has connected and joined. Plugins should typically call this from init() to ensure fn called.
func UnregisterCommand ¶
UnregisterCommand unrigesters the command handler for the given name, if found, and returns whether a handler was removed.
func UnregisterMatcher ¶
UnregisterMatcher unrigesters the match handler for the given ID, if found, and returns whether a handler was removed.
Types ¶
type HandleFunc ¶
HandleFunc provides an interface for handling IRC messages.
type Message ¶
type Message struct { // incoming and outgoing Type MessageType Context string Text string // ignored for outgoing Nick string User string Host string IRCCmd string Params []string Command string Args string Match string }
Message contains all data needed to deal with incoming and outgoing IRC messages.
type MessageType ¶
type MessageType int
MessageType is a bitmapped IRC message type.
const ( None MessageType = iota PrivMsg MessageType = 1 << iota Action Join Part All MessageType = 1<<iota - 1 )
message types
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
plugin
|
|
calc
Package calc is a bort IRC bot plugin that provides an interface to the clac RPN calculator.
|
Package calc is a bort IRC bot plugin that provides an interface to the clac RPN calculator. |
flip
Package flip is a bort IRC bot plugin that flips tables and text, in true emoji rage style.
|
Package flip is a bort IRC bot plugin that flips tables and text, in true emoji rage style. |
forecast
Package forecast is a bort IRC plugin that generates ascii forecasts using National Weather Service data.
|
Package forecast is a bort IRC plugin that generates ascii forecasts using National Weather Service data. |
heckle
Package heckle is a bort IRC bot plugin that responds to a set of watch regular expressions with provided retorts.
|
Package heckle is a bort IRC bot plugin that responds to a set of watch regular expressions with provided retorts. |
urltitle
Package urltitle is a bort IRC bot plugin that extracts titles for URLs posted in a channel
|
Package urltitle is a bort IRC bot plugin that extracts titles for URLs posted in a channel |