for function in aliases.commands:
dp.register_message_handler(function, lambda message: command_check(message, function.command))
def command(**kwargs):
def wrapper(*args):
return args[0], kwargs
return wrapper
class Aliases:
def __init__(self, bot: Bot):
self.bot = bot
@property
def commands(self) -> tuple:
return (
self.new_alias,
)
@command(
name="новый алиас",
args={"алиас": "str"}
)
def new_alias(self, message: types.Message = None):
...
def setup(bot: Bot, dp: Dispatcher):
aliases = Aliases(bot)
print(aliases.commands)
((Тут ссылка, но она почему-то не отображается на сайте, {'name': 'новый алиас', 'args': {'алиас': 'str'}}),)
File "/home/fourex/PycharmProjects/pythonProject/cogs/aliases.py", line 30, in setup
function[0]()
TypeError: Aliases.new_alias() missing 1 required positional argument: 'self
def setup(bot: Bot, dp: Dispatcher):
aliases = Aliases(bot)
for function in aliases.commands:
function[0]()