diff --git a/README.md b/README.md index 41ce353..41081da 100644 --- a/README.md +++ b/README.md @@ -683,6 +683,7 @@ Result will be: ## API conformance +* ✔ [Bot API 5.4](https://core.telegram.org/bots/api#november-5-2021) * ➕ [Bot API 5.3](https://core.telegram.org/bots/api#june-25-2021) - ChatMemberXXX classes are full copies of ChatMember * ✔ [Bot API 5.2](https://core.telegram.org/bots/api#april-26-2021) * ✔ [Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021) diff --git a/telebot/__init__.py b/telebot/__init__.py index 80b3818..cab3714 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -245,7 +245,6 @@ class TeleBot: Enable saving states (by default saving disabled) :param filename: Filename of saving file - """ self.current_states = StateFile(filename=filename) @@ -1690,8 +1689,10 @@ class TeleBot: :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) + :param name: Invite link name; 0-32 characters :param expire_date: Point in time (Unix timestamp) when the link will expire :param member_limit: Maximum number of users that can be members of the chat simultaneously + :param creates_join_request: True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified :return: """ return types.ChatInviteLink.de_json( @@ -1699,21 +1700,23 @@ class TeleBot: ) def edit_chat_invite_link( - self, chat_id: Union[int, str], name: Optional[str]=None, - invite_link: Optional[str] = None, - expire_date: Optional[Union[int, datetime]]=None, - member_limit: Optional[int]=None , + self, chat_id: Union[int, str], + invite_link: Optional[str] = None, + name: Optional[str]=None, + expire_date: Optional[Union[int, datetime]]=None, + member_limit: Optional[int]=None, creates_join_request: Optional[bool]=None) -> types.ChatInviteLink: """ Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. - :param invite_link: :param chat_id: Id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) + :param name: Invite link name; 0-32 characters :param invite_link: The invite link to edit :param expire_date: Point in time (Unix timestamp) when the link will expire :param member_limit: Maximum number of users that can be members of the chat simultaneously + :param creates_join_request: True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified :return: """ return types.ChatInviteLink.de_json( diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 37c7520..0ca982e 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -1016,7 +1016,7 @@ def edit_chat_invite_link(token, chat_id, invite_link, name, expire_date, member payload['member_limit'] = member_limit if name: payload['name'] = name - if creates_join_request: + if creates_join_request is not None: payload['creates_join_request'] = creates_join_request return _make_request(token, method_url, params=payload, method='post') @@ -1036,6 +1036,7 @@ def export_chat_invite_link(token, chat_id): payload = {'chat_id': chat_id} return _make_request(token, method_url, params=payload, method='post') + def approve_chat_join_request(token, chat_id, user_id): method_url = 'approveChatJoinRequest' payload = { @@ -1043,6 +1044,8 @@ def approve_chat_join_request(token, chat_id, user_id): 'user_id': user_id } return _make_request(token, method_url, params=payload, method='post') + + def decline_chat_join_request(token, chat_id, user_id): method_url = 'declineChatJoinRequest' payload = { @@ -1050,6 +1053,8 @@ def decline_chat_join_request(token, chat_id, user_id): 'user_id': user_id } return _make_request(token, method_url, params=payload, method='post') + + def set_chat_photo(token, chat_id, photo): method_url = 'setChatPhoto' payload = {'chat_id': chat_id} diff --git a/telebot/types.py b/telebot/types.py index fdf6467..263b327 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -175,16 +175,15 @@ class ChatJoinRequest(JsonDeserializable): obj = cls.check_json(json_string) obj['chat'] = Chat.de_json(obj['chat']) obj['from_user'] = User.de_json(obj['from']) - obj['invite_link'] = ChatInviteLink.de_json(obj['invite_link']) - + obj['invite_link'] = ChatInviteLink.de_json(obj.get('invite_link')) return cls(**obj) def __init__(self, chat, from_user, date, bio=None, invite_link=None, **kwargs): - self.chat = Chat = chat - self.from_user: User = from_user - self.date: int = date - self.bio: Optional[str] = bio - self.invite_link: Optional[ChatInviteLink] = invite_link + self.chat = chat + self.from_user = from_user + self.date = date + self.bio = bio + self.invite_link = invite_link class WebhookInfo(JsonDeserializable): @classmethod