change to more cleaner method

This commit is contained in:
dashedman 2021-05-05 12:14:53 +03:00
parent 1ae3d2e189
commit f790819369

View file

@ -194,8 +194,8 @@ class Message(base.TelegramObject):
:return: bool
"""
return self.text and self.text.startswith("/") \
or self.caption and self.caption.startswith("/")
text = self.text or self.caption
return text and text.startswith("/")
def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]:
"""
@ -204,8 +204,8 @@ class Message(base.TelegramObject):
:return: tuple of (command, args)
"""
if self.is_command():
command, *args = (self.text if self.text
else self.caption).split(maxsplit=1)
text = self.text or self.caption
command, *args = text.split(maxsplit=1)
args = args[0] if args else ""
return command, args