Documentation
¶
Overview ¶
Package core contains the bot's core functionalities
Index ¶
- func GetTargetFromEvent(event *irc.Event) string
- func UpdateUserList(event *irc.Event)
- type Bot
- func (bot *Bot) AddCmdHandler(cmdStruct *Command, replyCallback func(*ReplyCallbackData))
- func (bot *Bot) AddMsgHandler(msgProcessCallback func(*irc.Event, func(*ReplyCallbackData)), ...)
- func (bot *Bot) Reply(data *ReplyCallbackData)
- func (bot *Bot) ReplyToAll(data *ReplyCallbackData)
- func (bot *Bot) Run()
- func (bot *Bot) Stop()
- type Command
- type ReplyCallbackData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTargetFromEvent ¶
func GetTargetFromEvent(event *irc.Event) string
GetTargetFromEvent If the message originated from a channel then return it, else return the nick that sent the message
func UpdateUserList ¶
func UpdateUserList(event *irc.Event)
UpdateUserList Update the user list used for access control
Types ¶
type Bot ¶
type Bot struct { Admins *[]string // contains filtered or unexported fields }
Bot structure that contains connection informations, IRC connection, command handlers and message handlers
func NewBot ¶
NewBot creates a new Bot, sets the required parameters and open the connection to the server.
func (*Bot) AddCmdHandler ¶
func (bot *Bot) AddCmdHandler(cmdStruct *Command, replyCallback func(*ReplyCallbackData))
AddCmdHandler adds a command handler to bot. cmdStruct is a pointer to a Command structure. replyCallback is to be called by cmdProcessCallback (or not) to yield and process its result as a string message. Command handlers must return true if they found a command to process, false otherwise
func (*Bot) AddMsgHandler ¶
func (bot *Bot) AddMsgHandler(msgProcessCallback func(*irc.Event, func(*ReplyCallbackData)), replyCallback func(*ReplyCallbackData))
AddMsgHandler adds a message handler to bot. msgProcessCallback will be called on every user message the bot reads (if a command was not found previously in the message). replyCallback is to be called by msgProcessCallback (or not) to yield and process its result as a string message.
func (*Bot) Reply ¶
func (bot *Bot) Reply(data *ReplyCallbackData)
Reply sends a message to the user or channel specifed by "data.Target".
func (*Bot) ReplyToAll ¶
func (bot *Bot) ReplyToAll(data *ReplyCallbackData)
ReplyToAll sends a message to the channel where the bot is connected
type Command ¶
type Command struct { Module string HelpMessage string Triggers []string Handler func(event *irc.Event, callback func(*ReplyCallbackData)) bool }
Command structure
type ReplyCallbackData ¶
type ReplyCallbackData struct { Message string // Message to send Target string // Destination target of the message (Channel or Nick) }
ReplyCallbackData Structure used by the handlers to send data in a standardized format