-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
I have a bot that has a few very simple responses. I tried doing the following to register multiple listeners on the bot calling initSimple
from within a InitPlugin
func and passing it the reference to the bot.
var simpleResponses = map[string]string {
"listenfor1": "response1",
"listenfor2": "response2",
}
func initSimple(bot *slick.Bot) {
for listen, response := range simpleResponses {
bot.Listen(&slick.Listener{
Contains: listen,
MessageHandlerFunc: func(l *slick.Listener, m *slick.Message) {
m.Reply(response)
},
})
}
}
The problem is that every "query" into simpleResponses returns the response from the last response, e.g. "response2" in this case. I've also tried generating a listener for every case and handing them to the bot one for one, but that leads to the same result.
Any help on how to achieve this would be much appreciated 😊
Metadata
Metadata
Assignees
Labels
No labels