Fixing small remember bug (trim snips)

This commit is contained in:
Chris Sexton 2013-08-31 23:33:15 -04:00
parent 54899c74ca
commit 2acf375997
1 changed files with 5 additions and 0 deletions

View File

@ -60,6 +60,7 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
var trigger string var trigger string
for _, snip := range snips { for _, snip := range snips {
snip = strings.TrimSpace(snip)
snipParts := strings.Split(snip, " ") snipParts := strings.Split(snip, " ")
nick := snipParts[0] nick := snipParts[0]
snip := strings.Join(snipParts[1:], " ") snip := strings.Join(snipParts[1:], " ")
@ -67,6 +68,8 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
for i := len(p.Log[message.Channel]) - 1; i >= 0; i-- { for i := len(p.Log[message.Channel]) - 1; i >= 0; i-- {
entry := p.Log[message.Channel][i] entry := p.Log[message.Channel][i]
log.Println("Test entry:", entry.User.Name, entry.Body)
if strings.ToLower(entry.User.Name) == strings.ToLower(nick) && if strings.ToLower(entry.User.Name) == strings.ToLower(nick) &&
strings.Contains( strings.Contains(
strings.ToLower(entry.Body), strings.ToLower(entry.Body),
@ -117,6 +120,8 @@ func (p *RememberPlugin) Message(message bot.Message) bool {
log.Println("ERROR!!!!:", err) log.Println("ERROR!!!!:", err)
} }
log.Println("Remembering factoid:", msg)
// sorry, not creative with names so we're reusing msg // sorry, not creative with names so we're reusing msg
msg = fmt.Sprintf("Okay, %s, remembering '%s'.", msg = fmt.Sprintf("Okay, %s, remembering '%s'.",
message.User.Name, msg) message.User.Name, msg)