Made first an announcing event

This commit is contained in:
Chris Sexton 2013-02-01 08:41:18 -05:00
parent 1e32fbf5ea
commit ee15217634
1 changed files with 12 additions and 5 deletions

View File

@ -65,6 +65,7 @@ func (p *FirstPlugin) Message(message bot.Message) bool {
} else { } else {
if isToday(p.First.Time) { if isToday(p.First.Time) {
p.recordFirst(message) p.recordFirst(message)
return true
} }
} }
@ -72,11 +73,8 @@ func (p *FirstPlugin) Message(message bot.Message) bool {
"?", "", "!", "") "?", "", "!", "")
msg := strings.ToLower(message.Body) msg := strings.ToLower(message.Body)
if r.Replace(msg) == "whos on first" { if r.Replace(msg) == "whos on first" {
c := message.Channel p.announceFirst(message)
if p.First != nil { return true
p.Bot.SendMessage(c, fmt.Sprintf("%s had first at %s with the message: \"%s\"",
p.First.Nick, p.First.Time.Format(time.Kitchen), p.First.Body))
}
} }
return false return false
@ -91,6 +89,15 @@ func (p *FirstPlugin) recordFirst(message bot.Message) {
Nick: message.User.Name, Nick: message.User.Name,
} }
p.Coll.Insert(p.First) p.Coll.Insert(p.First)
p.announceFirst(message)
}
func (p *FirstPlugin) announceFirst(message bot.Message) {
c := message.Channel
if p.First != nil {
p.Bot.SendMessage(c, fmt.Sprintf("%s had first at %s with the message: \"%s\"",
p.First.Nick, p.First.Time.Format(time.Kitchen), p.First.Body))
}
} }
// LoadData imports any configuration data into the plugin. This is not strictly necessary other // LoadData imports any configuration data into the plugin. This is not strictly necessary other