koishi-plugin-proactive-chatluna
v0.1.0
Published
A companion plugin for koishi-plugin-chatluna that enables proactive, persona-driven chats at random intervals.
Maintainers
Readme
koishi-plugin-proactive-chatluna
让 Chatluna 的 Persona 在随机时间主动开聊。
安装
- 在 Koishi 环境中安装并启用
koishi-plugin-chatluna。 - 将本插件发布到 npm 或在本地打包后放入 Koishi 插件目录。
本地构建:
npm install
npm run build构建完成后将生成 dist/,Koishi 将从 dist/index.js 载入。
配置项
enabled: 是否启用(默认true)。targets: 目标频道数组,每项:{ platform: string, channelId: string }。minInterval/maxInterval: 间隔范围(分钟)。personaId: Chatluna Persona ID(必填)。actionPrompt: 行动指令,支持占位符[时间](清晨/上午/中午/下午/晚上/深夜)。
工作原理
- 每个目标频道拥有独立随机计时器。
- 触发时创建合成会话(包含
platform/selfId/channelId),调用ctx.chatluna.chat(session, { persona })。 - 从返回值提取文本后,通过相应
bot.sendMessage(channelId, text)主动发言。 - 插件卸载/重载时清理所有计时器,避免内存泄漏与误发。
