Closed Gercov closed 2 years ago
Sorry, I am not following. Could you come up with a user story? Like what the user sends and how do you expect the bot to react?
Just a shot in the dark, make sure you register command handlers before the scenes processor. This way, /commands
will have the priority.
Sorry, I am not following. Could you come up with a user story? Like what the user sends and how do you expect the bot to react?
Just a shot in the dark, make sure you register command handlers before the scenes processor. This way,
/commands
will have the priority.
Thank you very much, the error was that I was registering command handlers after registering scenes, because of which it did not work
But now another problem has appeared, how do I end the scene if nothing happens inside it when I enter another command of the command bot?
One may exit the current scene with ctx.scene.exit()
(from a scene handler) if that's what you mean. Otherwise, please come up with a particular example.
One may exit the current scene with
ctx.scene.exit()
(from a scene handler) if that's what you mean. Otherwise, please come up with a particular example.
Example: Being in a scene where you need to enter some text for further actions, a person decides to cancel it and calls another bot command. It is processed by a handler outside the scene, but the scene is not completed. How to fix it?
You may add this to your command handler:
delete ctx.session.scenes
or you may do that universally for all commands with something like:
bot.on("message:text", (ctx, next) => {
if (ctx.message.text.startsWith("/")) {
delete ctx.session.scenes
}
return next()
})
I think we should add something like ctx.scenes.abort()
so that user doesn't need to manually edit the session data.
Вы можете добавить это в свой обработчик команд:
удалить ctx.session.scenes
или вы можете сделать это универсально для всех команд с помощью чего-то вроде:
bot.on("message:text", (ctx, next) => { if (ctx.message.text.StartsWith("/")) { delete ctx.session.scenes } return next() })
Я думаю, мы должны добавить что-то вроде
ctx.scenes.abort()
того, чтобы пользователю не нужно было вручную редактировать данные сеанса.
Thanks
I create a scene where the user should enter the text, but I want the opportunity to cancel the input by the Bot command. How can I continue to execute the command if the handlers outside the scene are already registered on them?
next() does not work