mirror of https://github.com/velour/catbase.git
Moved tolower for triggers, allowed him to respond to long facts
This commit is contained in:
parent
713130bfea
commit
11ad192d18
|
@ -53,6 +53,7 @@ func (p *FactoidPlugin) learnFact(message bot.Message, trigger, operator, fact s
|
||||||
full = fmt.Sprintf("%s %s %s", trigger, operator, fact)
|
full = fmt.Sprintf("%s %s %s", trigger, operator, fact)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trigger = strings.ToLower(trigger)
|
||||||
newfact := factoid{
|
newfact := factoid{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
Trigger: trigger,
|
Trigger: trigger,
|
||||||
|
@ -90,6 +91,14 @@ func (p *FactoidPlugin) Message(message bot.Message) bool {
|
||||||
|
|
||||||
// This plugin has no business with normal messages
|
// This plugin has no business with normal messages
|
||||||
if !message.Command {
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +111,6 @@ func (p *FactoidPlugin) Message(message bot.Message) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger := strings.TrimSpace(parts[0])
|
trigger := strings.TrimSpace(parts[0])
|
||||||
trigger = strings.ToLower(trigger)
|
|
||||||
fact := strings.TrimSpace(parts[1])
|
fact := strings.TrimSpace(parts[1])
|
||||||
action := strings.TrimSpace(action)
|
action := strings.TrimSpace(action)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue