Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

[Bug?]: 获取群组历史消息记录 参数 count 存在问题 #376

@KomeiDiSanXian

Description

@KomeiDiSanXian

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

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

Lagrange项目

OneBot

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

4de8ac2

运行环境

Windows

运行架构

x64

连接方式

正向 WebSocket

重现步骤

我想要获取某一群聊的历史消息记录来做词云, 有如下的发现

如果bot刚加入群聊,群聊中没有大于count条消息的话,则会报错
请求如下

{
    "action": "get_group_msg_history",
    "params": {
        "group_id": 812312345,
        "count": 30,
        "message_id": 563047330
    }
}

日志

trce: Lagrange.Core.BotContext[0]
      [2024-05-17 08:58:54] [ServiceContext] [DEBUG]: Outgoing SSOFrame: trpc.msg.register_proxy.RegisterProxy.SsoGetGroupMsg
trce: Lagrange.Core.BotContext[0]
      [2024-05-17 08:58:54] [ServiceContext] [DEBUG]: Incoming SSOFrame: trpc.msg.register_proxy.RegisterProxy.SsoGetGroupMsg
warn: Lagrange.OneBot.Core.Operation.OperationService[0]
      Unexpected error encountered while handling message.
      System.Exception: Group member not found
         at Lagrange.OneBot.Message.MessageService.ConvertToGroupMsg(UInt32 uin, MessageChain chain)
         at System.Linq.Enumerable.SelectListIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
         at System.Linq.Enumerable.SelectListIterator`2.ToList()
         at Lagrange.OneBot.Core.Operation.Message.GetGroupMessageHistoryOperation.HandleOperation(BotContext context, JsonNode payload)
         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e)
trce: Lagrange.OneBot.Core.Network.Service.ForwardWSService[13]
      Send(6bfe055a-a0a9-4cc9-87d2-a25f7f25d3c5) {"status":"failed","retcode":200,"data":null,"echo":null}
trce: Lagrange.Core.BotContext[0]
      [2024-05-17 08:58:55] [ServiceContext] [DEBUG]: Outgoing SSOFrame: Heartbeat.Alive

但如果将count修改为18, 则刚好能获取 18 条, 大于18就会出现如上报错

将bot账号踢出群聊不附带消息记录拉入后, 使用同一参数就不能获取聊天记录了, 报错相同

我认为对于这种情况应报错消息记录获取失败而不是报错找不到群成员


如果bot在一个待了很久且活跃的群聊中, 我想要获取上千条消息, 但有如下发现
请求如下

{
    "action": "get_group_msg_history",
    "params": {
        "group_id": 81231230,
        "count": 3000,
        "message_id": -1333010792
    }
}

虽然能够正常拉取到消息, 但是最多只能获取到30条, 小于30能符合预期获取.

文档中并没有对count这一参数能获取的消息数量进行说明.

因此, 我认为需要对此进行提示或者使get_group_msg_history这一api能获取大于30条历史消息记录

看了一下代码感觉这个问题是修不了了, 应该是tx的问题, 但是希望能够对此添加一个说明

期望的结果是什么?

get_group_msg_history 能够获取更多的历史消息

实际的结果是什么?

重现步骤中已经说明

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

No response

日志记录(可选)

No response

补充说明(可选)

我觉得是修不了了, 所以希望能够在文档添加对此的相关的说明

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug?Maybe it's a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions