NapNeko / NapCatQQ

现代化的基于 NTQQ 的 Bot 协议端实现
https://napcat.napneko.icu
Other
2.69k stars 197 forks source link

[BUG] 无法基于onebot v11构造合并转发消息 #236

Closed Mr-qing233 closed 3 months ago

Mr-qing233 commented 3 months ago

系统版本

Windows 11 专业版 22631

QQNT 版本

9.9.12-26466

NapCat 版本

1.8.6

OneBot 客户端

nonebot-adapter-onebot==2.4.4

发生了什么?

仅能通过已有的合并转发消息获取id,再通过以下格式发送嵌套的合并转发消息。并且合并转发消息id会在一定时间或者get_forward_msg()操作后失效

{
    "type": "node",
    "data": {
        "id": "10001000"
    }
}

e434d4a4-e463-4372-aa8a-19790d321b9a

image

而如onebot文档中格式无法构造合并转发消息。使用node的CQ码也是相同错误。

{
    "type": "node",
    "data": {
        "user_id": "10001000",
        "nickname": "某人",
        "content": [
            {"type": "face", "data": {"id": "123"}},
            {"type": "text", "data": {"text": "哈喽~"}}
        ]
    }
}

QQ20240810-213002

napcat报以下错误

2024-08-10 21:29:46 [ERROR] Gin2(2726219668) | constructMessage error:  Error: Timeout: NTEvent EventName:NodeIKernelProfileService/getUserDetailInfoWithBizInfo ListenerName:NodeIKernelProfileListener/onProfileDetailInfoChanged EventRet:
{
    "result": 30008,
    "errMsg": "kReqUinNil"
}

    at Timeout.databack [as _onTimeout] (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:9892:18)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
2024-08-10 21:29:51 [ERROR] Gin2(2726219668) | 发生错误 Error: 转发消息失败,生成节点为空
    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22692:38)
    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22836:26)
    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22282:23)
    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)
    at async WebSocket.<anonymous> (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27872:7)

如何复现

  1. 构造合并转发消息
  2. 使用 bot.send_group_msg() 发送

期望的结果?

应该正常发送单层合并转发消息

NapCat 运行日志

2024-08-10 21:29:41 [INFO] Gin2(2726219668) | 群[琴酒。、Gin、Gin2(684198023)] 琴酒。(2638353426): /forward 
2024-08-10 21:29:41 [DEBUG] Gin2(2726219668) | 收到新消息 {"msgId":"7475719489373902813","msgRandom":"65030193","msgSeq":"0","cntSeq":"0","chatType":1,"msgType":5,"subMsgType":15,"sendType":3,"senderUid":"","peerUid":"u_W5VwObQpQ-j_zuz1LDAI6Q","channelId":"","guildId":"","guildCode":"0","fromUid":"0","fromAppid":"0","msgTime":"1723296580","msgMeta":"0x","sendStatus":2,"sendRemarkName":"","sendMemberName":"","sendNickName":"","guildName":"","channelName":"","elements":[{"elementType":8,"elementId":"7401502452510079449","extBufForUI":"0x","textElement":null,"faceElement":null,"marketFaceElement":null,"replyElement":null,"picElement":null,"pttElement":null,"videoElement":null,"grayTipElement":{"subElementType":15,"revokeElement":null,"proclamationElement":null,"emojiReplyElement":null,"groupElement":null,"buddyElement":null,"feedMsgElement":null,"essenceElement":null,"groupNotifyElement":null,"buddyNotifyElement":null,"xmlElement":null,"fileReceiptElement":null,"localGrayTipElement":null,"blockGrayTipElement":null,"aioOpGrayTipElement":{"operateType":2,"peerUid":"u_W5VwObQpQ-j_zuz1LDAI6Q","fromGrpCodeOfTmpChat":""},"jsonGrayTipElement":null,"walletGrayTipElement":null},"arkElement":null,"fileElement":null,"liveGiftElement":null,"markdownElement":null,"structLongMsgElement":null,"multiForwardMsgElement":null,"giphyElement":null,"walletElement":null,"inlineKeyboardElement":null,"textGiftElement":null,"calendarElement":null,"yoloGameResultElement":null,"avRecordElement":null,"structMsgElement":null,"faceBubbleElement":null,"shareLocationElement":null,"tofuRecordElement":null,"taskTopMsgElement":null,"recommendedMsgElement":null,"actionBarElement":null}],"records":[],"emojiLikesList":[],"commentCnt":"0","directMsgFlag":0,"directMsgMembers":[],"peerName":"","freqLimitInfo":null,"editable":false,"avatarMeta":"","avatarPendant":"","feedId":"","roleId":"0","timeStamp":"0","clientIdentityInfo":null,"isImportMsg":false,"atType":0,"roleType":0,"fromChannelRoleInfo":{"roleId":"0","name":"","color":0},"fromGuildRoleInfo":{"roleId":"0","name":"","color":0},"levelRoleInfo":{"roleId":"0","name":"","color":0},"recallTime":"0","isOnlineMsg":false,"generalFlags":"0x","clientSeq":"0","fileGroupSize":null,"foldingInfo":null,"multiTransInfo":null,"senderUin":"0","peerUin":"0","msgAttrs":{},"anonymousExtInfo":null,"nameType":0,"avatarFlag":0,"extInfoForUI":null,"personalMedal":null,"categoryManage":0,"msgEventInfo":null,"id":238859780} 
2024-08-10 21:29:46 [ERROR] Gin2(2726219668) | constructMessage error:  Error: Timeout: NTEvent EventName:NodeIKernelProfileService/getUserDetailInfoWithBizInfo ListenerName:NodeIKernelProfileListener/onProfileDetailInfoChanged EventRet:
{
    "result": 30008,
    "errMsg": "kReqUinNil"
}

    at Timeout.databack [as _onTimeout] (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:9892:18)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) 
2024-08-10 21:29:51 [ERROR] Gin2(2726219668) | 发生错误 Error: 转发消息失败,生成节点为空
    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22692:38)
    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22836:26)
    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22282:23)
    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)
    at async WebSocket.<anonymous> (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27872:7) 
2024-08-10 21:29:51 [DEBUG] Gin2(2726219668) | ws 消息上报 ws://localhost:9901/onebot/v11/ws {"status":"failed","retcode":1200,"data":null,"message":"Error: 转发消息失败,生成节点为空\n    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22692:38)\n    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22836:26)\n    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22282:23)\n    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)\n    at async WebSocket.<anonymous> (file:///D:/Wor...","wording":"Error: 转发消息失败,生成节点为空\n    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22692:38)\n    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22836:26)\n    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22282:23)\n    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)\n    at async WebSocket.<anonymous> (file:///D:/Wor...","echo":"1"}

OneBot 客户端运行日志

nonebot.adapters.onebot.v11.exception.ActionFailed: ActionFailed(status='failed', retcode=1200, data=None, message='Error: 转发消息失败,生成节点为空\n    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/n
apcat.mjs:22692:38)\n    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22836:26)\n    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.
mjs:22282:23)\n    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)\n    at async WebSocket.<anonymous> (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:278
72:7)', wording='Error: 转发消息失败,生成节点为空\n    at handleForwardNode (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22692:38)\n    at async SendGroupMsg._handle (file:///D:/Work/workspace/python/NapCat.win
32.x64/napcat.mjs:22836:26)\n    at async SendGroupMsg.websocketHandle (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:22282:23)\n    at async ReverseWebsocket.onmessage (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27832:28)\n    at async WebSocket.<anonymous> (file:///D:/Work/workspace/python/NapCat.win32.x64/napcat.mjs:27872:7)', echo='1')
MliKiowa commented 3 months ago

试试最新版本呢

Mr-qing233 commented 3 months ago

已更新,报错信息跟前文是一致的

使用以下格式时

@t_forward.handle()
async def handle_forward(
        bot: Bot,
        event: Event,
        msg: MessageEvent,
        matcher: Matcher,
        args: Message = CommandArg()
):
    msg = [
        {
            "type": "node",
            "data": {
                "uin": "263****426",
                "name": "**",
                "content": [
                    {"type": "text", "data": {"id": "956033642"}},
                ]
            }
        }
    ]
    await bot.send_group_msg(group_id=event.group_id, message=msg)

会有以下报错

2

2024-08-12 20:57:32 [INFO] Gin2(2726219668) | 接收 <- 群聊 (群 684198023 的 2638353426) /forward
2024-08-12 20:57:32 [INFO] Gin2(2726219668) | 接收 <- 私聊 (0) [灰条消息]
2024-08-12 20:57:37 [ERROR] Gin2(2726219668) | constructMessage error:  Error: Timeout: NTEvent EventName:NodeIKernelProfileService/fetchUserDetailInfo ListenerName:NodeIKernelProfileListener/onUserDetailInfoChanged EventRet:
{
    "result": 30008,
    "errMsg": "kReqUinNil",
    "source": 1,
    "detail": {}
}

    at Timeout.databack [as _onTimeout] (file:///D:/Work/workspace/python/NapCat.Shell/napcat.mjs:1120:18)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

并且经测试若合并转发内容为合并转发与普通消息混合,合并转发的消息可以正常发出,普通消息会有上述报错。

目前暂时解决方案是使用SAA插件,将消息转为插件的消息格式

MliKiowa commented 3 months ago

消息结构是错的

MliKiowa commented 3 months ago

node节点 content里面是标准ob11message

Mr-qing233 commented 3 months ago

好的谢谢,已解决