Skip to content

Commit 59d55df

Browse files
committed
Fixes crash when username is not defined on chat
1 parent 1bc58ad commit 59d55df

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

telegram/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def de_json(data):
6262
from_user = None
6363

6464
if 'chat' in data:
65-
if 'username' in data['chat'] or 'id' in data['chat']:
65+
if 'first_name' in data['chat']:
6666
from telegram import User
6767
chat = User.de_json(data['chat'])
6868
if 'title' in data['chat']:

tests/test_bot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ def testSendPhoto(self):
4949
print 'Testing sendPhoto - File'
5050
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
5151
chat_id=12173560)
52-
self.assertEqual(12948, message.photo[2].file_size)
52+
self.assertEqual(1451, message.photo[0].file_size)
5353

5454
def testResendPhoto(self):
5555
'''Test the telegram.Bot sendPhoto method'''
5656
print 'Testing sendPhoto - Resend'
57-
message = self._bot.sendPhoto(photo=str('AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI'),
57+
message = self._bot.sendPhoto(photo=str('AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI'),
5858
chat_id=12173560)
59-
self.assertEqual(u'AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI', message.photo[2].file_id)
59+
self.assertEqual(u'AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI', message.photo[0].file_id)
6060

6161
def testSendAudio(self):
6262
'''Test the telegram.Bot sendAudio method'''

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy