diff --git a/bot/handlers.go b/bot/handlers.go index c010685..b76fd27 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -48,9 +48,9 @@ func (b *Bot) Msg_recieved(conn *irc.Conn, line *irc.Line) { if len(parts) > 0 && parts[0] == "help" { if len(parts) == 1 { // just print out a list of help topics - topics := "Help topics: About" + topics := "Help topics: about" for name, _ := range b.Plugins { - topics = fmt.Sprintf("%s, %s ", topics, name) + topics = fmt.Sprintf("%s, %s", topics, name) } b.SendMessage(channel, topics) } else { diff --git a/main.go b/main.go index dec5e34..be576b5 100644 --- a/main.go +++ b/main.go @@ -43,7 +43,9 @@ func main() { b := bot.NewBot(config, c) // b.AddHandler(plugins.NewTestPlugin(b)) - b.AddHandler("Talker", plugins.NewTalkerPlugin(b)) + b.AddHandler("talker", plugins.NewTalkerPlugin(b)) + b.AddHandler("beers", plugins.NewBeersPlugin(b)) + b.AddHandler("skeleton", plugins.NewSkeletonPlugin(b)) c.AddHandler("PRIVMSG", func(conn *irc.Conn, line *irc.Line) { b.Msg_recieved(conn, line) diff --git a/plugins/beers.go b/plugins/beers.go new file mode 100644 index 0000000..aee3017 --- /dev/null +++ b/plugins/beers.go @@ -0,0 +1,36 @@ +package plugins + +import "bitbucket.org/phlyingpenguin/godeepintir/bot" + +// This is a skeleton plugin to serve as an example and quick copy/paste for new plugins. + +type BeersPlugin struct { + Bot *bot.Bot +} + +// NewBeersPlugin creates a new BeersPlugin with the Plugin interface +func NewBeersPlugin(bot *bot.Bot) *BeersPlugin { + return &BeersPlugin{ + Bot: bot, + } +} + +// Message responds to the bot hook on recieving messages. +// This function returns true if the plugin responds in a meaningful way to the users message. +// Otherwise, the function returns false and the bot continues execution of other plugins. +func (p *BeersPlugin) Message(message bot.Message) bool { + // This bot does not reply to anything + return false +} + +// LoadData imports any configuration data into the plugin. This is not strictly necessary other +// than the fact that the Plugin interface demands it exist. This may be deprecated at a later +// date. +func (p *BeersPlugin) LoadData() { + // This bot has no data to load +} + +// Help responds to help requests. Every plugin must implement a help function. +func (p *BeersPlugin) Help(channel string, parts []string) { + p.Bot.SendMessage(channel, "Sorry, Beers does not do a goddamn thing.") +} diff --git a/plugins/skeleton.go b/plugins/skeleton.go new file mode 100644 index 0000000..bac69e1 --- /dev/null +++ b/plugins/skeleton.go @@ -0,0 +1,36 @@ +package plugins + +import "bitbucket.org/phlyingpenguin/godeepintir/bot" + +// This is a skeleton plugin to serve as an example and quick copy/paste for new plugins. + +type SkeletonPlugin struct { + Bot *bot.Bot +} + +// NewSkeletonPlugin creates a new SkeletonPlugin with the Plugin interface +func NewSkeletonPlugin(bot *bot.Bot) *SkeletonPlugin { + return &SkeletonPlugin{ + Bot: bot, + } +} + +// Message responds to the bot hook on recieving messages. +// This function returns true if the plugin responds in a meaningful way to the users message. +// Otherwise, the function returns false and the bot continues execution of other plugins. +func (p *SkeletonPlugin) Message(message bot.Message) bool { + // This bot does not reply to anything + return false +} + +// LoadData imports any configuration data into the plugin. This is not strictly necessary other +// than the fact that the Plugin interface demands it exist. This may be deprecated at a later +// date. +func (p *SkeletonPlugin) LoadData() { + // This bot has no data to load +} + +// Help responds to help requests. Every plugin must implement a help function. +func (p *SkeletonPlugin) Help(channel string, parts []string) { + p.Bot.SendMessage(channel, "Sorry, Skeleton does not do a goddamn thing.") +}