Fixing self remembering problems stemming from lib change.

This commit is contained in:
Chris Sexton 2013-06-17 00:04:10 -04:00
parent a91ebde376
commit 0acd004e59
3 changed files with 9 additions and 7 deletions

View File

@ -149,6 +149,9 @@ func (b *Bot) AddHandler(name string, h Handler) {
} }
func (b *Bot) SendMessage(channel, message string) { func (b *Bot) SendMessage(channel, message string) {
if !strings.HasPrefix(message, actionPrefix) {
b.selfSaid(channel, message, false)
}
for len(message) > 0 { for len(message) > 0 {
m := irc.Msg{ m := irc.Msg{
Cmd: "PRIVMSG", Cmd: "PRIVMSG",
@ -164,19 +167,16 @@ func (b *Bot) SendMessage(channel, message string) {
} }
b.Client.Out <- m b.Client.Out <- m
} }
b.selfSaid(channel, message)
} }
// Sends action to channel // Sends action to channel
func (b *Bot) SendAction(channel, message string) { 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" message = actionPrefix + " " + message + "\x01"
b.SendMessage(channel, message) b.SendMessage(channel, message)
// Notify plugins that we've said something
b.selfSaid(channel, message)
} }
// Handles incomming PRIVMSG requests // Handles incomming PRIVMSG requests

View File

@ -215,12 +215,13 @@ func (b *Bot) Help(channel string, parts []string) {
} }
// Send our own musings to the plugins // 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{ msg := Message{
User: &b.Me, // hack User: &b.Me, // hack
Channel: channel, Channel: channel,
Body: message, Body: message,
Raw: message, // hack Raw: message, // hack
Action: action,
Command: false, Command: false,
Time: time.Now(), Time: time.Now(),
Host: "0.0.0.0", // hack Host: "0.0.0.0", // hack

View File

@ -58,6 +58,7 @@ 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]
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),