From 0acd004e595e41c391fdcfc5a78d316473061743 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 17 Jun 2013 00:04:10 -0400 Subject: [PATCH] Fixing self remembering problems stemming from lib change. --- bot/bot.go | 12 ++++++------ bot/handlers.go | 3 ++- plugins/remember.go | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bot/bot.go b/bot/bot.go index ed4e9bf..e64959c 100644 --- a/bot/bot.go +++ b/bot/bot.go @@ -149,6 +149,9 @@ func (b *Bot) AddHandler(name string, h Handler) { } func (b *Bot) SendMessage(channel, message string) { + if !strings.HasPrefix(message, actionPrefix) { + b.selfSaid(channel, message, false) + } for len(message) > 0 { m := irc.Msg{ Cmd: "PRIVMSG", @@ -164,19 +167,16 @@ func (b *Bot) SendMessage(channel, message string) { } b.Client.Out <- m } - - b.selfSaid(channel, message) } // Sends action to channel func (b *Bot) SendAction(channel, message string) { - // TODO: ADD CTCP ACTION + // Notify plugins that we've said something + b.selfSaid(channel, message, true) + message = actionPrefix + " " + message + "\x01" b.SendMessage(channel, message) - - // Notify plugins that we've said something - b.selfSaid(channel, message) } // Handles incomming PRIVMSG requests diff --git a/bot/handlers.go b/bot/handlers.go index 0cf9741..4c8d658 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -215,12 +215,13 @@ func (b *Bot) Help(channel string, parts []string) { } // Send our own musings to the plugins -func (b *Bot) selfSaid(channel, message string) { +func (b *Bot) selfSaid(channel, message string, action bool) { msg := Message{ User: &b.Me, // hack Channel: channel, Body: message, Raw: message, // hack + Action: action, Command: false, Time: time.Now(), Host: "0.0.0.0", // hack diff --git a/plugins/remember.go b/plugins/remember.go index c259bdd..9bc61f2 100644 --- a/plugins/remember.go +++ b/plugins/remember.go @@ -58,6 +58,7 @@ func (p *RememberPlugin) Message(message bot.Message) bool { for i := len(p.Log[message.Channel]) - 1; i >= 0; i-- { entry := p.Log[message.Channel][i] + if strings.ToLower(entry.User.Name) == strings.ToLower(nick) && strings.Contains( strings.ToLower(entry.Body),