PaulSonOfLars / gotgbot

Autogenerated Go wrapper for the telegram API. Inspired by the python-telegram-bot library.
MIT License
478 stars 106 forks source link

I want to interrupt the Conversation when receiving any command command or text route #181

Open DukeAnn opened 2 months ago

DukeAnn commented 2 months ago

I want to interrupt the Conversation when receiving any command command or text route。 Because many users are halfway through the operation. It may have been replaced by other operations and no termination command was sent.

PaulSonOfLars commented 2 months ago

Hi! You should be able to do this by setting a message handler on any command message as an exit for your conversation.

Have a look at the conversation handler struct for all the available options :)

DukeAnn commented 2 months ago

That is to say, I must write the exit message routing in

// Exits is the list of handlers to exit the current conversation partway (eg /cancel commands). This returns
// EndConversation() by default, unless otherwise specified.
Exits[]ext.Handler

What I expect is that sending /start or other commands will interrupt the Conversation. I have many Conversations and I can't write all the routing commands for each one. Are there any other solutions or cases?

PaulSonOfLars commented 1 month ago

Hi, thanks for your patience on my reply.

It's up to you to keep track of which exits to handle - thats not something the library can handle, as all conversations are entirely separate from the library's perspective