koishi-plugin-chat-model 1.0.3 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +9 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -112,6 +112,10 @@ module.exports = CustomAdapter
112
112
 
113
113
  ## 版本更新
114
114
 
115
+ ### v1.0.4
116
+ - 修复了回复后发送多余"true"消息的问题
117
+ - 优化中间件处理逻辑,提高稳定性
118
+
115
119
  ### v1.0.3
116
120
  - 修复使用限制功能无法正常工作的问题
117
121
  - 添加可选的"正在思考中..."消息配置,默认关闭
package/index.js CHANGED
@@ -81,7 +81,9 @@ exports.apply = (ctx, config) => {
81
81
  // 检查用户使用限制
82
82
  if (config.usageLimit?.enabled && !await checkUsageLimit(ctx, session.userId, config)) {
83
83
  await session.send('今日对话次数已达上限,请明天再来')
84
- return true
84
+ // 设置标记但不返回true
85
+ session._handled = true
86
+ return
85
87
  }
86
88
 
87
89
  try {
@@ -107,17 +109,20 @@ exports.apply = (ctx, config) => {
107
109
  await updateUsageCount(ctx, session.userId)
108
110
  }
109
111
 
110
- // 标记消息为已处理
111
- return true
112
+ // 标记消息为已处理,但不显式返回true
113
+ session._handled = true
114
+ // 这里不返回任何值,避免"true"被发送出去
112
115
  } catch (error) {
113
116
  ctx.logger.error('处理消息时出错:', error)
114
117
  await session.send(`处理消息时出错: ${error.message}`)
115
- return true
118
+ // 标记已处理但不返回true
119
+ session._handled = true
116
120
  }
117
121
  }, true) // true表示这个中间件应该在所有其他中间件之后执行
118
122
 
119
123
  // 注册清理上下文的命令
120
124
  ctx.command('清除上下文', '清除与AI助手的对话上下文')
125
+ .alias('/清除上下文')
121
126
  .action(async ({ session }) => {
122
127
  await clearUserContext(ctx, session.userId)
123
128
  return '已清除对话上下文'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-chat-model",
3
3
  "description": "在没有命令匹配时自动调用大型语言模型进行对话,支持OpenAI、Claude、Gemini等",
4
- "version": "1.0.3",
4
+ "version": "1.1.3",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
7
7
  "license": "MIT",