Skip to content

[Bug?]: 事件上报的时间戳和 get_msg 返回的时间戳不一致 #897

@su226

Description

@su226

请确保您已阅读以上注意事项,并勾选下方的确认框。

  • 我已经仔细阅读上述内容
  • 我已经使用 最新构建 测试过,问题依旧存在。
  • 我已经在 Issue Tracker 中找过我要提出的问题,没有找到相同问题的ISSUE。
  • 我已知晓并同意,此处仅用于汇报程序中存在的问题。若这个 Issue 是关于其他非程序本身问题,则我的 Issue 可能会被无条件自动关闭或/并锁定。(其它疑问请考虑加入TG群询问或在discussions中提问)

Lagrange项目

OneBot

所使用/依赖的Lagrange项目对应的commit

1968eac

运行环境

Linux

运行架构

x64

连接方式

正向 WebSocket

重现步骤

用消息事件上报的 message_id 调用 get_msg,比较事件上报的 time 和 get_msg 返回的 time

期望的结果是什么?

两个时间戳相同

实际的结果是什么?

向机器人发送消息“test”,对应消息事件上报的时间戳为 1758257396(2025-09-19 12:49:56,正确),get_msg 返回的时间戳为 1758228596(2025-09-19 04:49:56,错误)

简单的复现代码/链接(可选)

# 复现代码使用 NoneBot2 编写
from datetime import datetime

import nonebot
from nonebot.adapters.onebot.v11 import Bot, MessageEvent

test = nonebot.on_regex("^test$")


@test.handle()
async def _(bot: Bot, event: MessageEvent) -> None:
    msg = await bot.get_msg(message_id=event.message_id)
    time_event = event.time
    time_get_msg = msg["time"]
    print(time_event, datetime.fromtimestamp(time_event))
    print(time_get_msg, datetime.fromtimestamp(time_get_msg))

Trace 级别日志记录(可选)

https://gist.github.com/su226/4c072aea9e44f13181d97eecb7335268
创建 issue 时提示“Field can not be longer than 65536 characters”,无法直接贴在这里

补充说明(可选)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug?Maybe it's a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions