From 76e6644b8bd442870b658ba246ed56db6efd0c7a Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Sun, 16 Jun 2013 22:40:30 -0400 Subject: [PATCH] One more fix to the fact spitter. Turns out channels have case. --- bot/handlers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot/handlers.go b/bot/handlers.go index 5b026c7..0cf9741 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -130,9 +130,10 @@ func (b *Bot) LastMessage(channel string) (Message, error) { if len(log) == 0 { return Message{}, errors.New("No messages found.") } - for i := len(log); i > 0; i-- { - if log[i].Channel == channel { - return log[i], nil + for i := len(log) - 1; i >= 0; i-- { + msg := log[i] + if strings.ToLower(msg.Channel) == strings.ToLower(channel) { + return msg, nil } } return Message{}, errors.New("No messages found.")