X Tutup
Skip to content

Commit 8320227

Browse files
pingiuntsnoam
authored andcommitted
ConvesationHandler - check if a user exist before using it (python-telegram-bot#699)
Fixes python-telegram-bot#695
1 parent 08d298e commit 8320227

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ The following wonderful people contributed directly or indirectly to this projec
3232
- `Jacob Bom <https://github.com/bomjacob>`_
3333
- `JASON0916 <https://github.com/JASON0916>`_
3434
- `jeffffc <https://github.com/jeffffc>`_
35+
- `Jelle Besseling <https://github.com/pingiun>`_
3536
- `jh0ker <https://github.com/jh0ker>`_
3637
- `John Yong <https://github.com/whipermr5>`_
3738
- `jossalgon <https://github.com/jossalgon>`_

telegram/ext/conversationhandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def _get_key(self, update):
160160
if self.per_chat:
161161
key.append(chat.id)
162162

163-
if self.per_user:
163+
if self.per_user and user is not None:
164164
key.append(user.id)
165165

166166
if self.per_message:

tests/test_conversationhandler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ def test_perChatMessageWithoutChat(self):
330330
update = Update(0, callback_query=cbq)
331331
handler.check_update(update)
332332

333+
def test_channelMessageWithoutChat(self):
334+
handler = ConversationHandler(entry_points=[CommandHandler('start', self.start_end)], states={}, fallbacks=[])
335+
message = Message(0, None, None, Chat(0, Chat.CHANNEL, "Misses Test"))
336+
update = Update(0, message=message)
337+
handler.check_update(update)
338+
333339

334340
if __name__ == '__main__':
335341
unittest.main()

0 commit comments

Comments
 (0)
X Tutup