From ee00d0458d5c118e121d09ac2bfe81d4c88fcba1 Mon Sep 17 00:00:00 2001 From: Anthony Byuraev Date: Mon, 11 May 2020 22:26:03 +0300 Subject: [PATCH] Fix some bugs --- telebot/types.py | 65 +++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/telebot/types.py b/telebot/types.py index fe62bc5..37ec7b8 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -183,7 +183,7 @@ class GroupChat(JsonDeserializable): class Chat(JsonDeserializable): @classmethod def de_json(cls, json_string): - if (json_string is None): + if json_string is None: return None obj = cls.check_json(json_string) id = obj['id'] @@ -197,26 +197,34 @@ class Chat(JsonDeserializable): description = obj.get('description') invite_link = obj.get('invite_link') pinned_message = Message.de_json(obj.get('pinned_message')) + permissions = ChatPermissions.de_json(obj.get('permissions')) slow_mode_delay = obj.get('slow_mode_delay') sticker_set_name = obj.get('sticker_set_name') can_set_sticker_set = obj.get('can_set_sticker_set') - return cls(id, type, title, username, first_name, last_name, all_members_are_administrators, - photo, description, invite_link, pinned_message, slow_mode_delay, sticker_set_name, can_set_sticker_set) + return cls( + id, type, title, username, first_name, last_name, + all_members_are_administrators, photo, description, invite_link, + pinned_message, permissions, slow_mode_delay, sticker_set_name, + can_set_sticker_set) - def __init__(self, id, type, title=None, username=None, first_name=None, last_name=None, - all_members_are_administrators=None, photo=None, description=None, invite_link=None, - pinned_message=None, sticker_set_name=None, can_set_sticker_set=None): - self.type = type - self.last_name = last_name - self.first_name = first_name - self.username = username + def __init__(self, id, type, title=None, username=None, first_name=None, + last_name=None, all_members_are_administrators=None, + photo=None, description=None, invite_link=None, + pinned_message=None, permissions=None, slow_mode_delay=None, + sticker_set_name=None, can_set_sticker_set=None): self.id = id + self.type = type self.title = title + self.username = username + self.first_name = first_name + self.last_name = last_name self.all_members_are_administrators = all_members_are_administrators self.photo = photo self.description = description self.invite_link = invite_link self.pinned_message = pinned_message + self.permissions = permissions + self.slow_mode_delay = slow_mode_delay self.sticker_set_name = sticker_set_name self.can_set_sticker_set = can_set_sticker_set @@ -1017,7 +1025,7 @@ class ChatPhoto(JsonDeserializable): class ChatMember(JsonDeserializable): @classmethod def de_json(cls, json_string): - if (json_string is None): + if json_string is None: return None obj = cls.check_json(json_string) user = User.de_json(obj['user']) @@ -1025,39 +1033,50 @@ class ChatMember(JsonDeserializable): custom_title = obj.get('custom_title') until_date = obj.get('until_date') can_be_edited = obj.get('can_be_edited') - can_change_info = obj.get('can_change_info') can_post_messages = obj.get('can_post_messages') can_edit_messages = obj.get('can_edit_messages') can_delete_messages = obj.get('can_delete_messages') - can_invite_users = obj.get('can_invite_users') can_restrict_members = obj.get('can_restrict_members') - can_pin_messages = obj.get('can_pin_messages') can_promote_members = obj.get('can_promote_members') + can_change_info = obj.get('can_change_info') + can_invite_users = obj.get('can_invite_users') + can_pin_messages = obj.get('can_pin_messages') + is_member = obj.get('is_member') can_send_messages = obj.get('can_send_messages') can_send_media_messages = obj.get('can_send_media_messages') + can_send_polls = obj.get('can_send_polls') can_send_other_messages = obj.get('can_send_other_messages') can_add_web_page_previews = obj.get('can_add_web_page_previews') - return cls(user, status, custom_title, until_date, can_be_edited, can_change_info, can_post_messages, can_edit_messages, - can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members, - can_send_messages, can_send_media_messages, can_send_other_messages, can_add_web_page_previews) + return cls( + user, status, custom_title, until_date, can_be_edited, can_post_messages, + can_edit_messages, can_delete_messages, can_restrict_members, + can_promote_members, can_change_info, can_invite_users, can_pin_messages, + is_member, can_send_messages, can_send_media_messages, can_send_polls, + can_send_other_messages, can_add_web_page_previews) - def __init__(self, user, status, until_date, can_be_edited, can_change_info, can_post_messages, can_edit_messages, - can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members, - can_send_messages, can_send_media_messages, can_send_other_messages, can_add_web_page_previews): + def __init__(self, user, status, custom_title=None, until_date=None, can_be_edited=None, + can_post_messages=None, can_edit_messages=None, can_delete_messages=None, + can_restrict_members=None, can_promote_members=None, can_change_info=None, + can_invite_users=None, can_pin_messages=None, is_member=None, + can_send_messages=None, can_send_media_messages=None, can_send_polls=None, + can_send_other_messages=None, can_add_web_page_previews=None): self.user = user self.status = status + self.custom_title = custom_title self.until_date = until_date self.can_be_edited = can_be_edited - self.can_change_info = can_change_info self.can_post_messages = can_post_messages self.can_edit_messages = can_edit_messages self.can_delete_messages = can_delete_messages - self.can_invite_users = can_invite_users self.can_restrict_members = can_restrict_members - self.can_pin_messages = can_pin_messages self.can_promote_members = can_promote_members + self.can_change_info = can_change_info + self.can_invite_users = can_invite_users + self.can_pin_messages = can_pin_messages + self.is_member = is_member self.can_send_messages = can_send_messages self.can_send_media_messages = can_send_media_messages + self.can_send_polls = can_send_polls self.can_send_other_messages = can_send_other_messages self.can_add_web_page_previews = can_add_web_page_previews