From ba26a8ba5d3aa3aba7ebdf68d8bb081d16cc201a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Tue, 17 May 2016 07:36:04 +0200 Subject: [PATCH] use command filter instead of regexhandler #292 --- README.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 736e5408b..2d73f6c8d 100644 --- a/README.rst +++ b/README.rst @@ -398,15 +398,14 @@ To enable our bot to respond to inline queries, we can add the following (you wi >>> inline_caps_handler = InlineQueryHandler(inline_caps) >>> dispatcher.add_handler(inline_caps_handler) -People might try to send commands to the bot that it doesn't understand, so we can use a ``RegexHandler`` to recognize all commands that were not recognized by the previous handlers. **Note:** This handler has to be added last, else it will be triggered before the ``CommandHandlers`` had a chance to look at the update: +People might try to send commands to the bot that it doesn't understand, so we can use a ``MessageHandler`` with a ``command`` filter to recognize all commands that were not recognized by the previous handlers. **Note:** This handler has to be added last, else it will be triggered before the ``CommandHandlers`` had a chance to look at the update: .. code:: python >>> def unknown(bot, update): ... bot.sendMessage(chat_id=update.message.chat_id, text="Sorry, I didn't understand that command.") ... - >>> from telegram.ext import RegexHandler - >>> unknown_handler = RegexHandler(r'/.*', unknown) + >>> unknown_handler = MessageHandler([Filters.command], unknown) >>> dispatcher.add_handler(unknown_handler) If you're done playing around, stop the bot with this: