Skip to content

feat: add messageBuilder module with comprehensive message handling - #1

Open
xxtg666 wants to merge 1 commit into
mainfrom
qbotwire_message_builder_modal
Open

xxtg666 wants to merge 1 commit into
mainfrom
qbotwire_message_builder_modal

Conversation

@xxtg666

@xxtg666 xxtg666 commented Nov 11, 2026

Copy link
Copy Markdown
Member

新增与修改

消息构造与解析核心 — messageBuilder.ts

detectMessageScene:根据接口路径自动识别 群聊 / 单聊 (v2) 与 频道 / 频道私信 (guild) 两套协议结构,也可手动切换。
parseMessageDraft:打开弹窗时自动反序列化当前请求体 JSON 回填表单,并保留未知自定义顶层字段;若当前请求体非消息 JSON 则给出覆盖提示而不污染新报文。
buildMessagePayload / validateMessageDraft:支持 5 类消息(纯文本 0、Markdown 原生与 custom_template_id 模板 2、富媒体 file_info 7 / 频道 image、Ark 模板卡片 3 含 23/24/37 预设与 obj_kv 列表、Embed 卡片 4)、内嵌按钮 keyboard(按钮模板 ID 与最多 5×5 自定义按钮网格、样式、跳转/回调/指令动作、权限与指定用户/身份组)、被动回复(msg_id / event_id / msg_seq,主动消息自动省略)及引用回复 message_reference,并自动清理互斥字段与输出实时诊断提示。
extractReplyCandidates:从网关最近事件流提取可回复的 msg_id 与 event_id。

消息构造器弹窗组件 — MessageBuilderModal.vue

双栏布局:左侧交互式表单(支持复用 OpenIdInsertModal.vue 在光标处插入 <@!OpenID> 提及或为按钮选取指定可点击用户、一键从最近网关事件填入 msg_id / event_id),右侧固定展示带语法高亮的实时 JSON 预览、一键复制与字段校验提示;支持 Ctrl+Enter 快速回填。

编辑器接入与弹窗栈细节

RequestEditor.vue:在「请求体」操作栏新增「消息构造器」入口,确认后将格式化后的 JSON 写入当前请求标签页。
Modal.vue & SendPage.vue:为多层嵌套弹窗维护栈顶 Escape 关闭顺序(在内层选择 OpenID 按 Escape 不会误关外层构造器),并在弹窗打开时屏蔽底层页面的 Ctrl+Enter 直接发送快捷键。
补充单元测试 messageBuilder.test.ts、MessageBuilderModal.test.ts 及 README.md 功能说明。

…nd testing

- Implemented messageBuilder.ts to handle message creation, parsing, and validation for both v2 and guild API scenes.
- Added functions for building various message types including text, markdown, media, ark, and embed.
- Created utility functions for keyboard button management and reply candidate extraction.
- Developed unit tests for messageBuilder functionalities in messageBuilder.test.ts, covering detection of message scenes, payload building, draft parsing, and validation.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 14:54

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants