diff --git a/telebot/__init__.py b/telebot/__init__.py index 95ec936..fa0c11b 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -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. diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 4f56705..f1fdb7c 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -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 = '' diff --git a/telebot/async_telebot.py b/telebot/async_telebot.py index 65accb8..0ee8f06 100644 --- a/telebot/async_telebot.py +++ b/telebot/async_telebot.py @@ -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. diff --git a/telebot/asyncio_helper.py b/telebot/asyncio_helper.py index 8bbdc3d..86468d0 100644 --- a/telebot/asyncio_helper.py +++ b/telebot/asyncio_helper.py @@ -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: