Repository: python-telegram-bot/python-telegram-bot

Issue:
[QUESTION] Documentation on #1678 / #1680
<!--
Hey there, you have a question? We are happy to answer. Please make sure no similar question was opened already.

The following template is a suggestion how you can report an issue you run into whilst using our library. If you just want to ask a question, feel free to delete everything; just make sure you have a describing title :)

Please mind that there is also a users' Telegram group at https://t.me/pythontelegrambotgroup for questions about the library. Questions asked there might be answered quicker than here. In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel at https://webchat.freenode.net/?channels=##python-telegram-bot to participate in the group.
-->

### Issue I am facing
My question is about issue #1678 and its corresponding commit #1680.
I have not worked on my bot since October, so I went through the transition guide to version 12 again in case I missed something in the meantime. After starting my bot again for the first time and playing around with it, I discovered that the various "/cancel" fallback states in my ConversationHandlers were broken, although they previously worked. During my attempts at fixing this, I went through the documentation on the Filters module, the ConversationHandler, and the MessageHandler.
Nothing seemed to get my fallback state to kick in, until I discovered #1678. As can be seen in my code, the bot is supposed to accept any text as a response except a certain command, which triggers the fallback state.
In essence, I now need to explicitly check if the received message is text *and* not a command (which was previously implied by just the text filter).
I do not know whether my solution was optimal to begin with, but at least everything appeared to be working before this change.

If this is all intended behavior, I would suggest updating the docs in at least one of these places:
- In the tutorial "Extensions – Your first Bot" at the very end, the note about the "unkown command" handler should include a warning that if any catch-all command handler with a text filter is added before it, it will not do anything. In fact, the last two MessageHandlers in my code were exactly like this because I followed this tutorial when I started. I discovered that the behavior of these two was also broken (I want to give two different replies depending on whether someone only entered text - which does nothing aside from during the conversations - or an unknown command).
- The docs for telegram.ext.filters should make a mention in the Filters.text section about also matching leading commands (only in special circumstances like mine?).
- The transition guide to version 12 could make a mention about this in the section on combining filters (as the fix for my problem uses this new behavior).

### Related part of my old code
```python
def main():
    #### ...
    conversation_handler_start = ConversationHandler(
        entry_points=[CommandHandler("start", start)],
        states={
            START_NAME_STATE: [MessageHandler(Filters.text, start_name)],
            START_MESSAGE_STATE: [MessageHandler(Filters.text, start_message)]
        },
        fallbacks=[CommandHandler("startcancel", startcancel)]
    )
    dispatcher.add_handler(conversation_handler_start)
    #### ...
    # --- Catch-all commands for unknown inputs:
    dispatcher.add_handler(MessageHandler(Filters.text, text))
    # The "unknown" handler needs to be added last because it would override any handlers added afterwards
    dispatcher.add_handler(MessageHandler(Filters.command, unknown))
```

### Fixed new code
```python
def main():
    #### ...
    conversation_handler_start = ConversationHandler(
        entry_points=[CommandHandler("start", start)],
        states={
            START_NAME_STATE: [MessageHandler(Filters.text & (~ Filters.command), start_name)],
            START_MESSAGE_STATE: [MessageHandler(Filters.text & (~ Filters.command), start_message)]
        },
        fallbacks=[CommandHandler("startcancel", startcancel)]
    )
    dispatcher.add_handler(conversation_handler_start)
    #### ...
    # --- Catch-all commands for unknown inputs:
    dispatcher.add_handler(MessageHandler(Filters.text & (~ Filters.command), text))
    # The "unknown" handler needs to be added last because it would override any handlers added afterwards
    dispatcher.add_handler(MessageHandler(Filters.command, unknown))
```



Discussion:
Hi there. Thanks for pointing out the outdated wiki. I'll make sure to update it and try to add a note to the docs. About the v12 transition guide: as this behavior was changed only in v12.4, it's listed in the [Changelog](https://python-telegram-bot.readthedocs.io/en/stable/changelog.html#version-12-4-0) and not the transition guide, which was written before. But it's probably still good to add a note there, too.
> in the [Changelog](https://python-telegram-bot.readthedocs.io/en/stable/changelog.html#version-12-4-0)

... and there it is, right at the top. My bad. Could have saved me some debugging.
But I guess my points still stand, somewhere in the rest of the documentation it should be mentioned in case someone like me comes along and doesn't see the changelog (or at some point more changes will definitely come and it's going to be hard finding that specific entry).
Thanks a lot!

Resolving patch:
diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py
--- a/telegram/ext/filters.py
+++ b/telegram/ext/filters.py
@@ -273,8 +273,11 @@ def filter(self, message):
             MessageHandler(Filters.text(buttons), callback_method)
 
     Note:
-        Dice messages don't have text. If you want to filter either text or dice messages, use
-        ``Filters.text | Filters.dice``.
+        * Dice messages don't have text. If you want to filter either text or dice messages, use
+          ``Filters.text | Filters.dice``.
+        * Messages containing a command are accepted by this filter. Use
+          ``Filters.text & (~Filters.command)``, if you want to filter only text messages without
+          commands.
 
     Args:
         update (List[:obj:`str`] | Tuple[:obj:`str`], optional): Which messages to allow. Only
@@ -350,6 +353,9 @@ def filter(self, message):
         MessageHandler(Filters.command, command_at_start_callback)
         MessageHandler(Filters.command(False), command_anywhere_callback)
 
+    Note:
+        ``Filters.text`` also accepts messages containing a command.
+
     Args:
         update (:obj:`bool`, optional): Whether to only allow messages that `start` with a bot
             command. Defaults to ``True``.
@@ -998,9 +1004,9 @@ def filter(self, message):
         update (:obj:`int` | List[:obj:`int`], optional): Which values to allow. If not
             specified, will allow any dice message.
 
-        Note:
-            Dice messages don't have text. If you want to filter either text or dice messages, use
-            ``Filters.text | Filters.dice``.
+    Note:
+        Dice messages don't have text. If you want to filter either text or dice messages, use
+        ``Filters.text | Filters.dice``.
     """
 
     class language(BaseFilter):


Test patch: