From 11ad192d18668638514fcd50c534b02c3fbf1beb Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Sun, 26 Aug 2012 15:52:38 -0400 Subject: [PATCH] Moved tolower for triggers, allowed him to respond to long facts --- plugins/factoid.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/factoid.go b/plugins/factoid.go index 620e7fb..37350bf 100644 --- a/plugins/factoid.go +++ b/plugins/factoid.go @@ -53,6 +53,7 @@ func (p *FactoidPlugin) learnFact(message bot.Message, trigger, operator, fact s full = fmt.Sprintf("%s %s %s", trigger, operator, fact) } + trigger = strings.ToLower(trigger) newfact := factoid{ Id: 0, Trigger: trigger, @@ -90,6 +91,14 @@ func (p *FactoidPlugin) Message(message bot.Message) bool { // This plugin has no business with normal messages if !message.Command { + // look for any triggers in the db matching this message + if len(message.Body) > 4 { + if ok, fact := p.findTrigger(body); ok { + fact = p.Bot.Filter(message, fact) + p.Bot.SendMessage(message.Channel, fact) + return true + } + } return false } @@ -102,7 +111,6 @@ func (p *FactoidPlugin) Message(message bot.Message) bool { } trigger := strings.TrimSpace(parts[0]) - trigger = strings.ToLower(trigger) fact := strings.TrimSpace(parts[1]) action := strings.TrimSpace(action)