simmsb/calamity

Question: how to make bot to respond on mention

Closed this issue · 3 comments

for example

@bot hello how are you

simmsb commented

Sorry I've been busy recently.

You can do this with a custom implementation of parsePrefix: https://hackage.haskell.org/package/calamity-commands-0.4.0.0/docs/CalamityCommands-ParsePrefix.html#t:ParsePrefix

ParsePrefix has access to the usual effects so you'll be able to use getBotUser to find the bot's id, and then you can remove the prefix: <@{bot id}> from the message.

In my bot I have a parse prefix implementation that loads prefixes from a database: https://github.com/simmsb/calamity-bot/blob/master/src/CalamityBot/PrefixHandler.hs#L19

Doesn't a Message include all its mentions? You could use that with getBotUser, no?

https://hackage.haskell.org/package/calamity-0.7.1.0/docs/Calamity-Types-Model-Channel-Message.html#t:Message

Doesn't a Message include all its mentions? You could use that with getBotUser, no?

https://hackage.haskell.org/package/calamity-0.7.1.0/docs/Calamity-Types-Model-Channel-Message.html#t:Message

yes will try to add react on channel message, thank you