mirror of https://github.com/velour/catbase.git
Fixing self remembering problems stemming from lib change.
This commit is contained in:
parent
a91ebde376
commit
0acd004e59
12
bot/bot.go
12
bot/bot.go
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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),
|
||||||
|
|
Loading…
Reference in New Issue