feat: 现有指令占位

This commit is contained in:
Rock Chin
2023-03-19 14:33:01 +00:00
parent 36dca7ae2f
commit d08794579c
4 changed files with 265 additions and 13 deletions

View File

@@ -1,18 +1,30 @@
# 指令模型
commands = {}
"""已注册的指令类"""
commands = []
"""已注册的指令类
{
"name": "指令名",
"description": "指令描述",
"usage": "指令用法",
"aliases": ["别名1", "别名2"],
"admin_only": "是否仅管理员可用",
"func": "指令执行函数"
}
"""
class AbsCommand:
"""指令抽象类"""
@staticmethod
def execute(cls, cmd: str, params: list, session_name: str, text_message: str, launcher_type: str, launcher_id: int,
sender_id: int, is_admin: bool) -> list:
raise NotImplementedError
def command(name: str, description: str, usage: str, aliases: list = None, admin_only: bool = False):
"""指令装饰器"""
def register(cls: type):
"""注册指令类"""
commands[cls.name] = cls
return cls
def wrapper(fun: function):
commands.append({
"name": name,
"description": description,
"usage": usage,
"aliases": aliases,
"admin_only": admin_only,
"func": fun
})
return fun
return wrapper