diff --git a/aiogram/client/session/aiohttp.py b/aiogram/client/session/aiohttp.py index 1f31ee97..7ead6133 100644 --- a/aiogram/client/session/aiohttp.py +++ b/aiogram/client/session/aiohttp.py @@ -128,6 +128,8 @@ class AiohttpSession(BaseSession): def build_form_data(self, request: Request) -> FormData: form = FormData(quote_fields=False) for key, value in request.data.items(): + if request.method == "createForumTopic": + print(key, self.prepare_value(value)) if value is None or value is UNSET: continue form.add_field(key, self.prepare_value(value)) diff --git a/aiogram/client/session/base.py b/aiogram/client/session/base.py index 6fa25dd5..0e74d700 100644 --- a/aiogram/client/session/base.py +++ b/aiogram/client/session/base.py @@ -3,6 +3,7 @@ from __future__ import annotations import abc import datetime import json +from enum import Enum from http import HTTPStatus from types import TracebackType from typing import TYPE_CHECKING, Any, AsyncGenerator, Callable, Final, Optional, Type, Union, cast @@ -162,6 +163,8 @@ class BaseSession(abc.ABC): return str(round((now + value).timestamp())) if isinstance(value, datetime.datetime): return str(round(value.timestamp())) + if isinstance(value, Enum): + return self.prepare_value(value.value) else: return str(value) diff --git a/aiogram/enums/__init__.py b/aiogram/enums/__init__.py new file mode 100644 index 00000000..6b12bdec --- /dev/null +++ b/aiogram/enums/__init__.py @@ -0,0 +1,13 @@ +from .chat_type import ChatType +from .content_type import ContentType +from .dice_emoji import DiceEmoji +from .topic_icon_color import TopicIconColor +from .update_type import UpdateType + +__all__ = ( + "ChatType", + "DiceEmoji", + "TopicIconColor", + "UpdateType", + "ContentType", +) diff --git a/aiogram/enums/chat_type.py b/aiogram/enums/chat_type.py new file mode 100644 index 00000000..d2e9794b --- /dev/null +++ b/aiogram/enums/chat_type.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class ChatType(str, Enum): + """ + Type of chat + """ + + PRIVATE = "private" + GROUP = "group" + SUPERGROUP = "supergroup" + CHANNEL = "channel" diff --git a/aiogram/enums/content_type.py b/aiogram/enums/content_type.py new file mode 100644 index 00000000..d3d0de28 --- /dev/null +++ b/aiogram/enums/content_type.py @@ -0,0 +1,50 @@ +from enum import Enum + + +class ContentType(str, Enum): + """ + Message content type + """ + + UNKNOWN = "unknown" + ANY = "any" + TEXT = "text" + ANIMATION = "animation" + AUDIO = "audio" + DOCUMENT = "document" + PHOTO = "photo" + STICKER = "sticker" + VIDEO = "video" + VIDEO_NOTE = "video_note" + VOICE = "voice" + CONTACT = "contact" + DICE = "dice" + GAME = "game" + POLL = "poll" + VENUE = "venue" + LOCATION = "location" + NEW_CHAT_MEMBERS = "new_chat_members" + LEFT_CHAT_MEMBER = "left_chat_member" + NEW_CHAT_TITLE = "new_chat_title" + NEW_CHAT_PHOTO = "new_chat_photo" + DELETE_CHAT_PHOTO = "delete_chat_photo" + GROUP_CHAT_CREATED = "group_chat_created" + SUPERGROUP_CHAT_CREATED = "supergroup_chat_created" + CHANNEL_CHAT_CREATED = "channel_chat_created" + MESSAGE_AUTO_DELETE_TIMER_CHANGED = "message_auto_delete_timer_changed" + MIGRATE_TO_CHAT_ID = "migrate_to_chat_id" + MIGRATE_FROM_CHAT_ID = "migrate_from_chat_id" + PINNED_MESSAGE = "pinned_message" + INVOICE = "invoice" + SUCCESSFUL_PAYMENT = "successful_payment" + CONNECTED_WEBSITE = "connected_website" + PASSPORT_DATA = "passport_data" + PROXIMITY_ALERT_TRIGGERED = "proximity_alert_triggered" + FORUM_TOPIC_CREATED = "forum_topic_created" + FORUM_TOPIC_CLOSED = "forum_topic_closed" + FORUM_TOPIC_REOPENED = "forum_topic_reopened" + VIDEO_CHAT_SCHEDULED = "video_chat_scheduled" + VIDEO_CHAT_STARTED = "video_chat_started" + VIDEO_CHAT_ENDED = "video_chat_ended" + VIDEO_CHAT_PARTICIPANTS_INVITED = "video_chat_participants_invited" + WEB_APP_DATA = "web_app_data" diff --git a/aiogram/enums/dice_emoji.py b/aiogram/enums/dice_emoji.py new file mode 100644 index 00000000..b9514cb0 --- /dev/null +++ b/aiogram/enums/dice_emoji.py @@ -0,0 +1,14 @@ +from enum import Enum + + +class DiceEmoji(str, Enum): + """ + Emoji on which the dice throw animation is based + """ + + DICE = "🎲" + DART = "🎯" + BASKETBALL = "🏀" + FOOTBALL = "⚽" + SLOT_MACHINE = "🎰" + BOWLING = "🎳" diff --git a/aiogram/enums/topic_icon_color.py b/aiogram/enums/topic_icon_color.py new file mode 100644 index 00000000..f40ee71f --- /dev/null +++ b/aiogram/enums/topic_icon_color.py @@ -0,0 +1,16 @@ +from enum import Enum + + +class TopicIconColor(int, Enum): + """ + Color of the topic icon in RGB format. + + Source: https://github.com/telegramdesktop/tdesktop/blob/991fe491c5ae62705d77aa8fdd44a79caf639c45/Telegram/SourceFiles/data/data_forum_topic.cpp#L51-L56 + """ + + BLUE = 0x6FB9F0 + YELLOW = 0xFFD67E + VIOLET = 0xCB86DB + GREEN = 0x8EEE98 + ROSE = 0xFF93B2 + RED = 0xFB6F5F diff --git a/aiogram/enums/update_type.py b/aiogram/enums/update_type.py new file mode 100644 index 00000000..aaf0b970 --- /dev/null +++ b/aiogram/enums/update_type.py @@ -0,0 +1,22 @@ +from enum import Enum + + +class UpdateType(str, Enum): + """ + Known update types + """ + + MESSAGE = "message" + EDITED_MESSAGE = "edited_message" + CHANNEL_POST = "channel_post" + EDITED_CHANNEL_POST = "edited_channel_post" + INLINE_QUERY = "inline_query" + CHOSEN_INLINE_RESULT = "chosen_inline_result" + CALLBACK_QUERY = "callback_query" + SHIPPING_QUERY = "shipping_query" + PRE_CHECKOUT_QUERY = "pre_checkout_query" + POLL = "poll" + POLL_ANSWER = "poll_answer" + MY_CHAT_MEMBER = "my_chat_member" + CHAT_MEMBER = "chat_member" + CHAT_JOIN_REQUEST = "chat_join_request"