Skip to content

Feat: Docstring changes + moving limit to constants #3343

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 3 commits into from
Nov 9, 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
5 changes: 4 additions & 1 deletion telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ async def delete_message(
limitations:

- A message can only be deleted if it was sent less than 48 hours ago.
- Service messages about a supergroup, channel, or forum topic creation can't be deleted.
- A dice message in a private chat can only be deleted if it was sent more than 24
hours ago.
- Bots can delete outgoing messages in private chats, groups, and supergroups.
Expand Down Expand Up @@ -6171,7 +6172,9 @@ async def set_chat_title(
Args:
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
of the target channel (in the format ``@channelusername``).
title (:obj:`str`): New chat title, 1-255 characters.
title (:obj:`str`): New chat title,
tg-const:`telegram.constants.ChatLimits.MIN_TITLE_LENGTH`-
tg-const:`telegram.constants.ChatLimits.MAX_TITLE_LENGTH` characters.

Keyword Args:
read_timeout (:obj:`float` | :obj:`None`, optional): Value to pass to
Expand Down
2 changes: 1 addition & 1 deletion telegram/_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class Chat(TelegramObject):
"has_restricted_voice_and_video_messages",
"is_forum",
"active_usernames",
"emoji_status_custom_emoji_id"
"emoji_status_custom_emoji_id",
)

SENDER: ClassVar[str] = constants.ChatType.SENDER
Expand Down
16 changes: 16 additions & 0 deletions telegram/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"ChatAction",
"ChatID",
"ChatInviteLinkLimit",
"ChatLimit",
"ChatMemberStatus",
"ChatType",
"CustomEmojiStickerLimit",
Expand Down Expand Up @@ -901,3 +902,18 @@ class WebhookLimit(IntEnum):
""":obj:`int`: Minimum length of the secret token."""
MAX_SECRET_TOKEN_LENGTH = 256
""":obj:`int`: Maximum length of the secret token."""


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

.. versionadded:: 20.0
"""

__slots__ = ()

MIN_TITLE_LENGTH = 1
""":obj:`int`: Minimum length of a new chat title."""
MAX_TITLE_LENGTH = 128
""":obj:`int`: Maximum length of a new chat title."""
2 changes: 1 addition & 1 deletion tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_de_json(self, bot):
),
"is_forum": self.is_forum,
"active_usernames": self.active_usernames,
"emoji_status_custom_emoji_id": self.emoji_status_custom_emoji_id
"emoji_status_custom_emoji_id": self.emoji_status_custom_emoji_id,
}
chat = Chat.de_json(json_dict, bot)

Expand Down