From 04df139efb27bcb322c07bbe5503674f9d763afe Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Sun, 22 May 2016 13:32:53 +0300 Subject: [PATCH 1/6] Added edit_date to Message object As of Bot API update 2.1, `Message` object now has optional `edit_date` field. --- telebot/types.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telebot/types.py b/telebot/types.py index adf37e191..82680b5f9 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -178,6 +178,8 @@ def de_json(cls, json_string): opts['forward_date'] = obj['forward_date'] if 'reply_to_message' in obj: opts['reply_to_message'] = Message.de_json(obj['reply_to_message']) + if 'edit_date' in obj: + opts['edit_date'] = Message.de_json(obj['edit_date']) if 'text' in obj: opts['text'] = obj['text'] content_type = 'text' @@ -269,6 +271,7 @@ def __init__(self, message_id, from_user, date, chat, content_type, options): self.forward_from = None self.forward_date = None self.reply_to_message = None + self.edit_date = None self.text = None self.entities = None self.audio = None From 6a98d27f1add4c411d51171d869864ccb9323d1e Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Sun, 22 May 2016 13:35:21 +0300 Subject: [PATCH 2/6] Added edited_message to Update object As of Bot API update 2.1, Update object now has optional edited_message field. --- telebot/types.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telebot/types.py b/telebot/types.py index adf37e191..ccf964a3d 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -91,6 +91,8 @@ def de_json(cls, json_type): callback_query = None if 'message' in obj: message = Message.de_json(obj['message']) + if 'edited_message' in obj: + edited_message = Message.de_json(obj['edited_message']) if 'inline_query' in obj: inline_query = InlineQuery.de_json(obj['inline_query']) if 'chosen_inline_result' in obj: @@ -99,9 +101,10 @@ def de_json(cls, json_type): callback_query = CallbackQuery.de_json(obj['callback_query']) return cls(update_id, message, inline_query, chosen_inline_result, callback_query) - def __init__(self, update_id, message, inline_query, chosen_inline_result, callback_query): + def __init__(self, update_id, message, edited_message, inline_query, chosen_inline_result, callback_query): self.update_id = update_id self.message = message + self.edited_message = edited_message self.inline_query = inline_query self.chosen_inline_result = chosen_inline_result self.callback_query = callback_query From 234dd8cf9f6fd5ceacee8b8b6fbad2f3507abf27 Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Sun, 22 May 2016 13:55:54 +0300 Subject: [PATCH 3/6] Edited edit_date field It's integer, not `Message` --- telebot/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/types.py b/telebot/types.py index 82680b5f9..db409b113 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -179,7 +179,7 @@ def de_json(cls, json_string): if 'reply_to_message' in obj: opts['reply_to_message'] = Message.de_json(obj['reply_to_message']) if 'edit_date' in obj: - opts['edit_date'] = Message.de_json(obj['edit_date']) + opts['edit_date'] = obj.get('edit_date') if 'text' in obj: opts['text'] = obj['text'] content_type = 'text' From 8a9d89591bb3d84912da0fd06081b10740a9a7f4 Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Sun, 22 May 2016 15:44:04 +0300 Subject: [PATCH 4/6] Fixed Travis build errors --- telebot/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/types.py b/telebot/types.py index ccf964a3d..195cd9a44 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -99,7 +99,7 @@ def de_json(cls, json_type): chosen_inline_result = ChosenInlineResult.de_json(obj['chosen_inline_result']) if 'callback_query' in obj: callback_query = CallbackQuery.de_json(obj['callback_query']) - return cls(update_id, message, inline_query, chosen_inline_result, callback_query) + return cls(update_id, message, edited_message, inline_query, chosen_inline_result, callback_query) def __init__(self, update_id, message, edited_message, inline_query, chosen_inline_result, callback_query): self.update_id = update_id From 1a45b4844add7ecf774ccff7bbee603b0ef75766 Mon Sep 17 00:00:00 2001 From: Kondra007 Date: Sun, 22 May 2016 15:47:44 +0300 Subject: [PATCH 5/6] Fixed Travis build (again) Yeah, I'm really sorry for all this errors, maybe tired a little bit. --- telebot/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/telebot/types.py b/telebot/types.py index 195cd9a44..a8f2d443b 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -86,6 +86,7 @@ def de_json(cls, json_type): obj = cls.check_json(json_type) update_id = obj['update_id'] message = None + edited_message = None inline_query = None chosen_inline_result = None callback_query = None From 8c20f6302294ccf0601e9f0f7ea1477fdd7f4003 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Mon, 23 May 2016 11:12:20 +0800 Subject: [PATCH 6/6] Add user to MessageEntity. --- telebot/types.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index d837cbdc6..d0b9b4eff 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -311,13 +311,17 @@ def de_json(cls, json_string): offset = obj['offset'] length = obj['length'] url = obj.get('url') - return cls(type, offset, length, url) + user = None + if 'user' in obj: + user = User.de_json(obj['user']) + return cls(type, offset, length, url, user) - def __init__(self, type, offset, length, url=None): + def __init__(self, type, offset, length, url=None, user=None): self.type = type self.offset = offset self.length = length self.url = url + self.user = user class PhotoSize(JsonDeserializable):