feat: add QQ message type selector (Plain Text / Markdown) in IM sett…#99
Merged
Merged
Conversation
…ings Added a "Message Type" (`qq_msg_type`) dropdown in the `/#im` page's QQ configuration panel, allowing users to choose between Plain Text (`msg_type=0`) and Markdown (`msg_type=2`) for QQ bot messages. The selection is persisted via NVS and applied to `cap_im_qq_send_message_chunk` at runtime.
6 tasks
Collaborator
|
sha=de8645137a40b3751f0c26075f2ab9fcab967dd7 |
There was a problem hiding this comment.
Pull request overview
Adds a configurable QQ bot message format setting across the device config stack (Web UI → config API/NVS → runtime QQ capability), allowing users to switch between Plain Text (msg_type=0) and Markdown (msg_type=2) with the appropriate QQ API JSON body structure.
Changes:
- Introduces
qq_msg_typeas an IM config field persisted in NVS and exposed via the config HTTP API. - Adds a “Message Type” dropdown to
/#imfor QQ, with i18n strings (EN/ZH). - Updates QQ message sending to conditionally wrap Markdown payloads under
{"markdown":{"content":...}}whenmsg_type=2.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| components/common/app_claw/include/app_claw.h | Adds qq_msg_type to the runtime claw config struct. |
| components/common/app_claw/app_capabilities.c | Parses qq_msg_type and applies it to the QQ capability at startup. |
| components/claw_capabilities/cap_im_platform/src/cap_im_qq.c | Stores msg_type in QQ state and builds correct JSON for Markdown vs plain text. |
| components/claw_capabilities/cap_im_platform/include/cap_im_qq.h | Exposes cap_im_qq_set_msg_type() in the public header. |
| application/edge_agent/components/http_server/http_server_config_api.c | Exposes qq_msg_type through /api/config under the im group. |
| application/edge_agent/components/http_server/frontend_source/src/pages/ImPage.tsx | Adds QQ message type selector to the IM page form/mappings. |
| application/edge_agent/components/http_server/frontend_source/src/api/client.ts | Extends AppConfig and IM group fields with qq_msg_type. |
| application/edge_agent/components/http_server/frontend_source/src/i18n/en.ts | Adds EN strings for QQ message type labels. |
| application/edge_agent/components/http_server/frontend_source/src/i18n/zh-cn.ts | Adds ZH strings for QQ message type labels. |
| application/edge_agent/components/app_config/include/app_config.h | Adds qq_msg_type to the stored app config struct. |
| application/edge_agent/components/app_config/app_config.c | Adds default + NVS field mapping + claw config copy for qq_msg_type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
58
to
61
| CONFIG_FIELD("im", qq_app_id), | ||
| CONFIG_FIELD("im", qq_app_secret), | ||
| CONFIG_FIELD("im", qq_msg_type), | ||
| CONFIG_FIELD("im", feishu_app_id), |
|
|
||
| int msg_type = 0; | ||
| if (config->qq_msg_type[0]) { | ||
| msg_type = atoi(config->qq_msg_type); |
Comment on lines
+1980
to
+1983
| void cap_im_qq_set_msg_type(int msg_type) | ||
| { | ||
| s_qq.msg_type = msg_type; | ||
| } |
Comment on lines
+549
to
+556
| <SelectInput | ||
| label={t('qqMsgType')} | ||
| value={tab.form.qq_msg_type} | ||
| onChange={(e) => tab.setForm('qq_msg_type', e.currentTarget.value)} | ||
| > | ||
| <option value="0">{t('qqMsgTypePlain')}</option> | ||
| <option value="2">{t('qqMsgTypeMarkdown')}</option> | ||
| </SelectInput> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a "Message Type" (
qq_msg_type) dropdown in the/#impage's QQ configuration panel, allowing users to choose between Plain Text (msg_type=0) and Markdown (msg_type=2) for QQ bot messages. The selection is persisted via NVS and applied tocap_im_qq_send_message_chunkat runtime.Details
Markdown JSON body fix: QQ API requires different JSON structures per
msg_type:msg_type=0(Plain Text):{"content": "text", "msg_type": 0}msg_type=2(Markdown):{"markdown": {"content": "markdown text"}, "msg_type": 2}cap_im_qq_send_message_chunknow conditionally builds the correct body — amarkdownwrapper object formsg_type=2, plaincontentfor all other types.Changes
Backend (C)
components/common/app_claw/include/app_claw.hchar qq_msg_type[8]toapp_claw_config_tapplication/edge_agent/components/app_config/include/app_config.hchar qq_msg_type[8]toapp_config_tapplication/edge_agent/components/app_config/app_config.cAPP_DEFAULT_QQ_MSG_TYPE "0",s_fields[]entry (qq_msg_type/"qq_msg_type"), andapp_config_to_claw()field copyapplication/edge_agent/components/http_server/http_server_config_api.cCONFIG_FIELD("im", qq_msg_type)toCONFIG_FIELDScomponents/claw_capabilities/cap_im_platform/include/cap_im_qq.hcap_im_qq_set_msg_type(int msg_type)declarationcomponents/claw_capabilities/cap_im_platform/src/cap_im_qq.cint msg_typetocap_im_qq_state_t(init0), implementedcap_im_qq_set_msg_type(), changedsend_message_chunkto uses_qq.msg_typeinstead of hardcoded0; conditionally buildmarkdownwrapper formsg_type=2components/common/app_claw/app_capabilities.cconfig->qq_msg_typeand callcap_im_qq_set_msg_type(); added#include <stdlib.h>foratoiFrontend (TypeScript/TSX)
frontend_source/src/api/client.tsqq_msg_type: stringtoAppConfigtype andGROUP_FIELDS.imfrontend_source/src/pages/ImPage.tsxqq_msg_typetoImForm,toForm/fromFormmappings; added<SelectInput>dropdown with Plain Text (0) and Markdown (2) options in the QQ config panel; importedSelectInputfromFormFieldfrontend_source/src/i18n/en.tsqqMsgType,qqMsgTypePlain,qqMsgTypeMarkdownkeysfrontend_source/src/i18n/zh-cn.tsqqMsgType("消息类型"),qqMsgTypePlain("纯文本"),qqMsgTypeMarkdownkeysRelated
#47
Issues with #47
If the message type is set to 2 directly, it will cause the QQ and TIM desktop clients to be unable to display messages correctly:
Testing
/#im, expand QQ panel.msg_type: 2withmarkdownwrapper.msg_type: 0withcontentfield.Checklist
Before submitting a Pull Request, please ensure the following: