mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Added methods for topic management
Added the methods editGeneralForumTopic, closeGeneralForumTopic, reopenGeneralForumTopic, hideGeneralForumTopic, unhideGeneralForumTopic for managing the General topic in forums.
This commit is contained in:
parent
a20a3ae321
commit
f297ad23c7
@ -4754,6 +4754,75 @@ class TeleBot:
|
||||
"""
|
||||
return apihelper.unpin_all_forum_topic_messages(self.token, chat_id, message_thread_id)
|
||||
|
||||
def edit_general_forum_topic(self, chat_id: Union[int, str], name: str) -> bool:
|
||||
"""
|
||||
Use this method to edit the name of the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
|
||||
:param name: New topic name, 1-128 characters
|
||||
:type name: :obj:`str`
|
||||
"""
|
||||
|
||||
return apihelper.edit_general_forum_topic(self.token, chat_id, name)
|
||||
|
||||
def close_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to close the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#closegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return apihelper.close_general_forum_topic(self.token, chat_id)
|
||||
|
||||
def reopen_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to reopen the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#reopengeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return apihelper.reopen_general_forum_topic(self.token, chat_id)
|
||||
|
||||
def hide_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to hide the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#hidegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return apihelper.hide_general_forum_topic(self.token, chat_id)
|
||||
|
||||
def unhide_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to unhide the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return apihelper.unhide_general_forum_topic(self.token, chat_id)
|
||||
|
||||
def get_forum_topic_icon_stickers(self) -> List[types.Sticker]:
|
||||
"""
|
||||
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
|
||||
|
@ -1813,6 +1813,31 @@ def stop_poll(token, chat_id, message_id, reply_markup=None):
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
def edit_general_forum_topic(token, chat_id, name):
|
||||
method_url = r'editGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id, 'name': name}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
def close_general_forum_topic(token, chat_id):
|
||||
method_url = r'closeGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
def reopen_general_forum_topic(token, chat_id):
|
||||
method_url = r'reopenGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
def hide_general_forum_topic(token, chat_id):
|
||||
method_url = r'hideGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
def unhide_general_forum_topic(token, chat_id):
|
||||
method_url = r'unhideGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
def _convert_list_json_serializable(results):
|
||||
ret = ''
|
||||
|
@ -5620,6 +5620,75 @@ class AsyncTeleBot:
|
||||
"""
|
||||
return await asyncio_helper.unpin_all_forum_topic_messages(self.token, chat_id, message_thread_id)
|
||||
|
||||
async def edit_general_forum_topic(self, chat_id: Union[int, str], name: str) -> bool:
|
||||
"""
|
||||
Use this method to edit the name of the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#editgeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
|
||||
:param name: New topic name, 1-128 characters
|
||||
:type name: :obj:`str`
|
||||
"""
|
||||
|
||||
return await asyncio_helper.edit_general_forum_topic(self.token, chat_id, name)
|
||||
|
||||
async def close_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to close the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#closegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return await asyncio_helper.close_general_forum_topic(self.token, chat_id)
|
||||
|
||||
async def reopen_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to reopen the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#reopengeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return await asyncio_helper.reopen_general_forum_topic(self.token, chat_id)
|
||||
|
||||
async def hide_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to hide the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#hidegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return await asyncio_helper.hide_general_forum_topic(self.token, chat_id)
|
||||
|
||||
async def unhide_general_forum_topic(self, chat_id: Union[int, str]) -> bool:
|
||||
"""
|
||||
Use this method to unhide the 'General' topic in a forum supergroup chat.
|
||||
The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights.
|
||||
Returns True on success.
|
||||
|
||||
Telegram documentation: https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
:type chat_id: :obj:`int` or :obj:`str`
|
||||
"""
|
||||
return await asyncio_helper.unhide_general_forum_topic(self.token, chat_id)
|
||||
|
||||
async def get_forum_topic_icon_stickers(self) -> List[types.Sticker]:
|
||||
"""
|
||||
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user.
|
||||
|
@ -1797,6 +1797,31 @@ async def get_forum_topic_icon_stickers(token):
|
||||
method_url = r'getForumTopicIconStickers'
|
||||
return await _process_request(token, method_url)
|
||||
|
||||
async def edit_general_forum_topic(token, chat_id, name):
|
||||
method_url = r'editGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id, 'name': name}
|
||||
return await _process_request(token, method_url, params=payload)
|
||||
|
||||
async def close_general_forum_topic(token, chat_id):
|
||||
method_url = r'closeGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return await _process_request(token, method_url, params=payload)
|
||||
|
||||
async def reopen_general_forum_topic(token, chat_id):
|
||||
method_url = r'reopenGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return await _process_request(token, method_url, params=payload)
|
||||
|
||||
async def hide_general_forum_topic(token, chat_id):
|
||||
method_url = r'hideGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return await _process_request(token, method_url, params=payload)
|
||||
|
||||
async def unhide_general_forum_topic(token, chat_id):
|
||||
method_url = r'unhideGeneralForumTopic'
|
||||
payload = {'chat_id': chat_id}
|
||||
return await _process_request(token, method_url, params=payload)
|
||||
|
||||
async def _convert_list_json_serializable(results):
|
||||
ret = ''
|
||||
for r in results:
|
||||
|
Loading…
Reference in New Issue
Block a user