koishi-plugin-mcmod
v0.1.1
Published
Koishi plugin: search mcmod.cn and return mod info
Readme
koishi-plugin-mcmod
Koishi 插件:在 mcmod.cn 上搜索模组并返回结果(支持分页与图片预览)。
安装:
- 将本插件文件夹放入 Koishi 项目的
external目录,例如:
C:\Users\25463\Desktop\friend\koishi\external\koishi-plugin-mcmod- 在 Koishi 项目中安装依赖(进入 Koishi 项目根目录):
npm install node-fetch cheerio @napi-rs/canvas- 在 Koishi 启动脚本中加载插件:
const { App } = require('koishi')
const app = new App({ /* your config */ })
app.plugin(require('./external/koishi-plugin-mcmod'))
app.start()命令:
mcmod <关键词>- 搜索mcmod.cn并返回分页结果。- 翻页:发送
n(下一页)或p(上一页)。 - 选择:发送序号(例如
3)会先以图片方式发送对应页面或用户卡片,再发送对应链接。
Filter 映射(可通过 -t 选项使用):
mod=>filter=1(模组)pack=>filter=2(整合包)data=>filter=3(资料)tutorial=>filter=4(教程)author=>filter=5(作者)user=>filter=6(用户)
注意:
- 插件使用
@napi-rs/canvas,对 Node.js 20/24 支持更好,通常无需额外系统编译依赖。
配置示例:
// 在 Koishi 启动脚本中加载并传入配置
const plugin = require('./external/koishi-plugin-mcmod')
app.plugin(plugin, {
debug: true,
commands: {
mod: ['模组', 'mod'],
data: ['资料'],
user: ['用户']
}
})设置 debug: true 会在控制台输出用于诊断的抓取 URL 和页面片段。
- 如果页面结构改变,解析器可能需要更新选择器。
