Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

XDbot2 工具(_utils.py)

This is XiaoDeng edited this page Sep 5, 2023 · 1 revision

写在前面

本页面是 XDbot2 工具库(_utils.py)的文档,阅读本文有助于您开发 XDbot2

什么是 XDbot2 工具库

工具库位于 src/plugins/Core/plugins/_utils.py,包含了部分常用操作的封装

开始使用

在插件添加本行导入工具库

from ._utils import *

def create_command(cmd: str, aliases: set = set(), **params)

创建一个指令

参数 必要 备注
cmd 指令名
aliases 指令别名

示例

@create_command("hello")
async def handle_hello_command(bot: Bot, event: MessageEvent, message: MEssage):
    ...

警告

由于技术原因,被create_command修饰的函数至少要有三个参数,不能超过三个必须参数。

create_command注册的触发器触发时会向被修饰函数传入三个参数,其类型依次为:nonebot.adapters.onebot.v11.Botnonebot.adapters.onebot.v11.MessageEventnonebot.adapters.onebot.v11.Message

TODO