ConvesationHandler - check if a user exist before using it (#699)

Fixes #695
This commit is contained in:
Jelle Besseling 2017-07-23 21:29:52 +02:00 committed by Noam Meltzer
parent 08d298eb60
commit 8320227b2a
3 changed files with 8 additions and 1 deletions

View file

@ -32,6 +32,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Jacob Bom <https://github.com/bomjacob>`_
- `JASON0916 <https://github.com/JASON0916>`_
- `jeffffc <https://github.com/jeffffc>`_
- `Jelle Besseling <https://github.com/pingiun>`_
- `jh0ker <https://github.com/jh0ker>`_
- `John Yong <https://github.com/whipermr5>`_
- `jossalgon <https://github.com/jossalgon>`_

View file

@ -160,7 +160,7 @@ class ConversationHandler(Handler):
if self.per_chat:
key.append(chat.id)
if self.per_user:
if self.per_user and user is not None:
key.append(user.id)
if self.per_message:

View file

@ -330,6 +330,12 @@ class ConversationHandlerTest(BaseTest, unittest.TestCase):
update = Update(0, callback_query=cbq)
handler.check_update(update)
def test_channelMessageWithoutChat(self):
handler = ConversationHandler(entry_points=[CommandHandler('start', self.start_end)], states={}, fallbacks=[])
message = Message(0, None, None, Chat(0, Chat.CHANNEL, "Misses Test"))
update = Update(0, message=message)
handler.check_update(update)
if __name__ == '__main__':
unittest.main()