diff --git a/telegram/document.py b/telegram/document.py index 14cc1efdb..364a3f983 100644 --- a/telegram/document.py +++ b/telegram/document.py @@ -32,8 +32,9 @@ class Document(TelegramObject): file_size=data.get('file_size', None)) def to_dict(self): - data = {'file_id': self.file_id, - 'thumb': self.thumb.to_dict()} + data = {'file_id': self.file_id} + if self.thumb: + data['thumb'] = self.thumb.to_dict() if self.file_name: data['file_name'] = self.file_name if self.mime_type: diff --git a/telegram/video.py b/telegram/video.py index e4690631c..b21c400a2 100644 --- a/telegram/video.py +++ b/telegram/video.py @@ -44,8 +44,9 @@ class Video(TelegramObject): data = {'file_id': self.file_id, 'width': self.width, 'height': self.height, - 'duration': self.duration, - 'thumb': self.thumb.to_dict()} + 'duration': self.duration} + if self.thumb: + data['thumb'] = self.thumb.to_dict() if self.mime_type: data['mime_type'] = self.mime_type if self.file_size: