Skip to content

Commit ba26a8b

Browse files
committed
use command filter instead of regexhandler python-telegram-bot#292
1 parent d028d4e commit ba26a8b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,14 @@ To enable our bot to respond to inline queries, we can add the following (you wi
398398
>>> inline_caps_handler = InlineQueryHandler(inline_caps)
399399
>>> dispatcher.add_handler(inline_caps_handler)
400400
401-
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:
401+
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:
402402

403403
.. code:: python
404404
405405
>>> def unknown(bot, update):
406406
... bot.sendMessage(chat_id=update.message.chat_id, text="Sorry, I didn't understand that command.")
407407
...
408-
>>> from telegram.ext import RegexHandler
409-
>>> unknown_handler = RegexHandler(r'/.*', unknown)
408+
>>> unknown_handler = MessageHandler([Filters.command], unknown)
410409
>>> dispatcher.add_handler(unknown_handler)
411410
412411
If you're done playing around, stop the bot with this:

0 commit comments

Comments
 (0)