mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 19:00:23 +00:00
Update types to 3.4 Bot API
This commit is contained in:
parent
1b87532221
commit
afd76cce9f
2 changed files with 29 additions and 4 deletions
|
|
@ -22,6 +22,8 @@ class Chat(base.TelegramObject):
|
||||||
description: base.String = fields.Field()
|
description: base.String = fields.Field()
|
||||||
invite_link: base.String = fields.Field()
|
invite_link: base.String = fields.Field()
|
||||||
pinned_message: 'Message' = fields.Field(base='Message')
|
pinned_message: 'Message' = fields.Field(base='Message')
|
||||||
|
sticker_set_name: base.String = fields.Field()
|
||||||
|
can_set_sticker_set: base.Boolean = fields.Field()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ class Message(base.TelegramObject):
|
||||||
author_signature: base.String = fields.Field()
|
author_signature: base.String = fields.Field()
|
||||||
text: base.String = fields.Field()
|
text: base.String = fields.Field()
|
||||||
entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
|
entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
|
||||||
|
caption_entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
|
||||||
audio: Audio = fields.Field(base=Audio)
|
audio: Audio = fields.Field(base=Audio)
|
||||||
document: Document = fields.Field(base=Document)
|
document: Document = fields.Field(base=Document)
|
||||||
game: Game = fields.Field(base=Game)
|
game: Game = fields.Field(base=Game)
|
||||||
|
|
@ -100,6 +101,7 @@ class Message(base.TelegramObject):
|
||||||
def is_command(self):
|
def is_command(self):
|
||||||
"""
|
"""
|
||||||
Check message text is command
|
Check message text is command
|
||||||
|
|
||||||
:return: bool
|
:return: bool
|
||||||
"""
|
"""
|
||||||
return self.text and self.text.startswith('/')
|
return self.text and self.text.startswith('/')
|
||||||
|
|
@ -107,6 +109,7 @@ class Message(base.TelegramObject):
|
||||||
def get_full_command(self):
|
def get_full_command(self):
|
||||||
"""
|
"""
|
||||||
Split command and args
|
Split command and args
|
||||||
|
|
||||||
:return: tuple of (command, args)
|
:return: tuple of (command, args)
|
||||||
"""
|
"""
|
||||||
if self.is_command():
|
if self.is_command():
|
||||||
|
|
@ -114,18 +117,33 @@ class Message(base.TelegramObject):
|
||||||
return command, args
|
return command, args
|
||||||
|
|
||||||
def get_command(self):
|
def get_command(self):
|
||||||
|
"""
|
||||||
|
Get command from message
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
command = self.get_full_command()
|
command = self.get_full_command()
|
||||||
if command:
|
if command:
|
||||||
return command[0]
|
return command[0]
|
||||||
|
|
||||||
def get_args(self):
|
def get_args(self):
|
||||||
|
"""
|
||||||
|
Get arguments
|
||||||
|
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
command = self.get_full_command()
|
command = self.get_full_command()
|
||||||
if command:
|
if command:
|
||||||
return command[1].strip()
|
return command[1].strip()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def md_text(self):
|
def md_text(self) -> str:
|
||||||
text = self.text
|
"""
|
||||||
|
Text or caption formatted as markdown.
|
||||||
|
|
||||||
|
:return: str
|
||||||
|
"""
|
||||||
|
text = self.caption if self.caption else self.text
|
||||||
|
|
||||||
if self.text and self.entities:
|
if self.text and self.entities:
|
||||||
for entity in reversed(self.entities):
|
for entity in reversed(self.entities):
|
||||||
|
|
@ -134,8 +152,13 @@ class Message(base.TelegramObject):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def html_text(self):
|
def html_text(self) -> str:
|
||||||
text = self.text
|
"""
|
||||||
|
Text or caption formatted as HTML.
|
||||||
|
|
||||||
|
:return: str
|
||||||
|
"""
|
||||||
|
text = self.caption if self.caption else self.text
|
||||||
|
|
||||||
if self.text and self.entities:
|
if self.text and self.entities:
|
||||||
for entity in reversed(self.entities):
|
for entity in reversed(self.entities):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue