From 027139f1b2b7dc553012a4fe2d39f16b0f354d0b Mon Sep 17 00:00:00 2001 From: George Imedashvili Date: Mon, 8 Jun 2020 18:21:15 +0100 Subject: [PATCH] fix get_full_command (#348) The reason is that .partition() doesn't have a default param as .split has, and default split param gives possibility to split not only by whitespaces, but also whitespace consequences (so the .strip() in get_args() not needed) and newlines. It's called "fix", because without it, commands like this: '''/command arg arg1''' are resulting with ('/command\narg\narg1', '', '') --- aiogram/types/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 9b9c0f82..b9452967 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -168,7 +168,7 @@ class Message(base.TelegramObject): :return: tuple of (command, args) """ if self.is_command(): - command, _, args = self.text.partition(' ') + command, args = self.text.split(maxsplit=1) return command, args def get_command(self, pure=False): @@ -192,7 +192,7 @@ class Message(base.TelegramObject): """ command = self.get_full_command() if command: - return command[1].strip() + return command[1] def parse_entities(self, as_html=True): """