mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add is_forward method to Message (#390)
* new: add is_forward method to Message * enh: add return types to Message methods * fix: docs typo * ref: make command methods closer
This commit is contained in:
parent
5b40a2b8cf
commit
0cc6a2c8f6
1 changed files with 14 additions and 5 deletions
|
|
@ -153,7 +153,16 @@ class Message(base.TelegramObject):
|
|||
|
||||
return ContentType.UNKNOWN
|
||||
|
||||
def is_command(self):
|
||||
def is_forward(self) -> bool:
|
||||
"""
|
||||
Check that the message is forwarded.
|
||||
Only `forward_date` is required to be in forwarded message.
|
||||
|
||||
:return: bool
|
||||
"""
|
||||
return bool(self.forward_date)
|
||||
|
||||
def is_command(self) -> bool:
|
||||
"""
|
||||
Check message text is command
|
||||
|
||||
|
|
@ -161,7 +170,7 @@ class Message(base.TelegramObject):
|
|||
"""
|
||||
return self.text and self.text.startswith("/")
|
||||
|
||||
def get_full_command(self):
|
||||
def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]:
|
||||
"""
|
||||
Split command and args
|
||||
|
||||
|
|
@ -172,7 +181,7 @@ class Message(base.TelegramObject):
|
|||
args = args[-1] if args else ""
|
||||
return command, args
|
||||
|
||||
def get_command(self, pure=False):
|
||||
def get_command(self, pure=False) -> typing.Optional[str]:
|
||||
"""
|
||||
Get command from message
|
||||
|
||||
|
|
@ -185,7 +194,7 @@ class Message(base.TelegramObject):
|
|||
command, _, _ = command[1:].partition("@")
|
||||
return command
|
||||
|
||||
def get_args(self):
|
||||
def get_args(self) -> typing.Optional[str]:
|
||||
"""
|
||||
Get arguments
|
||||
|
||||
|
|
@ -195,7 +204,7 @@ class Message(base.TelegramObject):
|
|||
if command:
|
||||
return command[1]
|
||||
|
||||
def parse_entities(self, as_html=True):
|
||||
def parse_entities(self, as_html=True) -> str:
|
||||
"""
|
||||
Text or caption formatted as HTML or Markdown.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue