Fixed the name of the bot to always be current (could remove from config.json)

This commit is contained in:
Chris Sexton 2013-01-22 14:46:51 -05:00
parent 8ffac9291b
commit ae42e62872
3 changed files with 47 additions and 2 deletions

View File

@ -114,6 +114,8 @@ func NewBot(config *config.Config, c *irc.Conn) *Bot {
RunNewLogger(logIn, logOut) RunNewLogger(logIn, logOut)
config.Nick = c.Me.Name
return &Bot{ return &Bot{
Config: config, Config: config,
Plugins: make(map[string]Handler), Plugins: make(map[string]Handler),

View File

@ -1,3 +1,46 @@
package plugins package plugins
// "Welcome back, deleveled, you sucked at idling for %n, a new personal best!" import "bitbucket.org/phlyingpenguin/godeepintir/bot"
import (
"labix.org/v2/mgo"
)
// This is a downtime plugin to monitor how much our users suck
type DowntimePlugin struct {
Bot *bot.Bot
Coll *mgo.Collection
}
// NewDowntimePlugin creates a new DowntimePlugin with the Plugin interface
func NewDowntimePlugin(bot *bot.Bot) *DowntimePlugin {
return &DowntimePlugin{
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 *DowntimePlugin) 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 *DowntimePlugin) LoadData() {
p.Coll = p.Bot.Db.C("downtime")
}
// Help responds to help requests. Every plugin must implement a help function.
func (p *DowntimePlugin) Help(channel string, parts []string) {
p.Bot.SendMessage(channel, "Sorry, Downtime does not do a goddamn thing.")
}
// Empty event handler because this plugin does not do anything on event recv
func (p *DowntimePlugin) Event(kind string, message bot.Message) bool {
return false
}

View File

@ -338,7 +338,7 @@ func (p *FactoidPlugin) Message(message bot.Message) bool {
return p.trigger(message) return p.trigger(message)
} }
if message.Body == "forget that" { if strings.ToLower(message.Body) == "forget that" {
return p.forgetLastFact(message) return p.forgetLastFact(message)
} }