From 7958d0dca74894234066d1afc3cb7424883422de Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sun, 6 Nov 2022 15:04:41 +0400 Subject: [PATCH] Added can_manage_topics for promotechatmember Added the parameter can_manage_topics to the method promoteChatMember. --- telebot/__init__.py | 9 +++++++-- telebot/apihelper.py | 5 ++++- telebot/async_telebot.py | 9 +++++++-- telebot/asyncio_helper.py | 4 +++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 46e086c..e28f563 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -2910,7 +2910,8 @@ class TeleBot: is_anonymous: Optional[bool]=None, can_manage_chat: Optional[bool]=None, can_manage_video_chats: Optional[bool]=None, - can_manage_voice_chats: Optional[bool]=None) -> bool: + can_manage_voice_chats: Optional[bool]=None, + can_manage_topics: Optional[bool]=None) -> bool: """ Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. @@ -2967,6 +2968,10 @@ class TeleBot: :param can_manage_voice_chats: Deprecated, use can_manage_video_chats. :type can_manage_voice_chats: :obj:`bool` + :param can_manage_topics: Pass True if the user is allowed to create, rename, close, + and reopen forum topics, supergroups only + :type can_manage_topics: :obj:`bool` + :return: True on success. :rtype: :obj:`bool` """ @@ -2979,7 +2984,7 @@ class TeleBot: self.token, chat_id, user_id, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members, - is_anonymous, can_manage_chat, can_manage_video_chats) + is_anonymous, can_manage_chat, can_manage_video_chats, can_manage_topics) def set_chat_administrator_custom_title( self, chat_id: Union[int, str], user_id: int, custom_title: str) -> bool: diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 5f8d62e..b5009de 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -977,7 +977,8 @@ def promote_chat_member( token, chat_id, user_id, can_change_info=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_invite_users=None, can_restrict_members=None, can_pin_messages=None, can_promote_members=None, - is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None): + is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None, + can_manage_topics=None): method_url = 'promoteChatMember' payload = {'chat_id': chat_id, 'user_id': user_id} if can_change_info is not None: @@ -1002,6 +1003,8 @@ def promote_chat_member( payload['can_manage_chat'] = can_manage_chat if can_manage_video_chats is not None: payload['can_manage_video_chats'] = can_manage_video_chats + if can_manage_topics is not None: + payload['can_manage_topics'] = can_manage_topics return _make_request(token, method_url, params=payload, method='post') diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 3a9e142..40e3a88 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -3750,7 +3750,8 @@ class AsyncTeleBot: is_anonymous: Optional[bool]=None, can_manage_chat: Optional[bool]=None, can_manage_video_chats: Optional[bool]=None, - can_manage_voice_chats: Optional[bool]=None) -> bool: + can_manage_voice_chats: Optional[bool]=None, + can_manage_topics: Optional[bool]=None) -> bool: """ Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. @@ -3807,6 +3808,10 @@ class AsyncTeleBot: :param can_manage_voice_chats: Deprecated, use can_manage_video_chats. :type can_manage_voice_chats: :obj:`bool` + :param can_manage_topics: Pass True if the user is allowed to create, rename, close, + and reopen forum topics, supergroups only + :type can_manage_topics: :obj:`bool` + :return: True on success. :rtype: :obj:`bool` """ @@ -3820,7 +3825,7 @@ class AsyncTeleBot: self.token, chat_id, user_id, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users, can_restrict_members, can_pin_messages, can_promote_members, - is_anonymous, can_manage_chat, can_manage_video_chats) + is_anonymous, can_manage_chat, can_manage_video_chats, can_manage_topics) async def set_chat_administrator_custom_title( self, chat_id: Union[int, str], user_id: int, custom_title: str) -> bool: diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 7e8958a..3389b33 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -968,7 +968,7 @@ async def promote_chat_member( token, chat_id, user_id, can_change_info=None, can_post_messages=None, can_edit_messages=None, can_delete_messages=None, can_invite_users=None, can_restrict_members=None, can_pin_messages=None, can_promote_members=None, - is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None): + is_anonymous=None, can_manage_chat=None, can_manage_video_chats=None, can_manage_topics=None): method_url = 'promoteChatMember' payload = {'chat_id': chat_id, 'user_id': user_id} if can_change_info is not None: @@ -993,6 +993,8 @@ async def promote_chat_member( payload['can_manage_chat'] = can_manage_chat if can_manage_video_chats is not None: payload['can_manage_video_chats'] = can_manage_video_chats + if can_manage_topics is not None: + payload['can_manage_topics'] = can_manage_topics return await _process_request(token, method_url, params=payload, method='post')