Update message.py

This commit is contained in:
Yura 2022-02-25 15:38:52 +02:00 committed by GitHub
parent 4a4eb51bd4
commit f7a74e4289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -110,75 +110,10 @@ class Message(base.TelegramObject):
@property
@functools.lru_cache()
def content_type(self):
if self.text:
return ContentType.TEXT
if self.audio:
return ContentType.AUDIO
if self.animation:
return ContentType.ANIMATION
if self.document:
return ContentType.DOCUMENT
if self.game:
return ContentType.GAME
if self.photo:
return ContentType.PHOTO
if self.sticker:
return ContentType.STICKER
if self.video:
return ContentType.VIDEO
if self.video_note:
return ContentType.VIDEO_NOTE
if self.voice:
return ContentType.VOICE
if self.contact:
return ContentType.CONTACT
if self.venue:
return ContentType.VENUE
if self.location:
return ContentType.LOCATION
if self.poll:
return ContentType.POLL
if self.dice:
return ContentType.DICE
if self.new_chat_members:
return ContentType.NEW_CHAT_MEMBERS
if self.left_chat_member:
return ContentType.LEFT_CHAT_MEMBER
if self.invoice:
return ContentType.INVOICE
if self.successful_payment:
return ContentType.SUCCESSFUL_PAYMENT
if self.connected_website:
return ContentType.CONNECTED_WEBSITE
if self.message_auto_delete_timer_changed:
return ContentType.MESSAGE_AUTO_DELETE_TIMER_CHANGED
if self.migrate_from_chat_id:
return ContentType.MIGRATE_FROM_CHAT_ID
if self.migrate_to_chat_id:
return ContentType.MIGRATE_TO_CHAT_ID
if self.pinned_message:
return ContentType.PINNED_MESSAGE
if self.new_chat_title:
return ContentType.NEW_CHAT_TITLE
if self.new_chat_photo:
return ContentType.NEW_CHAT_PHOTO
if self.delete_chat_photo:
return ContentType.DELETE_CHAT_PHOTO
if self.group_chat_created:
return ContentType.GROUP_CHAT_CREATED
if self.passport_data:
return ContentType.PASSPORT_DATA
if self.proximity_alert_triggered:
return ContentType.PROXIMITY_ALERT_TRIGGERED
if self.voice_chat_scheduled:
return ContentType.VOICE_CHAT_SCHEDULED
if self.voice_chat_started:
return ContentType.VOICE_CHAT_STARTED
if self.voice_chat_ended:
return ContentType.VOICE_CHAT_ENDED
if self.voice_chat_participants_invited:
return ContentType.VOICE_CHAT_PARTICIPANTS_INVITED
content_types = ContentTypes.all()
for content_type in content_types:
if eval(f"self.{content_type}"):
return eval(content_type.upper())
return ContentType.UNKNOWN
def is_forward(self) -> bool: