koishi-plugin-multi-qa
v1.0.8
Published
Koishi多问答插件 - 支持关键词/正则匹配,可回复文本、图片和文件,提供美观的配置界面
Maintainers
Readme
Koishi 多问答插件 (multi-qa)
支持关键词/正则匹配,可回复文本、图片和文件,支持文件上传存储。
GitHub仓库地址: https://github.com/aynuzbh/koishi-plugin-multi-qa
功能特性
- 支持关键词匹配和正则表达式匹配
- 支持回复文本、图片和文件
- 支持文件上传和本地存储
- 提供可视化配置界面
安装
npm install koishi-plugin-multi-qa
# 或
yarn add koishi-plugin-multi-qa配置说明
规则配置
每个规则支持以下字段:
pattern: 匹配模式(字符串或正则表达式)isRegex: 是否使用正则匹配(默认false)replyType: 回复类型(text/image/file)content: 回复内容或资源路径enabled: 是否启用该规则(默认true)
在Koishi配置文件中添加:
export default {
plugins: {
'multi-qa': {
file: {
uploadPath: 'data/multi-qa', // 本地文件存储路径
useDirectLink: false, // 是否使用直链
directLinkPrefix: '', // 直链URL前缀
},
rules: [
{
pattern: '你好',
isRegex: false,
replyType: 'text',
content: '你好呀!'
},
{
pattern: '^\\d+$',
isRegex: true,
replyType: 'text',
content: '你发送了一个纯数字消息'
},
{
pattern: '图片',
isRegex: false,
replyType: 'image',
content: 'https://example.com/image.png'
}
]
}
}
}使用说明
- 关键词回复:配置规则后,当用户发送匹配的消息时,机器人会自动回复
- 文件上传:用户发送"上传文件"并附带文件,文件将保存到指定目录
- 文件回复:配置file类型的回复规则,content可以是本地路径或URL
注意事项
- 文件存储路径默认是
data/multi-qa - 确保服务器有写入权限
- 正则表达式需要双重转义(如
\\d+) - 完全支持中文文件名上传和下载
- 文件名中的特殊字符会自动替换为下划线
