icon_custom_emoji_id and name parameters made optional for edit_forum_topic

The parameters name and icon_custom_emoji_id of the method editForumTopic are now optional. If they are omitted, the existing values are kept.
This commit is contained in:
coder2020official 2022-12-30 19:50:14 +04:00
parent 9f5d9861a4
commit 107f92314b
4 changed files with 26 additions and 12 deletions

View File

@ -4648,8 +4648,8 @@ class TeleBot:
def edit_forum_topic(
self, chat_id: Union[int, str],
message_thread_id: int, name: str,
icon_custom_emoji_id: str,
message_thread_id: int, name: Optional[str]=None,
icon_custom_emoji_id: Optional[str]=None
) -> bool:
"""
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an
@ -4664,10 +4664,13 @@ class TeleBot:
:param message_thread_id: Identifier of the topic to edit
:type message_thread_id: :obj:`int`
:param name: New name of the topic, 1-128 characters
:param name: Optional, New name of the topic, 1-128 characters. If not specififed or empty,
the current name of the topic will be kept
:type name: :obj:`str`
:param icon_custom_emoji_id: New custom emoji for the topic icon. Must be an emoji of type tgs and must be exactly 1 character long
:param icon_custom_emoji_id: Optional, New unique identifier of the custom emoji shown as the topic icon.
Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the
icon. If not specified, the current icon will be kept
:type icon_custom_emoji_id: :obj:`str`
:return: On success, True is returned.

View File

@ -1773,9 +1773,13 @@ def create_forum_topic(token, chat_id, name, icon_color=None, icon_custom_emoji_
payload['icon_custom_emoji_id'] = icon_custom_emoji_id
return _make_request(token, method_url, params=payload)
def edit_forum_topic(token, chat_id, message_thread_id, name, icon_custom_emoji_id):
def edit_forum_topic(token, chat_id, message_thread_id, name=None, icon_custom_emoji_id=None):
method_url = r'editForumTopic'
payload = {'chat_id': chat_id, 'message_thread_id': message_thread_id, 'name': name, 'icon_custom_emoji_id': icon_custom_emoji_id}
payload = {'chat_id': chat_id, 'message_thread_id': message_thread_id}
if name is not None:
payload['name'] = name
if icon_custom_emoji_id is not None:
payload['icon_custom_emoji_id'] = icon_custom_emoji_id
return _make_request(token, method_url, params=payload)
def close_forum_topic(token, chat_id, message_thread_id):

View File

@ -5514,8 +5514,8 @@ class AsyncTeleBot:
async def edit_forum_topic(
self, chat_id: Union[int, str],
message_thread_id: int, name: str,
icon_custom_emoji_id: str,
message_thread_id: int, name: Optional[str]=None,
icon_custom_emoji_id: Optional[str]=None
) -> bool:
"""
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an
@ -5530,10 +5530,13 @@ class AsyncTeleBot:
:param message_thread_id: Identifier of the topic to edit
:type message_thread_id: :obj:`int`
:param name: New name of the topic, 1-128 characters
:param name: Optional, New name of the topic, 1-128 characters. If not specififed or empty,
the current name of the topic will be kept
:type name: :obj:`str`
:param icon_custom_emoji_id: New custom emoji for the topic icon. Must be an emoji of type tgs and must be exactly 1 character long
:param icon_custom_emoji_id: Optional, New unique identifier of the custom emoji shown as the topic icon.
Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the
icon. If not specified, the current icon will be kept
:type icon_custom_emoji_id: :obj:`str`
:return: On success, True is returned.

View File

@ -1764,9 +1764,13 @@ async def create_forum_topic(token, chat_id, name, icon_color=None, icon_custom_
payload['icon_custom_emoji_id'] = icon_custom_emoji_id
return await _process_request(token, method_url, params=payload)
async def edit_forum_topic(token, chat_id, message_thread_id, name, icon_custom_emoji_id):
async def edit_forum_topic(token, chat_id, message_thread_id, name=None, icon_custom_emoji_id=None):
method_url = r'editForumTopic'
payload = {'chat_id': chat_id, 'message_thread_id': message_thread_id, 'name': name, 'icon_custom_emoji_id': icon_custom_emoji_id}
payload = {'chat_id': chat_id, 'message_thread_id': message_thread_id}
if name is not None:
payload['name'] = name
if icon_custom_emoji_id is not None:
payload['icon_custom_emoji_id'] = icon_custom_emoji_id
return await _process_request(token, method_url, params=payload)
async def close_forum_topic(token, chat_id, message_thread_id):