I’m trying to let bot send the message that i gave him by first sending /send_m
command then it will ask for the message after that i write the message it will send it to other users, the problem is that message handler is running send
function even if I didn’t give it /send_m
command how can i fix this issue?
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler('send', send_m))
dispatcher.add_handler(MessageHandler(Filters.text,send))
updater.start_polling()
I’m handling messages and commands like this.
2
Answers
I've daclared a boolean variable and when i get the command it's been set to
True
and declared end function to set the booleanFalse
when the function called and i put if statement for every message handled to check if send command has called.You may notice that MessageHandler is used instead of CommandHandler. This is a more general handler that selects messages based off flags that you supply. In this case, it handles messages that contain text but aren’t commands