Skip to content

[Bug] 钉钉引用消息的文本及图片内容未被完整解析 #9463

Description

@chinatsu1124

What happened / 发生了什么

在钉钉群聊中,用户使用“引用回复”向机器人提问时,AstrBot 只能读取用户新输入的正文,无法完整读取被引用消息的文本或图片内容。

钉钉当前的机器人回调会把引用信息放在 text.isReplyMsgtext.repliedMsg 中。repliedMsg 可能是普通文本、单张图片或包含图片的富文本;但钉钉适配器此前只读取 message.text.content,没有将引用内容转换为 AstrBot 的 Reply 消息组件,因此引用上下文在进入 LLM 前丢失。

对于引用图片,仅生成 [Image] 文本占位也不够。适配器需要使用引用负载中的 downloadCode 和当前回调中的 robotCode 下载媒体,并将得到的 Image 组件放入 Reply.chain,模型才能实际接收图片。

脱敏后的文本引用回调结构:

{
  "msgtype": "text",
  "msgId": "current-message-id",
  "robotCode": "robot-code",
  "text": {
    "content": "你能回答这个问题么",
    "isReplyMsg": true,
    "repliedMsg": {
      "msgType": "text",
      "msgId": "quoted-message-id",
      "senderId": "quoted-sender-id",
      "senderNick": "Quoted User",
      "createdAt": 1785405000000,
      "content": {
        "text": "这个产品目前接入了哪些模型?"
      }
    }
  }
}

脱敏后的图片引用核心结构:

{
  "msgtype": "text",
  "robotCode": "robot-code",
  "text": {
    "content": "这张图片是什么问题?",
    "isReplyMsg": true,
    "repliedMsg": {
      "msgType": "picture",
      "msgId": "quoted-picture-message-id",
      "content": {
        "downloadCode": "quoted-picture-download-code"
      }
    }
  }
}

富文本引用中的图片位于 repliedMsg.content.richText,图片段同样携带 downloadCode

当前转换结果只包含用户新输入的正文,例如:

[At:bot] 这张图片是什么问题?

预期转换结果应包含:

  • Reply 组件以及被引用文本、发送者、时间和消息 ID;
  • 单图引用对应的真实 Image 组件;
  • 富文本引用中按原顺序排列的 PlainImage 组件;
  • 图片下载信息缺失或下载失败时保留可读占位,不应丢弃整个引用。

Reproduce / 如何复现?

  1. 配置并启动 AstrBot 内置钉钉 Stream 机器人适配器。
  2. 在钉钉群聊中找到一条普通文本、图片或包含图片的富文本消息。
  3. 对该消息使用钉钉“引用回复”,在回复中 @ 机器人并提出问题。
  4. 查看 AstrBot Debug 日志或模型收到的消息上下文。
  5. 可以看到回调中存在 text.isReplyMsg=truetext.repliedMsg,但未修复版本的消息链缺少完整的 Reply 文本或图片内容。

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商和消息平台适配器

  • AstrBot: v4.26.8
  • 部署方式: Linux 源码部署(systemd)
  • 消息平台: 内置 DingTalk / 钉钉 Stream 适配器
  • Provider: 与 Provider 无关,问题发生在消息进入 LLM 前的平台消息转换阶段

OS

Linux

Logs / 报错日志

该问题通常不会抛出异常。Debug 回调中可以看到引用字段,但转换后的消息链缺少引用组件或只保留图片占位:

[Core] [DBUG] [dingtalk.dingtalk_adapter]: dingtalk: {
  "msgtype": "text",
  "text": {
    "content": "这张图片是什么问题?",
    "isReplyMsg": true,
    "repliedMsg": {
      "msgType": "picture",
      "msgId": "quoted-picture-message-id",
      "content": {
        "downloadCode": "quoted-picture-download-code"
      }
    }
  }
}

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformThe bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions