mirror of https://github.com/velour/catbase.git
Fixing multi-channel factoid squirts.
This commit is contained in:
parent
276cc3e2fe
commit
eff200ee15
|
@ -125,12 +125,17 @@ func (b *Bot) buildMessage(conn *irc.Client, inMsg irc.Msg) Message {
|
|||
return msg
|
||||
}
|
||||
|
||||
func (b *Bot) LastMessage() (Message, error) {
|
||||
func (b *Bot) LastMessage(channel string) (Message, error) {
|
||||
log := <-b.logOut
|
||||
if len(log) == 0 {
|
||||
return Message{}, errors.New("No messages found.")
|
||||
}
|
||||
return log[len(log)-1], nil
|
||||
for i := len(log); i > 0; i-- {
|
||||
if log[i].Channel == channel {
|
||||
return log[i], nil
|
||||
}
|
||||
}
|
||||
return Message{}, errors.New("No messages found.")
|
||||
}
|
||||
|
||||
// Take an input string and mutate it based on $vars in the string
|
||||
|
|
|
@ -421,7 +421,7 @@ func (p *FactoidPlugin) factTimer(channel string) {
|
|||
for {
|
||||
time.Sleep(time.Duration(5) * time.Second)
|
||||
|
||||
lastmsg, err := p.Bot.LastMessage()
|
||||
lastmsg, err := p.Bot.LastMessage(channel)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue