mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-26 16:38:53 +01:00
Fixes crash when username is not defined on chat
This commit is contained in:
parent
1bc58ad746
commit
59d55df99e
2 changed files with 4 additions and 4 deletions
|
@ -62,7 +62,7 @@ class Message(object):
|
||||||
from_user = None
|
from_user = None
|
||||||
|
|
||||||
if 'chat' in data:
|
if 'chat' in data:
|
||||||
if 'username' in data['chat'] or 'id' in data['chat']:
|
if 'first_name' in data['chat']:
|
||||||
from telegram import User
|
from telegram import User
|
||||||
chat = User.de_json(data['chat'])
|
chat = User.de_json(data['chat'])
|
||||||
if 'title' in data['chat']:
|
if 'title' in data['chat']:
|
||||||
|
|
|
@ -49,14 +49,14 @@ class BotTest(unittest.TestCase):
|
||||||
print 'Testing sendPhoto - File'
|
print 'Testing sendPhoto - File'
|
||||||
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
|
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
|
||||||
chat_id=12173560)
|
chat_id=12173560)
|
||||||
self.assertEqual(12948, message.photo[2].file_size)
|
self.assertEqual(1451, message.photo[0].file_size)
|
||||||
|
|
||||||
def testResendPhoto(self):
|
def testResendPhoto(self):
|
||||||
'''Test the telegram.Bot sendPhoto method'''
|
'''Test the telegram.Bot sendPhoto method'''
|
||||||
print 'Testing sendPhoto - Resend'
|
print 'Testing sendPhoto - Resend'
|
||||||
message = self._bot.sendPhoto(photo=str('AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI'),
|
message = self._bot.sendPhoto(photo=str('AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI'),
|
||||||
chat_id=12173560)
|
chat_id=12173560)
|
||||||
self.assertEqual(u'AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI', message.photo[2].file_id)
|
self.assertEqual(u'AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI', message.photo[0].file_id)
|
||||||
|
|
||||||
def testSendAudio(self):
|
def testSendAudio(self):
|
||||||
'''Test the telegram.Bot sendAudio method'''
|
'''Test the telegram.Bot sendAudio method'''
|
||||||
|
|
Loading…
Add table
Reference in a new issue