From fa3ca84d2466a58fb243df0b4dc3bb69b62f865c Mon Sep 17 00:00:00 2001 From: Badiboy Date: Tue, 3 Nov 2020 17:46:19 +0300 Subject: [PATCH] Animation content_type "When you send gif telegram gives you animation and document at same time in update and when you parse that first if is animation and second is document because of this the content_type set document not animation" --- telebot/types.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index 1534da8..6dcf6c2 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -296,12 +296,13 @@ class Message(JsonDeserializable): if 'audio' in obj: opts['audio'] = Audio.de_json(obj['audio']) content_type = 'audio' - if 'animation' in obj: - opts['animation'] = Animation.de_json(obj['animation']) - content_type = 'animation' if 'document' in obj: opts['document'] = Document.de_json(obj['document']) content_type = 'document' + if 'animation' in obj: + # Document content type accompanies "animation", so "animation" should be checked below "document" to override it + opts['animation'] = Animation.de_json(obj['animation']) + content_type = 'animation' if 'game' in obj: opts['game'] = Game.de_json(obj['game']) content_type = 'game'