This commit is contained in:
Oleg A 2024-07-05 01:04:15 +03:00 committed by GitHub
parent 8fab9d1234
commit 094f219072
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 30 additions and 6 deletions

View file

@ -5,7 +5,6 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from .base import TelegramObject
if TYPE_CHECKING:
from .paid_media_info import PaidMediaInfo
from .animation import Animation
from .audio import Audio
from .chat import Chat
@ -22,6 +21,7 @@ if TYPE_CHECKING:
from .message_origin_chat import MessageOriginChat
from .message_origin_hidden_user import MessageOriginHiddenUser
from .message_origin_user import MessageOriginUser
from .paid_media_info import PaidMediaInfo
from .photo_size import PhotoSize
from .poll import Poll
from .sticker import Sticker

View file

@ -10,10 +10,11 @@ from aiogram.utils.text_decorations import (
html_decoration,
markdown_decoration,
)
from .custom import DateTime
from .maybe_inaccessible_message import MaybeInaccessibleMessage
from ..client.default import Default
from ..enums import ContentType
from .custom import DateTime
from .maybe_inaccessible_message import MaybeInaccessibleMessage
if TYPE_CHECKING:
from ..methods import (
@ -82,7 +83,6 @@ if TYPE_CHECKING:
from .labeled_price import LabeledPrice
from .link_preview_options import LinkPreviewOptions
from .location import Location
from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged
from .message_entity import MessageEntity
from .message_origin_channel import MessageOriginChannel
@ -595,6 +595,8 @@ class Message(MaybeInaccessibleMessage):
return ContentType.SUPERGROUP_CHAT_CREATED
if self.channel_chat_created:
return ContentType.CHANNEL_CHAT_CREATED
if self.paid_media:
return ContentType.PAID_MEDIA
if self.passport_data:
return ContentType.PASSPORT_DATA
if self.proximity_alert_triggered:
@ -3435,6 +3437,8 @@ class Message(MaybeInaccessibleMessage):
**kwargs,
).as_(self._bot)
if self.poll:
from .input_poll_option import InputPollOption
return SendPoll(
question=self.poll.question,
options=[

View file

@ -6,9 +6,9 @@ from .base import TelegramObject
from .custom import DateTime
if TYPE_CHECKING:
from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds
from .transaction_partner_fragment import TransactionPartnerFragment
from .transaction_partner_other import TransactionPartnerOther
from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds
from .transaction_partner_user import TransactionPartnerUser

View file

@ -4,7 +4,6 @@ from os import getenv
from typing import Any, Dict, Union
from aiohttp import web
from finite_state_machine import form_router
from aiogram import Bot, Dispatcher, F, Router
from aiogram.client.session.aiohttp import AiohttpSession
@ -19,6 +18,7 @@ from aiogram.webhook.aiohttp_server import (
TokenBasedRequestHandler,
setup_application,
)
from finite_state_machine import form_router
main_router = Router()

View file

@ -68,6 +68,8 @@ from aiogram.types import (
Location,
MessageAutoDeleteTimerChanged,
MessageEntity,
PaidMediaInfo,
PaidMediaPhoto,
PassportData,
PhotoSize,
Poll,
@ -331,6 +333,22 @@ TEST_MESSAGE_CHANNEL_CHAT_CREATED = Message(
chat=Chat(id=-10042, type="channel"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)
TEST_MESSAGE_PAID_MEDIA = Message(
message_id=42,
date=datetime.datetime.now(),
paid_media=PaidMediaInfo(
star_count=100500,
paid_media=[
PaidMediaPhoto(
photo=[
PhotoSize(file_id="file id", file_unique_id="file id", width=42, height=42)
],
)
],
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)
TEST_MESSAGE_PASSPORT_DATA = Message(
message_id=42,
date=datetime.datetime.now(),
@ -603,6 +621,7 @@ MESSAGES_AND_CONTENT_TYPES = [
[TEST_MESSAGE_GROUP_CHAT_CREATED, ContentType.GROUP_CHAT_CREATED],
[TEST_MESSAGE_SUPERGROUP_CHAT_CREATED, ContentType.SUPERGROUP_CHAT_CREATED],
[TEST_MESSAGE_CHANNEL_CHAT_CREATED, ContentType.CHANNEL_CHAT_CREATED],
[TEST_MESSAGE_PAID_MEDIA, ContentType.PAID_MEDIA],
[TEST_MESSAGE_PASSPORT_DATA, ContentType.PASSPORT_DATA],
[TEST_MESSAGE_PROXIMITY_ALERT_TRIGGERED, ContentType.PROXIMITY_ALERT_TRIGGERED],
[TEST_MESSAGE_POLL, ContentType.POLL],
@ -669,6 +688,7 @@ MESSAGES_AND_COPY_METHODS = [
[TEST_MESSAGE_GROUP_CHAT_CREATED, None],
[TEST_MESSAGE_SUPERGROUP_CHAT_CREATED, None],
[TEST_MESSAGE_CHANNEL_CHAT_CREATED, None],
[TEST_MESSAGE_PAID_MEDIA, None],
[TEST_MESSAGE_PASSPORT_DATA, None],
[TEST_MESSAGE_PROXIMITY_ALERT_TRIGGERED, None],
[TEST_MESSAGE_POLL, SendPoll],