OneBot适配器在sendGroupMsg时返回1200错误代码求助!

OneBot sendGroupMsg 1200 错误分析与求助

问题描述

在使用 OneBot 发送群消息 (sendGroupMsg) 时,随机性 触发 retcode: 1200 错误。当前观察到的触发条件包括:

  1. 发送了图片(暂不确定是否为主要原因)。
  2. 报错后短时间内再次发送消息仍然报错

即便已经尝试在发送请求前加入 1200~1300ms 的随机延迟,该问题依旧存在。
但奇怪的是,一模一样的消息过段时间重新发送就不会复现报错

错误日志

示例如下:

SenderError: Error with request send_group_msg, args: {"group_id":761619215,"message":"[CQ:image,summary=[动画表情],file=file:///C:/dev/koishi-app/memePath/%E5%BE%AE%E7%AC%91.jpg,sub_type=1]"}, retcode: 1200
    at _Internal._get (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:119:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async _Internal.<computed> [as sendGroupMsg] (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:162:20)
    at async sendReply (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:223:9)
    at async handleAIResponse (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:154:7)
    at async executeTriggerTask (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:43:5)
    at async setTimerTrigger (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:28:21)

SenderError: Error with request send_group_msg, args: {"group_id":761619215,"message":"[CQ:image,summary=&#91;动画表情&#93;,file=file:///C:/dev/koishi-app/memePath/%E8%AE%A4%E6%80%82.jpg,sub_type=1]"}, retcode: 1200
    at _Internal._get (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:119:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async _Internal.<computed> [as sendGroupMsg] (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:162:20)
    at async sendReply (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:223:9)
    at async handleAIResponse (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:154:7)
    at async executeTriggerTask (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:43:5)
    at async setTimerTrigger (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:28:21)

SenderError: Error with request send_group_msg, args: {"group_id":761619215,"message":"[扶额]"}, retcode: 1200     
    at _Internal._get (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:119:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async _Internal.<computed> [as sendGroupMsg] (C:\dev\koishi-app\node_modules\koishi-plugin-adapter-onebot\lib\index.js:162:20)     
    at async sendMessage (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:201:7)
    at async sendReply (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:224:9)
    at async handleAIResponse (C:\dev\koishi-app\external\tangxi\src\messageHandler.ts:160:7)  [这里是同一个地方报错,只是位置我给换了]
    at async executeTriggerTask (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:43:5)
    at async setTimerTrigger (C:\dev\koishi-app\external\tangxi\src\timerTrigger.ts:28:21)

完整日志显示,错误发生在 koishi-plugin-adapter-onebotsendGroupMsg 调用过程中,并且多数与图片消息相关。

尝试的解决方案

  • 增加发送间隔(1200ms+随机延迟)→ 无效
  • 查阅 OneBot 文档(未找到 1200 错误码相关信息)

求助

有没有大佬也遇到过这种情况,这个 1200 错误可能是什么原因导致的
目前猜测可能与图片格式、网络情况、或是 napcat 的问题有关系

求助!!

2 个赞

补充一下
代码可能看起来有些奇怪,因为它们原本位于不同位置

拼接后的出错的相关代码:

import fs from 'fs'; // 用于读取本地文件
import * as path from "path";

export const memesPath = './memePath'; // 表情包文件夹
export const memes = fs.readdirSync(memesPath) // 表情包
    .map(file => `[${file.replace(/\.[^/.]+$/, '')}]`)
    .join('/'); // 用空格连接成一行

const imageCQ = `[CQ:image,summary=&#91;动画表情&#93;,file=${pathToFileURL(path.resolve(memesPath, `${msg.content}.jpg`))},sub_type=1]`;
await sendMessage(imageCQ);

const sendMessage = async (content: string) => {
  if (messageInfo.message_type === 'group') {
    await session.onebot.sendGroupMsg(messageInfo.group_id, content);
  } else {
    await session.onebot.sendPrivateMsg(messageInfo.user_id, content);
  }
};
2 个赞

检查onebot协议实现端日志


此类问题成因往往不在koishi侧

2 个赞

找到问题原因了
03-07 23:18:57 [e[31merrore[39m] 糖曦 | 发生错误 Error: EventChecker Failed: NTEvent serviceAndMethod:NodeIKernelMsgService/sendMsg ListenerName:NodeIKernelMsgListener/onMsgInfoListUpdate EventRet:
{
“result”: 299,
“errMsg”: “本群每分钟只能发10条消息\u0000”
}

at OneBotMsgApi.sendMsgWithOb11UniqueId (file:///C:/Users/Administrator/Desktop/NapCat.32793.Shell/versions/9.9.18-32793/resources/app/napcat/napcat.mjs:56755:13)
at async SendGroupMsg._handle (file:///C:/Users/Administrator/Desktop/NapCat.32793.Shell/versions/9.9.18-32793/resources/app/napcat/napcat.mjs:57079:23)
at async SendGroupMsg.websocketHandle (file:///C:/Users/Administrator/Desktop/NapCat.32793.Shell/versions/9.9.18-32793/resources/app/napcat/napcat.mjs:47926:23)
at async OB11WebSocketClientAdapter.handleMessage (file:///C:/Users/Administrator/Desktop/NapCat.32793.Shell/versions/9.9.18-32793/resources/app/napcat/napcat.mjs:48071:21)
2 个赞