From be3b6f88e8f729bf68a3577cbd937a138c835b0f Mon Sep 17 00:00:00 2001 From: Taha Date: Sun, 14 Jul 2019 18:53:59 +0430 Subject: [PATCH 1/3] Added Animation --- telebot/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telebot/types.py b/telebot/types.py index 4d6a041..774b526 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -296,6 +296,9 @@ class Message(JsonDeserializable): if 'photo' in obj: opts['photo'] = Message.parse_photo(obj['photo']) content_type = 'photo' + if 'animation' in obj: + opts['animation'] = Animation.de_json(obj['animation']) + content_type = 'animation' if 'sticker' in obj: opts['sticker'] = Sticker.de_json(obj['sticker']) content_type = 'sticker' @@ -421,6 +424,7 @@ class Message(JsonDeserializable): self.contact = None self.location = None self.venue = None + self.animation = None self.new_chat_member = None self.new_chat_members = None self.left_chat_member = None @@ -2056,7 +2060,6 @@ class Sticker(JsonDeserializable): self.mask_position = mask_position self.file_size = file_size - class MaskPosition(JsonDeserializable, JsonSerializable): @classmethod def de_json(cls, json_string): From f0835a1a14f2d30395b2f1795301d715556c5698 Mon Sep 17 00:00:00 2001 From: cmd410 Date: Tue, 30 Jul 2019 12:46:39 +0300 Subject: [PATCH 2/3] Support for animated stickers --- telebot/types.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index 4d6a041..825ab3f 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -2035,6 +2035,7 @@ class Sticker(JsonDeserializable): file_id = obj['file_id'] width = obj['width'] height = obj['height'] + is_animated = obj['is_animated'] thumb = None if 'thumb' in obj: thumb = PhotoSize.de_json(obj['thumb']) @@ -2044,9 +2045,9 @@ class Sticker(JsonDeserializable): if 'mask_position' in obj: mask_position = MaskPosition.de_json(obj['mask_position']) file_size = obj.get('file_size') - return cls(file_id, width, height, thumb, emoji, set_name, mask_position, file_size) + return cls(file_id, width, height, thumb, emoji, set_name, mask_position, file_size, is_animated) - def __init__(self, file_id, width, height, thumb, emoji, set_name, mask_position, file_size): + def __init__(self, file_id, width, height, thumb, emoji, set_name, mask_position, file_size, is_animated): self.file_id = file_id self.width = width self.height = height @@ -2055,6 +2056,7 @@ class Sticker(JsonDeserializable): self.set_name = set_name self.mask_position = mask_position self.file_size = file_size + self.is_animated = is_animated class MaskPosition(JsonDeserializable, JsonSerializable): From 0603a0df4ca1261dbcac840fa823198f6bd76d10 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Fri, 3 Jan 2020 17:51:05 +0300 Subject: [PATCH 3/3] Update types.py Animation is moved before document to save backward compatibility. content_type = 'document' should override content_type = 'animation' to save previous behaviour. --- telebot/types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index aa54e06..dac9d79 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -287,6 +287,9 @@ 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' @@ -296,9 +299,6 @@ class Message(JsonDeserializable): if 'photo' in obj: opts['photo'] = Message.parse_photo(obj['photo']) content_type = 'photo' - if 'animation' in obj: - opts['animation'] = Animation.de_json(obj['animation']) - content_type = 'animation' if 'sticker' in obj: opts['sticker'] = Sticker.de_json(obj['sticker']) content_type = 'sticker'