Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

概述 / Overview

QQ bot now extracts quoted/referenced message content and exposes it as quoted_message_text variable for Dify workflows. Previously, when users replied to messages in QQ, only the new message was sent downstream, losing the quoted context.

Changes:

  • QQ API Layer - Extract message_reference from payloads; fetch original message via get_message_by_id() with context-aware endpoint selection
  • Message Conversion - Create Quote components from referenced messages including text and images; graceful degradation on fetch failures
  • Pipeline Integration - Add quoted_message_text to query variables, available as {{quoted_message_text}} in Dify

Usage in Dify:

# Enable in pipeline config
trigger:
  misc:
    combine-quote-message: true

# Access in Dify workflow
User Prompt: |
  Quoted: {{quoted_message_text}}
  Reply: {{user_message_text}}

Technical Notes:

  • Each quoted message requires 1 API call to QQ servers (subject to rate limits)
  • Validates exactly one context parameter (channel/group/user) provided
  • Supports C2C, GROUP_AT, AT_MESSAGE, DIRECT_MESSAGE event types

更改前后对比截图 / Screenshots

修改前 / Before:

  • QQ引用消息场景:用户回复"已处理"时,Dify仅收到"已处理",丢失被引用的原始消息上下文

修改后 / After:

  • Dify同时收到 quoted_message_text(原始消息内容)和 user_message_text(用户回复),可基于完整上下文生成响应

检查清单 / Checklist

PR 作者完成 / For PR author

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: qq机器人的引用消息无法获取并传递给dify</issue_title>
<issue_description>### 这是一个?

现有功能优化

详细描述

qq 机器人的引用消息再配置流水线发送个dify是,只有对话内容,没有引用消息的原文。建议添加
例:
下图只能发送给dify 的内容是已处理,无法将引用的内容一并发送
Image
</issue_description>

<agent_instructions>可以参考localagent获取quote消息的方式,把引用消息内容取出,以变量的形式写到query,最终传给dify
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 3, 2025 14:13
- Added message_reference property to QQOfficialEvent class
- Implemented get_message_by_id method in QQOfficialClient to fetch referenced messages
- Updated QQOfficialMessageConverter to handle quoted messages and create Quote components
- Modified QQOfficialEventConverter to pass message reference context
- Updated QQOfficialAdapter to properly initialize converters with bot reference
- Added quoted_message_text variable in pipeline preprocessor for Dify workflow integration

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
- Add validation to ensure only one context parameter is provided in get_message_by_id
- Simplify logger check in error handling

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for sending quoted messages to Dify feat: Extract quoted message content for QQ bot and pass to Dify workflows Dec 3, 2025
Copilot AI requested a review from RockChinQ December 3, 2025 14:22
Copilot finished work on behalf of RockChinQ December 3, 2025 14:22
@RockChinQ RockChinQ marked this pull request as ready for review December 3, 2025 14:26
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. eh: Feature enhance: 新功能添加 / add new features IM: qqofficial QQ 官方 API Webhook 适配器相关 / QQ API (Webhook) adapter related m: Platform 机器人管理相关 / Bots management labels Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features IM: qqofficial QQ 官方 API Webhook 适配器相关 / QQ API (Webhook) adapter related m: Platform 机器人管理相关 / Bots management size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: qq机器人的引用消息无法获取并传递给dify

2 participants