From 1759fd9172f2c9edeb1209846015a530856c05a5 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Fri, 26 May 2017 11:00:37 +0300 Subject: [PATCH] Get command and args from message --- aiogram/types/message.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index 93730b15..0852bc8e 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -150,6 +150,19 @@ class Message(Deserializable): def is_command(self): return self.text and self.text.startswith('/') + def get_full_command(self): + if self.is_command(): + command, _, args = self.text.partition(' ') + return command, args + + def get_command(self): + command, _ = self.get_command() + return command + + def get_args(self): + _, args = self.get_command() + return args + async def reply(self, text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_markup=None) -> 'Message': return await self.bot.send_message(self.chat.id, text, parse_mode, disable_web_page_preview,