From 35bf18cf5ac4fdf75eccd6d23873309589beef35 Mon Sep 17 00:00:00 2001 From: Googleplex Date: Thu, 29 Apr 2021 04:37:59 +0800 Subject: [PATCH] fix: builtin command filter args (#556) (#558) * fix: builtin command filter args * fix: use string for command arguments * fix: text property of command object Co-authored-by: evgfilim1 Co-authored-by: evgfilim1 --- aiogram/dispatcher/filters/builtin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aiogram/dispatcher/filters/builtin.py b/aiogram/dispatcher/filters/builtin.py index c32c53be..457de182 100644 --- a/aiogram/dispatcher/filters/builtin.py +++ b/aiogram/dispatcher/filters/builtin.py @@ -4,7 +4,7 @@ import typing import warnings from contextvars import ContextVar from dataclasses import dataclass, field -from typing import Any, Dict, Iterable, Optional, Union +from typing import Any, Dict, Iterable, List, Optional, Union from babel.support import LazyProxy @@ -110,7 +110,8 @@ class Command(Filter): if not text: return False - full_command = text.split()[0] + full_command, *args_list = text.split(maxsplit=1) + args = args_list[0] if args_list else None prefix, (command, _, mention) = full_command[0], full_command[1:].partition('@') if not ignore_mention and mention and (await message.bot.me).username.lower() != mention.lower(): @@ -120,7 +121,7 @@ class Command(Filter): if (command.lower() if ignore_case else command) not in commands: return False - return {'command': cls.CommandObj(command=command, prefix=prefix, mention=mention)} + return {'command': cls.CommandObj(command=command, prefix=prefix, mention=mention, args=args)} @dataclass class CommandObj: