Skip to content

Commit

Permalink
fix get_full_command for messages with caption (#576)
Browse files Browse the repository at this point in the history
* fix get_full_command for messages with caption

* change to more cleaner method
  • Loading branch information
dashedman committed May 11, 2021
1 parent d5a4c0c commit 405add3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions aiogram/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def is_command(self) -> bool:
: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]]:
"""
Expand All @@ -203,8 +204,9 @@ def get_full_command(self) -> typing.Optional[typing.Tuple[str, str]]:
: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]:
Expand Down Expand Up @@ -271,7 +273,7 @@ def url(self) -> str:
:return: str
"""

if self.chat.type == ChatType.PRIVATE:
raise TypeError("Invalid chat type!")
url = "https://t.me/"
Expand Down Expand Up @@ -1420,7 +1422,7 @@ async def answer_dice(
allow_sending_without_reply=allow_sending_without_reply,
reply_markup=reply_markup,
)

async def answer_chat_action(
self,
action: base.String,
Expand Down

0 comments on commit 405add3

Please sign in to comment.