Skip to content

improvement of constants: unify ChatLimit #3377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5284,7 +5284,7 @@ async def set_chat_description(
Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
description (:obj:`str`, optional): New chat description,
0-:tg-const:`telegram.constants.ChatDescriptionLimit.DESCRIPTION_LENGTH`
0-:tg-const:`telegram.constants.ChatLimit.CHAT_DESCRIPTION_LENGTH`
characters.

Returns:
Expand Down
26 changes: 7 additions & 19 deletions telegram/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"BotCommandScopeType",
"CallbackQueryLimit",
"ChatAction",
"ChatDescriptionLimit",
"ChatID",
"ChatInviteLinkLimit",
"ChatLimit",
Expand Down Expand Up @@ -233,22 +232,6 @@ class ChatAction(StringEnum):
""":obj:`str`: Chat action indicating that the bot is uploading a video note."""


class ChatDescriptionLimit(IntEnum):
"""This enum contains limitations for :meth:`telegram.Bot.set_chat_description`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
"""

__slots__ = ()

DESCRIPTION_LENGTH = 255
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_description.description` parameter of
:meth:`telegram.Bot.set_chat_description`.
"""


class ChatID(IntEnum):
"""This enum contains some special chat IDs. The enum
members of this enumeration are instances of :class:`int` and can be treated as such.
Expand Down Expand Up @@ -318,8 +301,8 @@ class ChatInviteLinkLimit(IntEnum):

class ChatLimit(IntEnum):
"""This enum contains limitations for
:meth:`telegram.Bot.set_chat_administrator_custom_title` and
:meth:`telegram.Bot.set_chat_title`.
:meth:`telegram.Bot.set_chat_administrator_custom_title`,
:meth:`telegram.Bot.set_chat_description`, and :meth:`telegram.Bot.set_chat_title`.
The enum members of this enumeration are instances of :class:`int` and can be treated as such.

.. versionadded:: 20.0
Expand All @@ -332,6 +315,11 @@ class ChatLimit(IntEnum):
:paramref:`~telegram.Bot.set_chat_administrator_custom_title.custom_title` parameter of
:meth:`telegram.Bot.set_chat_administrator_custom_title`.
"""
CHAT_DESCRIPTION_LENGTH = 255
""":obj:`int`: Maximum number of characters in a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_description.description` parameter of
:meth:`telegram.Bot.set_chat_description`.
"""
MIN_CHAT_TITLE_LENGTH = 1
""":obj:`int`: Minimum length of a :obj:`str` passed as the
:paramref:`~telegram.Bot.set_chat_title.title` parameter of
Expand Down