MrXiaoM / Overflow

替换 mirai 实现为 Onebot 以进行无缝迁移
https://mirai.mrxiaom.top
GNU Affero General Public License v3.0
346 stars 24 forks source link

cn.evolvefield.onebot.sdk.response.group.ForwardMsgResp.Node中的message属性不应该为字符串 #107

Closed kagg886 closed 2 weeks ago

kagg886 commented 2 weeks ago

问题描述

这是cn.evolvefield.onebot.sdk.response.group.ForwardMsgResp.Node的定义:

@Data
@AllArgsConstructor
class Node {
    var time = 0
    var messageType = ""
    var messageId = 0
    var realId = 0
    var peerId = 0L
    var targetId = 0L
    var sender: Sender? = null
    var message = ""
}

而根据Onebot V11标准,这里的message属性可以为一个消息数组

复现

Overflow 版本

cf8fec7

其他组件版本

系统日志

网络日志

补充信息

kagg886 commented 2 weeks ago

主要是,合并转发消息需要这个字段。

因调用get_forward_msg开销问题,napcat会在forward的消息类型中添加content参数代表返回。例如:

{
            "type": "forward",
            "data": {
                "id": "7436377759204399490",
                "content": [
                    {
                        "self_id": 3405637452,
                        "user_id": 485184047,
                        "time": 1731415740,
                        "message_id": 726892516,
                        "message_seq": 726892516,
                        "real_id": 726892516,
                        "message_type": "group",
                        "sender": {
                            "user_id": 485184047,
                            "nickname": "上亦下心",
                            "card": ""
                        },
                        "raw_message": "1",
                        "font": 14,
                        "sub_type": "normal",
                        "message": [
                            {
                                "type": "text",
                                "data": {
                                    "text": "1"
                                }
                            }
                        ],
                        "message_format": "array",
                        "post_type": "message",
                        "group_id": 284840486
                    },
                    {
                        "self_id": 3405637452,
                        "user_id": 485184047,
                        "time": 1731415746,
                        "message_id": 1835533293,
                        "message_seq": 1835533293,
                        "real_id": 1835533293,
                        "message_type": "group",
                        "sender": {
                            "user_id": 485184047,
                            "nickname": "上亦下心",
                            "card": ""
                        },
                        "raw_message": "1",
                        "font": 14,
                        "sub_type": "normal",
                        "message": [
                            {
                                "type": "text",
                                "data": {
                                    "text": "1"
                                }
                            }
                        ],
                        "message_format": "array",
                        "post_type": "message",
                        "group_id": 284840486
                    }
                ]
            }
        }

但截止到目前为止我并未在Napcat的日志中寻找到有关于get_forward_msg的返回,因此大概需要对这个地方做一下兼容

MrXiaoM commented 2 weeks ago

有意为之。

@JsonAdapter(ForwardMsgAdapter::class)
class ForwardMsgResp {
    class Node {
        // ...
    }
}

你光看到了Node,没看到它的父类有 JsonAdapter,这个 Adapter 支持了 Lagrange、go-cqhttp、旧 napcat 等多种不同格式的转发消息 node

MrXiaoM commented 2 weeks ago

关于你说的 NapCat 格式兼容问题,应该从这里下手,你找错地方了 https://github.com/MrXiaoM/Overflow/blob/main/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/message/OnebotMessages.kt#L412-L419