From 405add31abf76de6896bf43ee3826306053d4916 Mon Sep 17 00:00:00 2001 From: dashedman <64865196+dashedman@users.noreply.github.com> Date: Tue, 11 May 2021 23:39:17 +0300 Subject: [PATCH] fix get_full_command for messages with caption (#576) * fix get_full_command for messages with caption * change to more cleaner method --- aiogram/types/message.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index ce8395d2..5eb96618 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -194,7 +194,8 @@ class Message(base.TelegramObject): :return: bool """ - return self.text and self.text.startswith("/") + text = self.text or self.caption + return text and text.startswith("/") def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]: """ @@ -203,8 +204,9 @@ class Message(base.TelegramObject): :return: tuple of (command, args) """ if self.is_command(): - command, *args = self.text.split(maxsplit=1) - args = args[-1] if args else "" + text = self.text or self.caption + command, *args = text.split(maxsplit=1) + args = args[0] if args else "" return command, args def get_command(self, pure=False) -> typing.Optional[str]: @@ -271,7 +273,7 @@ class Message(base.TelegramObject): :return: str """ - + if self.chat.type == ChatType.PRIVATE: raise TypeError("Invalid chat type!") url = "https://t.me/" @@ -1420,7 +1422,7 @@ class Message(base.TelegramObject): allow_sending_without_reply=allow_sending_without_reply, reply_markup=reply_markup, ) - + async def answer_chat_action( self, action: base.String,