From ee15217634bf6822b0efcdcc889be8e23ae4ea14 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 1 Feb 2013 08:41:18 -0500 Subject: [PATCH] Made first an announcing event --- plugins/first.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/first.go b/plugins/first.go index 4cdcc12..0b3e677 100644 --- a/plugins/first.go +++ b/plugins/first.go @@ -65,6 +65,7 @@ func (p *FirstPlugin) Message(message bot.Message) bool { } else { if isToday(p.First.Time) { p.recordFirst(message) + return true } } @@ -72,11 +73,8 @@ func (p *FirstPlugin) Message(message bot.Message) bool { "?", "", "!", "") msg := strings.ToLower(message.Body) if r.Replace(msg) == "whos on first" { - 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)) - } + p.announceFirst(message) + return true } return false @@ -91,6 +89,15 @@ func (p *FirstPlugin) recordFirst(message bot.Message) { Nick: message.User.Name, } 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