enh: add return types to Message methods

This commit is contained in:
uburuntu 2020-07-25 17:43:46 +03:00
parent f559dd65b5
commit 7263892401

View file

@ -153,7 +153,7 @@ class Message(base.TelegramObject):
return ContentType.UNKNOWN
def is_command(self):
def is_command(self) -> bool:
"""
Check message text is command
@ -161,7 +161,7 @@ class Message(base.TelegramObject):
"""
return self.text and self.text.startswith("/")
def is_forward(self):
def is_forward(self) -> bool:
"""
Check message text is forward.
Only `forward_date` is required to be in forwarded message.
@ -170,7 +170,7 @@ class Message(base.TelegramObject):
"""
return bool(self.forward_date)
def get_full_command(self):
def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]:
"""
Split command and args
@ -181,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
@ -194,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
@ -204,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.