fix get_full_command for messages with caption

This commit is contained in:
dashedman 2021-05-04 16:51:54 +03:00
parent d5a4c0c4af
commit 1ae3d2e189

View file

@ -194,7 +194,8 @@ class Message(base.TelegramObject):
:return: bool :return: bool
""" """
return self.text and self.text.startswith("/") return self.text and self.text.startswith("/") \
or self.caption and self.caption.startswith("/")
def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]: def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]:
""" """
@ -203,8 +204,9 @@ class Message(base.TelegramObject):
:return: tuple of (command, args) :return: tuple of (command, args)
""" """
if self.is_command(): if self.is_command():
command, *args = self.text.split(maxsplit=1) command, *args = (self.text if self.text
args = args[-1] if args else "" else self.caption).split(maxsplit=1)
args = args[0] if args else ""
return command, args return command, args
def get_command(self, pure=False) -> typing.Optional[str]: def get_command(self, pure=False) -> typing.Optional[str]:
@ -271,7 +273,7 @@ class Message(base.TelegramObject):
:return: str :return: str
""" """
if self.chat.type == ChatType.PRIVATE: if self.chat.type == ChatType.PRIVATE:
raise TypeError("Invalid chat type!") raise TypeError("Invalid chat type!")
url = "https://t.me/" url = "https://t.me/"
@ -1420,7 +1422,7 @@ class Message(base.TelegramObject):
allow_sending_without_reply=allow_sending_without_reply, allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup, reply_markup=reply_markup,
) )
async def answer_chat_action( async def answer_chat_action(
self, self,
action: base.String, action: base.String,