diff --git a/.butcher/enums/BotCommandScopeType.yml b/.butcher/enums/BotCommandScopeType.yml new file mode 100644 index 00000000..8d2f50bd --- /dev/null +++ b/.butcher/enums/BotCommandScopeType.yml @@ -0,0 +1,16 @@ +name: BotCommandScopeType +description: | + This object represents the scope to which bot commands are applied. + + Source: https://core.telegram.org/bots/api#botcommandscope +multi_parse: + attribute: type + regexp: "must be ([a-z_]+)" + entities: + - BotCommandScopeDefault + - BotCommandScopeAllPrivateChats + - BotCommandScopeAllGroupChats + - BotCommandScopeAllChatAdministrators + - BotCommandScopeChat + - BotCommandScopeChatAdministrators + - BotCommandScopeChatMember diff --git a/.butcher/enums/ChatActions.yml b/.butcher/enums/ChatActions.yml new file mode 100644 index 00000000..49710dc3 --- /dev/null +++ b/.butcher/enums/ChatActions.yml @@ -0,0 +1,22 @@ +name: ChatAction +description: | + This object represents bot actions. + + Choose one, depending on what the user is about to receive: + + - typing for text messages, + - upload_photo for photos, + - record_video or upload_video for videos, + - record_voice or upload_voice for voice notes, + - upload_document for general files, + - choose_sticker for stickers, + - find_location for location data, + - record_video_note or upload_video_note for video notes. + + Source: https://core.telegram.org/bots/api#sendchataction +parse: + format: rst + entity: sendChatAction + category: methods + attribute: action + regexp: '\*([a-z_]+)\*' diff --git a/.butcher/enums/ChatMemberStatus.yml b/.butcher/enums/ChatMemberStatus.yml new file mode 100644 index 00000000..037e8717 --- /dev/null +++ b/.butcher/enums/ChatMemberStatus.yml @@ -0,0 +1,15 @@ +name: ChatMemberStatus +description: | + This object represents chat member status. + + Source: https://core.telegram.org/bots/api#chatmember +multi_parse: + attribute: status + regexp: "'([a-z_]+)'" + entities: + - ChatMemberOwner + - ChatMemberAdministrator + - ChatMemberMember + - ChatMemberRestricted + - ChatMemberLeft + - ChatMemberBanned diff --git a/.butcher/enums/ChatType.yml b/.butcher/enums/ChatType.yml new file mode 100644 index 00000000..34a4f7aa --- /dev/null +++ b/.butcher/enums/ChatType.yml @@ -0,0 +1,9 @@ +name: ChatType +description: | + This object represents a chat type + + Source: https://core.telegram.org/bots/api#chat +parse: + entity: Chat + attribute: type + regexp: "'([a-z]+)'" diff --git a/.butcher/enums/content_type.yml b/.butcher/enums/ContentType.yml similarity index 89% rename from .butcher/enums/content_type.yml rename to .butcher/enums/ContentType.yml index 7ee024d8..654c89ac 100644 --- a/.butcher/enums/content_type.yml +++ b/.butcher/enums/ContentType.yml @@ -1,5 +1,6 @@ name: ContentType -description: "Message content type" +description: + This object represents a type of content in message static: UNKNOWN: unknown ANY: any diff --git a/.butcher/enums/dice.yml b/.butcher/enums/DiceEmoji.yml similarity index 51% rename from .butcher/enums/dice.yml rename to .butcher/enums/DiceEmoji.yml index 593cdad1..bf7576dc 100644 --- a/.butcher/enums/dice.yml +++ b/.butcher/enums/DiceEmoji.yml @@ -1,5 +1,8 @@ name: DiceEmoji -description: "Emoji on which the dice throw animation is based" +description: | + Emoji on which the dice throw animation is based + + Source: https://core.telegram.org/bots/api#dice static: DICE: 🎲 DART: 🎯 diff --git a/.butcher/enums/MenuButtonType.yml b/.butcher/enums/MenuButtonType.yml new file mode 100644 index 00000000..a539d058 --- /dev/null +++ b/.butcher/enums/MenuButtonType.yml @@ -0,0 +1,13 @@ +name: MenuButtonType +description: | + This object represents an type of Menu button + + Source: https://core.telegram.org/bots/api#menubuttondefault +multi_parse: + format: rst + attribute: type + regexp: '\*([a-z_]+)\*' + entities: + - MenuButtonDefault + - MenuButtonCommands + - MenuButtonWebApp diff --git a/.butcher/enums/MessageEntityType.yml b/.butcher/enums/MessageEntityType.yml new file mode 100644 index 00000000..95719bc9 --- /dev/null +++ b/.butcher/enums/MessageEntityType.yml @@ -0,0 +1,10 @@ +name: MessageEntityType +description: | + This object represents type of message entity + + Source: https://core.telegram.org/bots/api#messageentity +parse: + entity: MessageEntity + category: types + attribute: type + regexp: "'([a-z_]+)'" diff --git a/.butcher/enums/ParseMode.yml b/.butcher/enums/ParseMode.yml new file mode 100644 index 00000000..5ccb98b8 --- /dev/null +++ b/.butcher/enums/ParseMode.yml @@ -0,0 +1,9 @@ +name: ParseMode +description: | + Formatting options + + Source: https://core.telegram.org/bots/api#formatting-options +static: + MARKDOWN_V2: MarkdownV2 + MARKDOWN: Markdown + HTML: HTML diff --git a/.butcher/enums/PollType.yml b/.butcher/enums/PollType.yml new file mode 100644 index 00000000..02bf95de --- /dev/null +++ b/.butcher/enums/PollType.yml @@ -0,0 +1,9 @@ +name: PollType +description: | + This object represents poll type + + Source: https://core.telegram.org/bots/api#poll +parse: + entity: Poll + attribute: type + regexp: "'([a-z]+)'" diff --git a/.butcher/enums/topic_icon_color.yml b/.butcher/enums/TopicIconColor.yml similarity index 100% rename from .butcher/enums/topic_icon_color.yml rename to .butcher/enums/TopicIconColor.yml diff --git a/.butcher/enums/UpdateType.yml b/.butcher/enums/UpdateType.yml new file mode 100644 index 00000000..ad18ef2f --- /dev/null +++ b/.butcher/enums/UpdateType.yml @@ -0,0 +1,9 @@ +name: UpdateType +description: | + This object represents the complete list of allowed update types + + Source: https://core.telegram.org/bots/api#update +extract: + entity: Update + exclude: + - update_id diff --git a/.butcher/enums/chat_type.yml b/.butcher/enums/chat_type.yml deleted file mode 100644 index 2d43fc1e..00000000 --- a/.butcher/enums/chat_type.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: ChatType -description: "Type of chat" -parse: - entity: Chat - attribute: type - regexp: "'([a-z]+)'" diff --git a/.butcher/enums/update_type.yml b/.butcher/enums/update_type.yml deleted file mode 100644 index 28b6e3e8..00000000 --- a/.butcher/enums/update_type.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: UpdateType -description: Known update types -extract: - entity: Update - exclude: - - update_id diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ffe7b117..870c3366 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,17 +33,17 @@ repos: args: [ '--config=.flake8' ] files: *files - - repo: https://github.com/floatingpurr/sync_with_poetry - rev: 0.2.0 - hooks: - - id: sync_with_poetry +# - repo: https://github.com/floatingpurr/sync_with_poetry +# rev: 0.2.0 +# hooks: +# - id: sync_with_poetry - repo: https://github.com/python-poetry/poetry rev: '1.2.1' hooks: - id: poetry-check - - id: poetry-lock - args: [ "--no-update" ] +# - id: poetry-lock +# args: [ "--no-update" ] - id: poetry-export args: [ "-f", "requirements.txt", "--without-hashes", "-o", "requirements/base.txt" ] - id: poetry-export diff --git a/aiogram/enums/__init__.py b/aiogram/enums/__init__.py index 7e3935fe..0d197052 100644 --- a/aiogram/enums/__init__.py +++ b/aiogram/enums/__init__.py @@ -1,13 +1,27 @@ +from .bot_command_scope_type import BotCommandScopeType +from .chat_action import ChatAction +from .chat_member_status import ChatMemberStatus from .chat_type import ChatType from .content_type import ContentType from .dice_emoji import DiceEmoji +from .menu_button_type import MenuButtonType +from .message_entity_type import MessageEntityType +from .parse_mode import ParseMode +from .poll_type import PollType from .topic_icon_color import TopicIconColor from .update_type import UpdateType __all__ = ( + "BotCommandScopeType", + "ChatAction", + "ChatMemberStatus", "ChatType", "ContentType", "DiceEmoji", + "MenuButtonType", + "MessageEntityType", + "ParseMode", + "PollType", "TopicIconColor", "UpdateType", ) diff --git a/aiogram/enums/bot_command_scope_type.py b/aiogram/enums/bot_command_scope_type.py new file mode 100644 index 00000000..387e4d05 --- /dev/null +++ b/aiogram/enums/bot_command_scope_type.py @@ -0,0 +1,18 @@ +from enum import Enum + + +class BotCommandScopeType(str, Enum): + """ + This object represents the scope to which bot commands are applied. + + Source: https://core.telegram.org/bots/api#botcommandscope + """ + + DEFAULT = "default" + ALL_PRIVATE_CHATS = "all_private_chats" + ALL_GROUP_CHATS = "all_group_chats" + ALL_CHAT_ADMINISTRATORS = "all_chat_administrators" + CHAT = "chat" + CHAT_ADMINISTRATORS = "chat_administrators" + CHAT_MEMBER = "chat_member" + ALL = "all" diff --git a/aiogram/enums/chat_action.py b/aiogram/enums/chat_action.py new file mode 100644 index 00000000..4402b5b4 --- /dev/null +++ b/aiogram/enums/chat_action.py @@ -0,0 +1,32 @@ +from enum import Enum + + +class ChatAction(str, Enum): + """ + This object represents bot actions. + + Choose one, depending on what the user is about to receive: + + - typing for text messages, + - upload_photo for photos, + - record_video or upload_video for videos, + - record_voice or upload_voice for voice notes, + - upload_document for general files, + - choose_sticker for stickers, + - find_location for location data, + - record_video_note or upload_video_note for video notes. + + Source: https://core.telegram.org/bots/api#sendchataction + """ + + TYPING = "typing" + UPLOAD_PHOTO = "upload_photo" + RECORD_VIDEO = "record_video" + UPLOAD_VIDEO = "upload_video" + RECORD_VOICE = "record_voice" + UPLOAD_VOICE = "upload_voice" + UPLOAD_DOCUMENT = "upload_document" + CHOOSE_STICKER = "choose_sticker" + FIND_LOCATION = "find_location" + RECORD_VIDEO_NOTE = "record_video_note" + UPLOAD_VIDEO_NOTE = "upload_video_note" diff --git a/aiogram/enums/chat_member_status.py b/aiogram/enums/chat_member_status.py new file mode 100644 index 00000000..db6f9213 --- /dev/null +++ b/aiogram/enums/chat_member_status.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class ChatMemberStatus(str, Enum): + """ + This object represents chat member status. + + Source: https://core.telegram.org/bots/api#chatmember + """ + + CREATOR = "creator" + ADMINISTRATOR = "administrator" + MEMBER = "member" + RESTRICTED = "restricted" + LEFT = "left" + KICKED = "kicked" diff --git a/aiogram/enums/chat_type.py b/aiogram/enums/chat_type.py index d2e9794b..749bf464 100644 --- a/aiogram/enums/chat_type.py +++ b/aiogram/enums/chat_type.py @@ -3,7 +3,9 @@ from enum import Enum class ChatType(str, Enum): """ - Type of chat + This object represents a chat type + + Source: https://core.telegram.org/bots/api#chat """ PRIVATE = "private" diff --git a/aiogram/enums/content_type.py b/aiogram/enums/content_type.py index d3d0de28..18fa3484 100644 --- a/aiogram/enums/content_type.py +++ b/aiogram/enums/content_type.py @@ -3,7 +3,7 @@ from enum import Enum class ContentType(str, Enum): """ - Message content type + This object represents a type of content in message """ UNKNOWN = "unknown" diff --git a/aiogram/enums/dice_emoji.py b/aiogram/enums/dice_emoji.py index b9514cb0..68519324 100644 --- a/aiogram/enums/dice_emoji.py +++ b/aiogram/enums/dice_emoji.py @@ -4,6 +4,8 @@ from enum import Enum class DiceEmoji(str, Enum): """ Emoji on which the dice throw animation is based + + Source: https://core.telegram.org/bots/api#dice """ DICE = "🎲" diff --git a/aiogram/enums/menu_button_type.py b/aiogram/enums/menu_button_type.py new file mode 100644 index 00000000..4c1015b9 --- /dev/null +++ b/aiogram/enums/menu_button_type.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class MenuButtonType(str, Enum): + """ + This object represents an type of Menu button + + Source: https://core.telegram.org/bots/api#menubuttondefault + """ + + DEFAULT = "default" + COMMANDS = "commands" + WEB_APP = "web_app" diff --git a/aiogram/enums/message_entity_type.py b/aiogram/enums/message_entity_type.py new file mode 100644 index 00000000..f58f487a --- /dev/null +++ b/aiogram/enums/message_entity_type.py @@ -0,0 +1,27 @@ +from enum import Enum + + +class MessageEntityType(str, Enum): + """ + This object represents type of message entity + + Source: https://core.telegram.org/bots/api#messageentity + """ + + MENTION = "mention" + HASHTAG = "hashtag" + CASHTAG = "cashtag" + BOT_COMMAND = "bot_command" + URL = "url" + EMAIL = "email" + PHONE_NUMBER = "phone_number" + BOLD = "bold" + ITALIC = "italic" + UNDERLINE = "underline" + STRIKETHROUGH = "strikethrough" + SPOILER = "spoiler" + CODE = "code" + PRE = "pre" + TEXT_LINK = "text_link" + TEXT_MENTION = "text_mention" + CUSTOM_EMOJI = "custom_emoji" diff --git a/aiogram/enums/parse_mode.py b/aiogram/enums/parse_mode.py new file mode 100644 index 00000000..f17dd984 --- /dev/null +++ b/aiogram/enums/parse_mode.py @@ -0,0 +1,13 @@ +from enum import Enum + + +class ParseMode(str, Enum): + """ + Formatting options + + Source: https://core.telegram.org/bots/api#formatting-options + """ + + MARKDOWN_V2 = "MarkdownV2" + MARKDOWN = "Markdown" + HTML = "HTML" diff --git a/aiogram/enums/poll_type.py b/aiogram/enums/poll_type.py new file mode 100644 index 00000000..039d600d --- /dev/null +++ b/aiogram/enums/poll_type.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class PollType(str, Enum): + """ + This object represents poll type + + Source: https://core.telegram.org/bots/api#poll + """ + + REGULAR = "regular" + QUIZ = "quiz" diff --git a/aiogram/enums/update_type.py b/aiogram/enums/update_type.py index aaf0b970..6025accc 100644 --- a/aiogram/enums/update_type.py +++ b/aiogram/enums/update_type.py @@ -3,7 +3,9 @@ from enum import Enum class UpdateType(str, Enum): """ - Known update types + This object represents the complete list of allowed update types + + Source: https://core.telegram.org/bots/api#update """ MESSAGE = "message" diff --git a/docs/api/enums/index.rst b/docs/api/enums/index.rst index d2cb7041..e392a4d1 100644 --- a/docs/api/enums/index.rst +++ b/docs/api/enums/index.rst @@ -8,8 +8,15 @@ Here is list of all available enums: .. toctree:: :maxdepth: 1 + bot_command_scope_type + chat_action + chat_member_status chat_type content_type dice_emoji + menu_button_type + message_entity_type + parse_mode + poll_type topic_icon_color update_type diff --git a/docs/locale/en/LC_MESSAGES/changelog.po b/docs/locale/en/LC_MESSAGES/changelog.po index 4b0fb643..bef877d8 100644 --- a/docs/locale/en/LC_MESSAGES/changelog.po +++ b/docs/locale/en/LC_MESSAGES/changelog.po @@ -1272,7 +1272,7 @@ msgstr "" #: ../../../HISTORY.rst:139 msgid "" -"Added is_chat_creator method to ChatMemberStatus (`#394 " +"Added is_chat_creator method to ChatMemberStatus.yml (`#394 " "`_)" msgstr "" @@ -1765,7 +1765,7 @@ msgstr "" #: ../../../HISTORY.rst:287 msgid "" ":code:`is_member` and :code:`is_admin` methods of :code:`ChatMember` and " -":code:`ChatMemberStatus` was renamed to :code:`is_chat_member` and " +":code:`ChatMemberStatus.yml` was renamed to :code:`is_chat_member` and " ":code:`is_chat_admin`" msgstr "" diff --git a/docs/locale/uk_UA/LC_MESSAGES/changelog.po b/docs/locale/uk_UA/LC_MESSAGES/changelog.po index 4b0fb643..bef877d8 100644 --- a/docs/locale/uk_UA/LC_MESSAGES/changelog.po +++ b/docs/locale/uk_UA/LC_MESSAGES/changelog.po @@ -1272,7 +1272,7 @@ msgstr "" #: ../../../HISTORY.rst:139 msgid "" -"Added is_chat_creator method to ChatMemberStatus (`#394 " +"Added is_chat_creator method to ChatMemberStatus.yml (`#394 " "`_)" msgstr "" @@ -1765,7 +1765,7 @@ msgstr "" #: ../../../HISTORY.rst:287 msgid "" ":code:`is_member` and :code:`is_admin` methods of :code:`ChatMember` and " -":code:`ChatMemberStatus` was renamed to :code:`is_chat_member` and " +":code:`ChatMemberStatus.yml` was renamed to :code:`is_chat_member` and " ":code:`is_chat_admin`" msgstr ""