ConversationHandler breaks when bot is also used in Channels (#487)

* ConversationHandler now ignores channel posts
This commit is contained in:
Joscha Götzer 2016-12-25 21:36:01 +01:00 committed by Noam Meltzer
parent 7f6b017ce2
commit 6a01164897
2 changed files with 6 additions and 2 deletions

View file

@ -32,6 +32,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `overquota <https://github.com/overquota>`_ - `overquota <https://github.com/overquota>`_
- `Patrick Hofmann <https://github.com/PH89>`_ - `Patrick Hofmann <https://github.com/PH89>`_
- `Rahiel Kasim <https://github.com/rahiel>`_ - `Rahiel Kasim <https://github.com/rahiel>`_
- `Joscha Götzer <https://github.com/Rostgnom>`_
- `Shelomentsev D <https://github.com/shelomentsevd>`_ - `Shelomentsev D <https://github.com/shelomentsevd>`_
- `sooyhwang <https://github.com/sooyhwang>`_ - `sooyhwang <https://github.com/sooyhwang>`_
- `Valentijn <https://github.com/Faalentijn>`_ - `Valentijn <https://github.com/Faalentijn>`_

View file

@ -28,7 +28,9 @@ from telegram.utils.promise import Promise
class ConversationHandler(Handler): class ConversationHandler(Handler):
""" """
A handler to hold a conversation with a user by managing four collections of other handlers. A handler to hold a conversation with a single user by managing four collections of other
handlers. Note that neither posts in Telegram Channels, nor group interactions with multiple
users are managed by instances of this class.
The first collection, a ``list`` named ``entry_points``, is used to initiate the conversation, The first collection, a ``list`` named ``entry_points``, is used to initiate the conversation,
for example with a ``CommandHandler`` or ``RegexHandler``. for example with a ``CommandHandler`` or ``RegexHandler``.
@ -113,7 +115,8 @@ class ConversationHandler(Handler):
def check_update(self, update): def check_update(self, update):
if not isinstance(update, Update): # Ignore messages in channels
if not isinstance(update, Update) or update.channel_post:
return False return False
chat, user = extract_chat_and_user(update) chat, user = extract_chat_and_user(update)