mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-09 23:36:02 +00:00
feat: 现有指令占位
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user