X Tutup
Skip to content

Commit 185a9e9

Browse files
committed
Fixes bug when to_data thumb for document and video
1 parent a1899a7 commit 185a9e9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

telegram/document.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ def de_json(data):
3232
file_size=data.get('file_size', None))
3333

3434
def to_dict(self):
35-
data = {'file_id': self.file_id,
36-
'thumb': self.thumb.to_dict()}
35+
data = {'file_id': self.file_id}
36+
if self.thumb:
37+
data['thumb'] = self.thumb.to_dict()
3738
if self.file_name:
3839
data['file_name'] = self.file_name
3940
if self.mime_type:

telegram/video.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def to_dict(self):
4444
data = {'file_id': self.file_id,
4545
'width': self.width,
4646
'height': self.height,
47-
'duration': self.duration,
48-
'thumb': self.thumb.to_dict()}
47+
'duration': self.duration}
48+
if self.thumb:
49+
data['thumb'] = self.thumb.to_dict()
4950
if self.mime_type:
5051
data['mime_type'] = self.mime_type
5152
if self.file_size:

0 commit comments

Comments
 (0)
X Tutup