Added message content type

This commit is contained in:
Alex Root Junior 2022-11-06 12:59:39 +02:00
parent 07ec7eafeb
commit 9738efce08
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
2 changed files with 39 additions and 0 deletions

View file

@ -286,6 +286,12 @@ class Message(TelegramObject):
return ContentType.DICE
if self.message_auto_delete_timer_changed:
return ContentType.MESSAGE_AUTO_DELETE_TIMER_CHANGED
if self.forum_topic_created:
return ContentType.FORUM_TOPIC_CREATED
if self.forum_topic_closed:
return ContentType.FORUM_TOPIC_CLOSED
if self.forum_topic_reopened:
return ContentType.FORUM_TOPIC_REOPENED
if self.video_chat_scheduled:
return ContentType.VIDEO_CHAT_SCHEDULED
if self.video_chat_started:
@ -2037,6 +2043,9 @@ class ContentType(helper.Helper):
POLL = helper.Item() # poll
DICE = helper.Item() # dice
MESSAGE_AUTO_DELETE_TIMER_CHANGED = helper.Item() # message_auto_delete_timer_changed
FORUM_TOPIC_CREATED = helper.Item() # forum_topic_created
FORUM_TOPIC_CLOSED = helper.Item() # forum_topic_closed
FORUM_TOPIC_REOPENED = helper.Item() # forum_topic_reopened
VIDEO_CHAT_SCHEDULED = helper.Item() # video_chat_scheduled
VIDEO_CHAT_STARTED = helper.Item() # video_chat_started
VIDEO_CHAT_ENDED = helper.Item() # video_chat_ended

View file

@ -42,6 +42,9 @@ from aiogram.types import (
Dice,
Document,
EncryptedCredentials,
ForumTopicClosed,
ForumTopicCreated,
ForumTopicReopened,
Game,
InlineKeyboardButton,
InlineKeyboardMarkup,
@ -401,6 +404,30 @@ TEST_MESSAGE_WEB_APP_DATA = Message(
web_app_data=WebAppData(data="test", button_text="Test"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)
TEST_FORUM_TOPIC_CREATED = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
forum_topic_created=ForumTopicCreated(
name="test",
icon_color=0xFFD67E,
),
)
TEST_FORUM_TOPIC_CLOSED = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
forum_topic_closed=ForumTopicClosed(),
)
TEST_FORUM_TOPIC_REOPENED = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
forum_topic_reopened=ForumTopicReopened(),
)
TEST_MESSAGE_UNKNOWN = Message(
message_id=42,
date=datetime.datetime.now(),
@ -456,6 +483,9 @@ class TestMessage:
],
[TEST_MESSAGE_DICE, ContentType.DICE],
[TEST_MESSAGE_WEB_APP_DATA, ContentType.WEB_APP_DATA],
[TEST_FORUM_TOPIC_CREATED, ContentType.FORUM_TOPIC_CREATED],
[TEST_FORUM_TOPIC_CLOSED, ContentType.FORUM_TOPIC_CLOSED],
[TEST_FORUM_TOPIC_REOPENED, ContentType.FORUM_TOPIC_REOPENED],
[TEST_MESSAGE_UNKNOWN, ContentType.UNKNOWN],
],
)