词库插件
Project description
nonebot-plugin-ciku
✨ NoneBot 插件描述 ✨
这是一个 onebot.v11的词库语言插件
📖 介绍
词库插件方面:
面向小白的词库语言插件,目的是减少编写代码的时间和难度 特点:语言精简(应该) 无需重启nb和reload即可实 现功能热重载 缺点:目前仅能实现一些简单的逻辑运行,但随着更新肯定会慢慢削减
支持导入自定义解析规则(自定义的优先级较低,请注意是否与默认规则冲突)
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot_plugin_ciku
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令pip
pip install nonebot_plugin_ciku
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebot_plugin_ciku"]
⚙️ 说明
词库文件(dicpro.ck)和自定义拓展文件夹都会在初次使用时自动创建
项目还在持续优化,暂时不开放env配置相关
变量大全
目前支持的变量(\是md转译问题,忽略就行):| 变量 | 说明 |
|---|---|
| %QQ% | 用户id |
| %群号% | 群号 |
| %BotQQ% | 机器人自己的QQ |
| %括号n% | 从0开始匹配正则,提取对应字段 |
| %ATn% | 从0开始,提取艾特对应的对象QQ号 |
| [[1150]/6+5[50+6-7*8]] | 如果被包裹的不是数组,优先被识别为计算式,如果不符合计算式,才是正常字符串 |
| \$读 路径 键 默认值\$ | 读文件 |
| \$写 路径 键 值\$ | 写文件 |
| \$调用 名称\$ | 调用对应语块,若有消息字符串单独发出(例子见下,调用的语块前必须有[内部]) |
| \$回调 名称\$ | 调用对应语块,若有消息字符串则合并到对应位置一起发出(例子见下,调用的语块前必须有[内部]) |
| ±at QQ号± | 艾特用户 |
| ±img 路径/链接± | 发送图片 |
| ±reply 0± | 回复指令消息 |
| @%a%['data'] | 比如你前面写了a:{'data':1},那么为1 |
🎉 使用
词库格式
测试
路径:/词库项目/qrbot/src/plugins/词库v2/
name:['123']
a:$读 %路径%send.txt a 0$
b:$读 %路径%send.txt b 0$
c:$读 %路径%send.txt c 123$
d:±img bug.png±
$写 %路径%send.txt c 哈哈哈$
±reply 0±
%a%《隔断》%b%%c%\n±at %QQ%±\n456789
±img https://homdgcat.wiki/images/emote/Yunli/1.png±
%d%
如果:1 > 2
$读 %路径%send.txt c wdnmd$
如果:%a% == %a%
变量测试成功@%name%[0]
如果尾
如果尾
如果:%a% == %a%
缩进测试成功
测试json
name:['123']
data:{'a':'123','b':'456'}
test:{'a':['123']}
@%name%[0]\n
@%data%['b']\n
@%test%['a'][0]
循环测试
测试:1
循环:%i% in 5
测试:[%测试% + %i%]
%测试%\n
循环尾
%测试%\n[1+5*%测试%]
(.*)测试正则(.*)
测试成功\n%括号0%
.*测试艾特
%AT1%\n%BotQQ%
$回调 测试调用$
$调用 测试调用$
[内部]测试调用
测试成功
自定义拓展
在机器人项目目录下找到《自定义拓展》文件夹 创建py文件,这里是示例
# example.py
from nonebot import require
require("nonebot_plugin_ciku")
from nonebot_plugin_ciku.ciku.parser_rules import ParseRule
class EmojiRule(ParseRule):
"""示例第三方规则:替换表情符号"""
def match(self, line, event,tab_time, arg_list,async_def_list) -> bool:
return re.search(r'#\w+#', line) is not None
def process(self, line, event,tab_time, arg_list,async_def_list) -> str:
line = line.replace('#smile#', '😊')
line = line.replace('#angry#', '😠')
return f'{line}', tab_time
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_ciku-0.1.5.tar.gz.
File metadata
- Download URL: nonebot_plugin_ciku-0.1.5.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abe71d32ebe614da6603927293d5cef2f6375b04d1a017b27a21d5695acc9e17
|
|
| MD5 |
001e5bf58df342ca9d5be77433776e9d
|
|
| BLAKE2b-256 |
470940f189de97a3ea828950d981c38ab7e4d3d045e884e62181940303006d55
|
File details
Details for the file nonebot_plugin_ciku-0.1.5-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_ciku-0.1.5-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60e4a2ea5e37db8462c10dab9c7ebdfd5e2cf96c953f22ef49dddb2f83a637f6
|
|
| MD5 |
44084952b2d5586fa4c1019e88222b87
|
|
| BLAKE2b-256 |
88fa720807ec30e8001d9547697696928551e788dd028da82ff7dc57f1d44294
|