I created a Python Telegram bot and registered two command handlers. The issue is that the hello command handler is not working.
I tried changing the group of that handler to group=2, still hello does not get invoked when I use /rtd.
Unable to figure out the issue.
def mybot():
print("dispatcher created.")
updater = Updater(token=my_token)
dispatcher = updater.dispatcher
dispatcher.add_error_handler(error_callback)
dispatcher.add_handler(CommandHandler('start', start))
dispatcher.add_handler(CommandHandler('rtd', hello, pass_args=True))
dispatcher.add_handler(MessageHandler(Filters.command, unknown))
print("handlers added.")
updater.start_polling()
updater.idle()
pass
def hello(bot, update, cmd):
print("hello handler", cmd)
pass
def start(bot, update):
bot.sendMessage(chat_id=update.message.chat_id, text="bot start!")
pass
def unknown(bot, update):
bot.send_message(chat_id=update.message.chat_id, text="unknown stuff.")
pass
def error_callback(bot, update, error):
try:
raise error
except TelegramError:
print("Telegram Error")
if __name__ == '__main__':
print("bot started.")
mybot()

hellofunction useprintinstead ofbot.send_message, where you are expecting the output? 2. I see some indent issue in your code. That's right? - Stefano Giraldi