Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageChain Source中的时间戳后三位被截断了? #114

Closed
CuteKims opened this issue Dec 16, 2024 · 1 comment
Closed

MessageChain Source中的时间戳后三位被截断了? #114

CuteKims opened this issue Dec 16, 2024 · 1 comment
Labels
question 对错误或其它问题进行提问

Comments

@CuteKims
Copy link

问题描述

机器人方案:LiteLoaderQQNT --> LLOneBot --> Overflow --> mirai-api-http + mirai-ts --> nodejs(机器人业务实现)
情况简单介绍:自Mirai续不上命之后便切换到了现在这套方案,自切换后发现机器人获取到的消息时间戳有问题,消息ID跟以前也对不上。
已经做过简单确认从LLOneBot得到的消息时间戳是正确的,而mirai-ts获取到的MessageChain的Source中time值总是会被截断后三位。
mirai-ts获取到的消息的ID与LLOneBot获取到的是一致的。这可能是OneBot协议与Mirai协议对消息ID的定义不同造成的。

复现

import Mirai from "mirai-ts"

const mirai = new Mirai(SETTINGS)

async function App() {
    await mirai.link(QQ_ID)
    mirai.on
    (
        'message',
        (msg) => console.log(JSON.stringfy(msg))
    )
    mirai.listen()
}

App()

仅截取messageChain:

[
    {
        "type": "Source",
        "id": 1612883938,
        "time": 1734348    /* <--这里的时间戳被截掉了后三位 */
    },
    {
        "type": "Plain",
        "text": "测试"
    }
]

完整对象:

{
    "type": "GroupMessage",
    "messageChain": [
        {
            "type": "Source",
            "id": 1612883938,
            "time": 1734348
        },
        {
            "type": "Plain",
            "text": "测试"
        }
    ],
    "sender": {
        "id": ***,
        "memberName": "CuteKims",
        "specialTitle": "",
        "permission": "MEMBER",
        "joinTimestamp": 0,
        "lastSpeakTimestamp": 0,
        "muteTimeRemaining": 0,
        "group": {
            "id": ***,
            "name": "***",
            "permission": "MEMBER"
        },
        "active": null
    },
    "plain": "测试"
}

附LLOneBot事件上报:

{
    "self_id": ***,
    "user_id": ***,
    "time": 1734348620,    /* <--这里的时间是正确的 */
    "message_id": 1612883938,
    "real_id": 1612883938,
    "message_seq": 1612883938,
    "message_type": "group",
    "sender": {
        "user_id": ***,
        "nickname": "CuteKims",
        "card": "",
        "role": "member",
        "title": ""
    },
    "raw_message": "测试",
    "font": 14,
    "sub_type": "normal",
    "message": [
        {
            "type": "text",
            "data": {
                "text": "测试"
            }
        }
    ],
    "message_format": "array",
    "post_type": "message",
    "group_id": ***
}

Overflow 版本

开发版本7d6c17e

其他组件版本

Mirai console 2.16.0
LLOneBot v4.4.3
mirai-api-http 2.10.0

系统日志

2024-12-16 19:30:00 I/main: Starting mirai-console...
2024-12-16 19:30:00 I/main: 

===================================[ Mirai console 2.16.0 ]===================================
 __       __ __                   __  ______                                      __
|  \     /  \  \                 |  \/      \                                    |  \
| ▓▓\   /  ▓▓\▓▓ ______   ______  \▓▓  ▓▓▓▓▓▓\ ______  _______   _______  ______ | ▓▓ ______
| ▓▓▓\ /  ▓▓▓  \/      \ |      \|  \ ▓▓   \▓▓/      \|       \ /       \/      \| ▓▓/      \
| ▓▓▓▓\  ▓▓▓▓ ▓▓  ▓▓▓▓▓▓\ \▓▓▓▓▓▓\ ▓▓ ▓▓     |  ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\  ▓▓▓▓▓▓▓  ▓▓▓▓▓▓\ ▓▓  ▓▓▓▓▓▓\
| ▓▓\▓▓ ▓▓ ▓▓ ▓▓ ▓▓   \▓▓/      ▓▓ ▓▓ ▓▓   __| ▓▓  | ▓▓ ▓▓  | ▓▓\▓▓    \| ▓▓  | ▓▓ ▓▓ ▓▓    ▓▓
| ▓▓ \▓▓▓| ▓▓ ▓▓ ▓▓     |  ▓▓▓▓▓▓▓ ▓▓ ▓▓__/  \ ▓▓__/ ▓▓ ▓▓  | ▓▓_\▓▓▓▓▓▓\ ▓▓__/ ▓▓ ▓▓ ▓▓▓▓▓▓▓▓
| ▓▓  \▓ | ▓▓ ▓▓ ▓▓      \▓▓    ▓▓ ▓▓\▓▓    ▓▓\▓▓    ▓▓ ▓▓  | ▓▓       ▓▓\▓▓    ▓▓ ▓▓\▓▓     \
 \▓▓      \▓▓\▓▓\▓▓       \▓▓▓▓▓▓▓\▓▓ \▓▓▓▓▓▓  \▓▓▓▓▓▓ \▓▓   \▓▓\▓▓▓▓▓▓▓  \▓▓▓▓▓▓ \▓▓ \▓▓▓▓▓▓▓


2024-12-16 19:30:00 I/main: Backend: version 2.16.0, built on 2023-10-20 06:28:10.
2024-12-16 19:30:00 I/main: Frontend Terminal: version 2.16.0, provided by Mamoe Technologies
2024-12-16 19:30:00 I/main: Welcome to visit https://mirai.mamoe.net/
2024-12-16 19:30:02 I/plugin: Successfully loaded plugin mirai-api-http v2.10.0
2024-12-16 19:30:02 I/main: Prepared built-in commands: autoLogin, help, login, logout, permission, status, stop
2024-12-16 19:30:02 W/mirai-api-http: USING INITIAL KEY, please edit the key
2024-12-16 19:30:02 I/Mirai HTTP API: ********************************************************
2024-12-16 19:30:02 I/MahKtorAdapter[http]: Autoreload is disabled because the development mode is off.
2024-12-16 19:30:03 I/MahKtorAdapter[http]: Application started in 0.409 seconds.
2024-12-16 19:30:03 I/MahKtorAdapter[http]: Responding at http://192.168.0.2:8080
2024-12-16 19:30:03 I/http adapter: >>> [http adapter] is listening at http://192.168.0.2:8080
2024-12-16 19:30:03 I/Mirai HTTP API: Http api server is running with verifyKey: INITKEYBemaL4HO
2024-12-16 19:30:03 I/Mirai HTTP API: adaptors: [http]
2024-12-16 19:30:03 I/Mirai HTTP API: ********************************************************
2024-12-16 19:30:03 I/main: 3 plugin(s) enabled.
2024-12-16 19:30:03 I/main: mirai-console started successfully.
2024-12-16 19:30:03 I/Onebot: Overflow v1.0.0.533-7d6c17e-SNAPSHOT.533 正在运行
2024-12-16 19:30:03 I/Onebot: 连接到 WebSocket: ws://127.0.0.1:3001
2024-12-16 19:30:03 I/Onebot: ▌ 已连接到服务器 ┈━═☆
2024-12-16 19:30:03 I/Onebot: 协议端版本信息
{
  "app_name": "LLOneBot",
  "protocol_version": "v11",
  "app_version": "4.4.3"
}
2024-12-16 19:30:03 V/Bot.***: 8 friends loaded.
2024-12-16 19:30:03 V/Bot.***: 3 groups loaded.
2024-12-16 19:30:03 V/Bot.***: Event: BotOnlineEvent(bot=Bot(***))
2024-12-16 19:30:20 V/Bot.***: [***(***)] CuteKims(***) -> 测试

网络日志

以下是部分测试用消息的网络日志。

2024-12-16 18:27:04 D/Onebot: [Recv] <-- {"self_id":***,"user_id":***,"time":1734344824,"message_id":110280450,"real_id":110280450,"message_seq":110280450,"message_type":"group","sender":{"user_id":***,"nickname":"CuteKims","card":"","role":"member","title":""},"raw_message":"测试","font":14,"sub_type":"normal","message":[{"type":"text","data":{"text":"测试"}}],"message_format":"array","post_type":"message","group_id":***}
2024-12-16 18:27:46 D/Onebot: [Recv] <-- {"self_id":***,"user_id":***,"time":1734344866,"message_id":1076185038,"real_id":1076185038,"message_seq":1076185038,"message_type":"group","sender":{"user_id":***,"nickname":"***","card":"","role":"owner","title":""},"raw_message":"测试","font":14,"sub_type":"normal","message":[{"type":"text","data":{"text":"测试"}}],"message_format":"array","post_type":"message","group_id":***}
2024-12-16 18:31:35 D/Onebot: [Recv] <-- {"self_id":***,"user_id":***,"time":1734345095,"message_id":1266429438,"real_id":1266429438,"message_seq":1266429438,"message_type":"group","sender":{"user_id":***,"nickname":"***","card":"","role":"member","title":""},"raw_message":"测试","font":14,"sub_type":"normal","message":[{"type":"text","data":{"text":"测试"}}],"message_format":"array","post_type":"message","group_id":***}
2024-12-16 18:43:44 D/Onebot: [Recv] <-- {"self_id":***,"user_id":***,"time":1734345823,"message_id":871595776,"real_id":871595776,"message_seq":871595776,"message_type":"group","sender":{"user_id":***,"nickname":"***","card":"","role":"member","title":""},"raw_message":"测试","font":14,"sub_type":"normal","message":[{"type":"text","data":{"text":"测试"}}],"message_format":"array","post_type":"message","group_id":***}
2024-12-16 18:44:41 D/Onebot: [Recv] <-- {"self_id":***,"user_id":***,"time":1734345881,"message_id":2138722604,"real_id":2138722604,"message_seq":2138722604,"message_type":"group","sender":{"user_id":***,"nickname":"CuteKims","card":"","role":"member","title":""},"raw_message":"别测了先 还没修好 还有bug","font":14,"sub_type":"normal","message":[{"type":"text","data":{"text":"别测了先 还没修好 还有bug"}}],"message_format":"array","post_type":"message","group_id":***}


### 补充信息

目前仅能确定问题可能出在mirai-api-http/mirai-ts/overflow这三者之间,所以可能问题并不在overflow这边。不过我在任何项目Issue中都还没有发现与此相似的问题,加上这个问题是换用overflow之后出现的,所以选择优先提交到这边来。

如果有事实错误请指出后轻喷 谢谢
@CuteKims CuteKims added the question 对错误或其它问题进行提问 label Dec 16, 2024
@MrXiaoM
Copy link
Owner

MrXiaoM commented Dec 17, 2024

原因是 Overflow 将时间戳认为是毫秒类型的来处理,未判定类型的时间戳。
也好解决,按毫秒判断时间在2000年前的时间(< 946656000000),给解析成秒就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 对错误或其它问题进行提问
Projects
None yet
Development

No branches or pull requests

2 participants