mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix: builtin command filter args
This commit is contained in:
parent
79c59b34f9
commit
bdd797075d
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
||||
|
|
@ -111,6 +111,7 @@ class Command(Filter):
|
|||
return False
|
||||
|
||||
full_command = text.split()[0]
|
||||
args = text.split()[1:]
|
||||
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:
|
||||
|
|
@ -137,7 +138,7 @@ class Command(Filter):
|
|||
"""Mention (if available)"""
|
||||
mention: str = None
|
||||
"""Command argument"""
|
||||
args: str = field(repr=False, default=None)
|
||||
args: List[str] = field(repr=False, default_factory=list)
|
||||
|
||||
@property
|
||||
def mentioned(self) -> bool:
|
||||
|
|
@ -159,7 +160,7 @@ class Command(Filter):
|
|||
if self.mentioned:
|
||||
line += '@' + self.mention
|
||||
if self.args:
|
||||
line += ' ' + self.args
|
||||
line += ' ' + ' '.join(self.args)
|
||||
return line
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue