Skip to content

Commit b745088

Browse files
committed
Let thumb option in Sticker. Api chamged.
1 parent 8abd3fe commit b745088

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎telebot/types.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ def de_json(cls, json_string):
265265
file_id = obj['file_id']
266266
width = obj['width']
267267
height = obj['height']
268-
thumb = PhotoSize.de_json(obj['thumb'])
268+
thumb = None
269+
if 'thumb' in obj:
270+
thumb = PhotoSize.de_json(obj['thumb'])
269271
file_size = None
270272
if 'file_size' in obj:
271273
file_size = obj['file_size']

‎tests/test_types.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def test_json_Message_Sticker():
5252
assert msg.sticker.thumb.height == 60
5353
assert msg.content_type == 'sticker'
5454

55+
def test_json_Message_Sticker_without_thumb():
56+
json_string = r'{"message_id":98,"from":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd"},"chat":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd"},"date":1435479551,"sticker":{"width":550,"height":368,"file_id":"BQADBQADNAIAAsYifgYdGJOa6bGAsQI","file_size":30320}}'
57+
msg = types.Message.de_json(json_string)
58+
assert msg.sticker.height == 368
59+
assert msg.sticker.thumb == None
60+
assert msg.content_type == 'sticker'
5561

5662
def test_json_Message_Document():
5763
json_string = r'{"message_id":97,"from":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd"},"chat":{"id":10,"first_name":"Fd","last_name":"Wd","username":"dd"},"date":1435478744,"document":{"file_name":"Text File","thumb":{},"file_id":"BQADBQADMwIAAsYifgZ_CEh0u682xwI","file_size":446}}'
@@ -95,3 +101,4 @@ def test_json_contact():
95101
contact = types.Contact.de_json(json_string)
96102
assert contact.first_name == 'dd'
97103
assert contact.last_name == 'ddl'
104+

0 commit comments

Comments
 (0)