Documentation
¶
Overview ¶
Package bot provides a simple to use IRC bot
Index ¶
Constants ¶
const ( // CmdPrefix is the prefix used to identify a command. // !hello whould be identified as a command CmdPrefix = "!" )
Variables ¶
This section is empty.
Functions ¶
func RegisterCommand ¶
func RegisterCommand(command, description, exampleArgs string, cmdFunc func(cmd *Cmd) (string, error))
RegisterCommand adds a new command to the bot. The command(s) should be registered in the Ini() func of your package command: String which the user will use to execute the command, example: reverse decription: Description of the command to use in !help, example: Reverses a string exampleArgs: Example args to be displayed in !help <command>, example: string to be reversed cmdFunc: Function which will be executed. It will received a parsed command as a Cmd value
func RegisterPassiveCommand ¶
func RegisterPassiveCommand(command string, cmdFunc func(cmd *PassiveCmd) (string, error))
RegisterPassiveCommand adds a new passive command to the bot. The command(s) should be registered in the Ini() func of your package Passive commands receives all the text posted to a channel without any parsing command: String used to identify the command, for internal use only (ex: logs) cmdFunc: Function which will be executed. It will received the raw message, channel and nick
Types ¶
type Cmd ¶
type Cmd struct {
Raw string // Raw is full string passed to the command
Channel string // Channel where the command was called
Nick string // User who sent the message
Message string // Full string without the prefix
Command string // Command is the first argument passed to the bot
FullArg string // Full argument as a single string
Args []string // Arguments as array
}
Cmd holds the parsed user's input for easier handling of commands
type Config ¶
type Config struct {
Server string // IRC server:port. Ex: irc.freenode.org:7000
Channels []string // Channels to connect. Ex: []string{"#go-bot", "#channel mypassword"}
User string // The IRC username the bot will use
Nick string // The nick the bot will use
Password string // Server password
UseTLS bool // Should connect using TLS?
TLSServerName string // Must supply if UseTLS is true
Debug bool // This will log all IRC communication to standad output
}
Config must contain the necessary data to connect to an IRC server
type PassiveCmd ¶
type PassiveCmd struct {
Raw string // Raw message sent to the channel
Channel string // Channel which the message was sent to
Nick string // Nick of the user which sent the message
}
PassiveCmd holds the information which will be passed to passive commands when receiving a message on the channel

