Skip to content

feat: add QQ message type selector (Plain Text / Markdown) in IM sett…#99

Merged
wujiangang merged 1 commit into
espressif:masterfrom
Karasukaigan:qq-msg-type
May 21, 2026
Merged

feat: add QQ message type selector (Plain Text / Markdown) in IM sett…#99
wujiangang merged 1 commit into
espressif:masterfrom
Karasukaigan:qq-msg-type

Conversation

@Karasukaigan

@Karasukaigan Karasukaigan commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

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.

ScreenShot_2026-05-21_143441_347

Details

Markdown JSON body fix: QQ API requires different JSON structures per msg_type:

  • msg_type=0 (Plain Text): {"content": "text", "msg_type": 0}
    ScreenShot_2026-05-21_142628_452
    ScreenShot_2026-05-21_145713_038
  • msg_type=2 (Markdown): {"markdown": {"content": "markdown text"}, "msg_type": 2}
    ScreenShot_2026-05-21_143423_392
    ScreenShot_2026-05-21_145656_211

cap_im_qq_send_message_chunk now conditionally builds the correct body — a markdown wrapper object for msg_type=2, plain content for all other types.

Changes

Backend (C)

File Change
components/common/app_claw/include/app_claw.h Added char qq_msg_type[8] to app_claw_config_t
application/edge_agent/components/app_config/include/app_config.h Added char qq_msg_type[8] to app_config_t
application/edge_agent/components/app_config/app_config.c Added APP_DEFAULT_QQ_MSG_TYPE "0", s_fields[] entry (qq_msg_type / "qq_msg_type"), and app_config_to_claw() field copy
application/edge_agent/components/http_server/http_server_config_api.c Added CONFIG_FIELD("im", qq_msg_type) to CONFIG_FIELDS
components/claw_capabilities/cap_im_platform/include/cap_im_qq.h Added cap_im_qq_set_msg_type(int msg_type) declaration
components/claw_capabilities/cap_im_platform/src/cap_im_qq.c Added int msg_type to cap_im_qq_state_t (init 0), implemented cap_im_qq_set_msg_type(), changed send_message_chunk to use s_qq.msg_type instead of hardcoded 0; conditionally build markdown wrapper for msg_type=2
components/common/app_claw/app_capabilities.c Parse config->qq_msg_type and call cap_im_qq_set_msg_type(); added #include <stdlib.h> for atoi

Frontend (TypeScript/TSX)

File Change
frontend_source/src/api/client.ts Added qq_msg_type: string to AppConfig type and GROUP_FIELDS.im
frontend_source/src/pages/ImPage.tsx Added qq_msg_type to ImForm, toForm/fromForm mappings; added <SelectInput> dropdown with Plain Text (0) and Markdown (2) options in the QQ config panel; imported SelectInput from FormField
frontend_source/src/i18n/en.ts Added qqMsgType, qqMsgTypePlain, qqMsgTypeMarkdown keys
frontend_source/src/i18n/zh-cn.ts Added qqMsgType ("消息类型"), qqMsgTypePlain ("纯文本"), qqMsgTypeMarkdown keys

Related

#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:

ScreenShot_2026-05-21_144632_378

Testing

  1. Navigate to /#im, expand QQ panel.
  2. Verify "Message Type" dropdown appears with "Plain Text" (default) and "Markdown" options.
  3. Save with "Markdown" selected, restart device, send a QQ message — should use msg_type: 2 with markdown wrapper.
  4. Switch back to "Plain Text", save, restart — should use msg_type: 0 with content field.
  5. Verify i18n: switch language to Chinese, dropdown labels should display correctly.

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

…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.
@laride

laride commented May 21, 2026

Copy link
Copy Markdown
Collaborator

sha=de8645137a40b3751f0c26075f2ab9fcab967dd7

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_type as an IM config field persisted in NVS and exposed via the config HTTP API.
  • Adds a “Message Type” dropdown to /#im for QQ, with i18n strings (EN/ZH).
  • Updates QQ message sending to conditionally wrap Markdown payloads under {"markdown":{"content":...}} when msg_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>
@wujiangang wujiangang merged commit af1aca9 into espressif:master May 21, 2026
3 checks passed
@Karasukaigan Karasukaigan deleted the qq-msg-type branch May 21, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR-Sync-Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants