@alemonjs/qq-bot 2.1.35 → 2.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -1981
  3. package/lib/config.d.ts +2 -0
  4. package/lib/format.d.ts +4 -1
  5. package/lib/format.js +68 -4
  6. package/lib/framework-actions.d.ts +75 -0
  7. package/lib/framework-actions.js +620 -0
  8. package/lib/framework-events.d.ts +10 -0
  9. package/lib/framework-events.js +182 -0
  10. package/lib/hook.d.ts +16 -12
  11. package/lib/hook.js +5 -9
  12. package/lib/index.d.ts +5 -1
  13. package/lib/index.websoket.js +6 -2
  14. package/lib/message/AUDIO_EVENT.d.ts +20 -0
  15. package/lib/message/AUDIO_EVENT.js +1 -0
  16. package/lib/message/FORUM_EVENT.d.ts +33 -0
  17. package/lib/message/FORUM_EVENT.js +1 -0
  18. package/lib/message/GUILD_AUDIT.d.ts +14 -0
  19. package/lib/message/GUILD_AUDIT.js +1 -0
  20. package/lib/message/INTERACTION_CREATE.d.ts +13 -20
  21. package/lib/message/MESSAGE_CREATE.d.ts +3 -9
  22. package/lib/message/MESSAGE_DELETE.d.ts +15 -1
  23. package/lib/message/group/C2C_MESSAGE_CREATE.d.ts +3 -13
  24. package/lib/message/group/C2C_MSG_RECEIVE.d.ts +1 -1
  25. package/lib/message/group/C2C_MSG_REJECT.d.ts +1 -1
  26. package/lib/message/group/FRIEND_ADD.d.ts +7 -1
  27. package/lib/message/group/FRIEND_DEL.d.ts +4 -1
  28. package/lib/message/group/GROUP_AT_MESSAGE_CREATE.d.ts +6 -27
  29. package/lib/message/group/GROUP_MEMBER_ADD.d.ts +4 -2
  30. package/lib/message/group/GROUP_MEMBER_REMOVE.d.ts +4 -2
  31. package/lib/message/group/GROUP_MESSAGE_CREATE.d.ts +6 -27
  32. package/lib/message/group/GROUP_MSG_RECEIVE.d.ts +1 -1
  33. package/lib/message/group/GROUP_MSG_REJECT.d.ts +1 -1
  34. package/lib/message/group/MESSAGE_AUDIT_PASS.d.ts +2 -0
  35. package/lib/message/group/MESSAGE_AUDIT_REJECT.d.ts +2 -0
  36. package/lib/message/group/SUBSCRIBE_MESSAGE_STATUS.d.ts +17 -0
  37. package/lib/message/group/SUBSCRIBE_MESSAGE_STATUS.js +1 -0
  38. package/lib/register.d.ts +1 -0
  39. package/lib/register.js +279 -115
  40. package/lib/sdk/api.d.ts +93 -14
  41. package/lib/sdk/api.js +241 -45
  42. package/lib/sdk/client.webhook.js +2 -1
  43. package/lib/sdk/client.websoket.js +2 -1
  44. package/lib/sdk/intents.d.ts +1 -0
  45. package/lib/sdk/intents.js +1 -0
  46. package/lib/sdk/message.d.ts +1 -1
  47. package/lib/sdk/message.group.d.ts +4 -2
  48. package/lib/sdk/message.guild.d.ts +19 -0
  49. package/lib/sdk/non-channel-types.d.ts +138 -0
  50. package/lib/sdk/non-channel-types.js +1 -0
  51. package/lib/sdk/registry.js +2 -2
  52. package/lib/sdk/typing.d.ts +13 -1
  53. package/lib/sends.d.ts +3 -3
  54. package/lib/sends.js +57 -71
  55. package/lib/upload.js +13 -37
  56. package/package.json +8 -5
@@ -0,0 +1,182 @@
1
+ import { getIdentity } from "./config.js";
2
+
3
+ //#region src/framework-events.ts
4
+ /** Preserve scoped identities in every author/mention, not only the top-level sender. */
5
+ const normalizeMessageUser = (raw, scope) => {
6
+ const UserId = (scope === "group" ? raw.member_openid : scope === "c2c" ? raw.user_openid : raw.id) || raw.id || "";
7
+ const [IsMaster, UserKey] = getIdentity(UserId);
8
+ return {
9
+ UserId,
10
+ UserKey,
11
+ IsMaster,
12
+ UserName: raw.username,
13
+ IsBot: raw.bot ?? false,
14
+ SourceUserId: raw.id,
15
+ DirectUserId: raw.user_openid,
16
+ MemberId: raw.member_openid,
17
+ UnionId: raw.union_openid,
18
+ AccountId: raw.union_user_account,
19
+ Role: raw.member_role
20
+ };
21
+ };
22
+ const normalizeJoinRequest = (raw, guildId = raw.group_openid) => ({
23
+ id: raw.join_request_id,
24
+ guildId,
25
+ userId: raw.member_openid,
26
+ userName: raw.username,
27
+ unionId: raw.union_openid,
28
+ isBot: raw.bot,
29
+ risk: raw.risk_tips,
30
+ appliedAt: raw.apply_at,
31
+ source: raw.apply_source,
32
+ inviterId: raw.invited_by,
33
+ verification: raw.verify_info && {
34
+ method: raw.verify_info.method,
35
+ message: raw.verify_info.verify_message,
36
+ questions: raw.verify_info.review_qa_list
37
+ },
38
+ approvedByStrategyId: raw.auto_approved?.strategy_id
39
+ });
40
+ const context = (items = []) => Object.fromEntries(items.map((item) => {
41
+ const at = item.indexOf("=");
42
+ return at < 0 ? [item, ""] : [item.slice(0, at), item.slice(at + 1)];
43
+ }));
44
+ const normalizeAttachments = (attachments = []) => attachments.map((item) => ({
45
+ Type: item.content_type === "voice" || item.content_type?.startsWith("audio/") ? "audio" : item.content_type?.startsWith("image/") ? "image" : item.content_type?.startsWith("video/") ? "video" : "file",
46
+ Url: item.url,
47
+ FileId: item.id,
48
+ FileName: item.filename,
49
+ FileSize: item.size,
50
+ MimeType: item.content_type,
51
+ Width: item.width,
52
+ Height: item.height,
53
+ AudioUrl: item.voice_wav_url,
54
+ Transcript: item.asr_refer_text
55
+ }));
56
+ const message = (raw, scope) => {
57
+ const ext = context(raw.message_scene?.ext);
58
+ return {
59
+ type: raw.message_type,
60
+ referenceId: ext.msg_idx,
61
+ replyReferenceId: ext.ref_msg_idx,
62
+ source: raw.message_scene?.source,
63
+ context: ext,
64
+ card: raw.ark_data && {
65
+ type: raw.ark_data.ark_type,
66
+ name: raw.ark_data.ark_name,
67
+ prompt: raw.ark_data.prompt,
68
+ fields: raw.ark_data.fields
69
+ },
70
+ elements: raw.msg_elements?.map((item) => ({
71
+ referenceId: item.msg_idx,
72
+ userId: item.author ? normalizeMessageUser(item.author, scope).UserId : void 0,
73
+ author: item.author && normalizeMessageUser(item.author, scope),
74
+ userName: item.author?.username,
75
+ text: item.content,
76
+ content: message(item, scope),
77
+ attachments: normalizeAttachments(item.attachments)
78
+ }))
79
+ };
80
+ };
81
+ const interactionTypes = {
82
+ 11: "button",
83
+ 12: "menu",
84
+ 13: "feedback",
85
+ 14: "clear-session",
86
+ 15: "story",
87
+ 16: "model",
88
+ 18: "authorization",
89
+ 19: "authorization",
90
+ 20: "authorization-status"
91
+ };
92
+ /** Standard fields expose platform capabilities without business code reading raw QQ data. */
93
+ const normalizeFrameworkEvent = (event, acknowledged = false) => {
94
+ const raw = event.value;
95
+ const tag = "_tag" in event ? String(event._tag) : "";
96
+ if (!raw || typeof raw !== "object") return event;
97
+ const details = {};
98
+ const timestamp = typeof raw.timestamp === "number" ? raw.timestamp * 1e3 : Date.parse(raw.timestamp);
99
+ if (Number.isFinite(timestamp)) details.OccurredAt = timestamp;
100
+ if (raw.author) {
101
+ details.UnionId = raw.author.union_openid;
102
+ details.AccountId = raw.author.union_user_account;
103
+ details.Role = raw.author.member_role;
104
+ }
105
+ if (raw.group_openid) details.Target = {
106
+ scope: "group",
107
+ targetId: raw.group_openid,
108
+ BotId: event.BotId
109
+ };
110
+ else if (/^(C2C_|FRIEND_|SUBSCRIBE_MESSAGE_STATUS|INTERACTION_CREATE_C2C)/.test(tag)) {
111
+ const id = raw.openid || raw.user_openid || raw.author?.user_openid || raw.author?.id;
112
+ if (id) details.Target = {
113
+ scope: "c2c",
114
+ targetId: id,
115
+ BotId: event.BotId
116
+ };
117
+ }
118
+ if (/^(GROUP_MESSAGE_CREATE|GROUP_AT_MESSAGE_CREATE|C2C_MESSAGE_CREATE)$/.test(tag)) {
119
+ const scope = tag.startsWith("GROUP_") ? "group" : "c2c";
120
+ if (raw.author) Object.assign(details, normalizeMessageUser(raw.author, scope));
121
+ details.MessageContent = message(raw, scope);
122
+ details.MessageMentions = raw.mentions?.map((item) => normalizeMessageUser(item, scope)) ?? [];
123
+ details.MessageMedia = normalizeAttachments(raw.attachments);
124
+ }
125
+ if (tag === "GROUP_MEMBER_ADD" || tag === "GROUP_MEMBER_REMOVE") {
126
+ details.MemberId = raw.member_openid;
127
+ details.DirectUserId = raw.user_openid;
128
+ }
129
+ if (tag === "GROUP_JOIN_REQUEST") details.Notice = {
130
+ type: "join-request",
131
+ request: normalizeJoinRequest(raw)
132
+ };
133
+ if (tag === "SUBSCRIBE_MESSAGE_STATUS") details.Notice = {
134
+ type: "subscription",
135
+ subscriptions: raw.result.map((r) => ({
136
+ templateId: r.template_id,
137
+ customTemplateId: r.custom_template_id,
138
+ allowed: r.op === 1,
139
+ subscriptionId: r.subscribe_id,
140
+ subscribedAt: r.subscribe_ts,
141
+ updatedAt: r.update_ts
142
+ }))
143
+ };
144
+ if (/^(C2C|GROUP)_MSG_(RECEIVE|REJECT)$/.test(tag)) details.Notice = {
145
+ type: "message-permission",
146
+ enabled: tag.endsWith("RECEIVE")
147
+ };
148
+ if (tag === "FRIEND_ADD" || tag === "FRIEND_DEL") details.FriendSource = {
149
+ scene: raw.scene,
150
+ data: raw.scene_param,
151
+ code: raw.short_code,
152
+ unionId: raw.author?.union_openid
153
+ };
154
+ if (tag.startsWith("INTERACTION_CREATE")) {
155
+ const r = raw.data?.resolved ?? {};
156
+ details.EventId = raw.event_id || raw.id;
157
+ details.Interaction = {
158
+ type: interactionTypes[raw.type] ?? "unknown",
159
+ buttonId: r.button_id === void 0 ? void 0 : String(r.button_id),
160
+ data: r.button_data,
161
+ featureId: r.feature_id,
162
+ messageId: r.message_id,
163
+ feedback: r.feedback_opt === "LIKE" ? "like" : r.feedback_opt === "UNLIKE" ? "dislike" : void 0,
164
+ checked: r.checked === void 0 ? void 0 : Boolean(r.checked),
165
+ action: r.action,
166
+ authorization: r.authorize_data && {
167
+ scene: r.authorize_data.opt_scene,
168
+ scope: r.authorize_data.scope
169
+ },
170
+ context: context(r.message_scene?.ext),
171
+ requiresAck: raw.type === 11 || raw.type === 12,
172
+ acknowledged
173
+ };
174
+ } else if (!tag.endsWith("MESSAGE_CREATE")) details.EventId = raw.id;
175
+ return {
176
+ ...event,
177
+ ...details
178
+ };
179
+ };
180
+
181
+ //#endregion
182
+ export { normalizeAttachments, normalizeFrameworkEvent, normalizeJoinRequest, normalizeMessageUser };
package/lib/hook.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ import { QQBotAPI } from "./sdk/api.js";
2
+ import { SUBSCRIBE_MESSAGE_STATUS_TYPE } from "./message/group/SUBSCRIBE_MESSAGE_STATUS.js";
3
+ import { GROUP_MEMBER_ADD } from "./message/group/GROUP_MEMBER_ADD.js";
4
+ import { GROUP_MEMBER_REMOVE } from "./message/group/GROUP_MEMBER_REMOVE.js";
1
5
  import { GROUP_AT_MESSAGE_CREATE_TYPE } from "./message/group/GROUP_AT_MESSAGE_CREATE.js";
2
6
  import { GROUP_MESSAGE_CREATE_TYPE } from "./message/group/GROUP_MESSAGE_CREATE.js";
3
- import { QQBotAPI } from "./sdk/api.js";
4
7
  import { AT_MESSAGE_CREATE_TYPE } from "./message/AT_MESSAGE_CREATE.js";
5
8
  import { INTERACTION_CREATE_TYPE } from "./message/INTERACTION_CREATE.js";
6
9
  import { DIRECT_MESSAGE_CREATE_TYPE } from "./message/DIRECT_MESSAGE_CREATE.js";
@@ -31,6 +34,10 @@ import { C2C_MSG_REJECT_TYPE } from "./message/group/C2C_MSG_REJECT.js";
31
34
  import { MESSAGE_AUDIT_PASS_TYPE } from "./message/group/MESSAGE_AUDIT_PASS.js";
32
35
  import { MESSAGE_AUDIT_REJECT_TYPE } from "./message/group/MESSAGE_AUDIT_REJECT.js";
33
36
  import { GROUP_JOIN_REQUEST_TYPE } from "./message/group/GROUP_JOIN_REQUEST.js";
37
+ import { GUILD_AUDIT_TYPE } from "./message/GUILD_AUDIT.js";
38
+ import { FORUM_EVENT_TYPE } from "./message/FORUM_EVENT.js";
39
+ import { AUDIO_EVENT_TYPE, AUDIO_OR_LIVE_CHANNEL_MEMBER_EVENT_TYPE } from "./message/AUDIO_EVENT.js";
40
+ import { READY_TYPE } from "./message/READY.js";
34
41
  import { EventKeys, Events } from "alemonjs";
35
42
  //#region src/hook.d.ts
36
43
  type MAP = {
@@ -49,31 +56,28 @@ type MAP = {
49
56
  'guild.join': GUILD_CREATE_TYPE | GROUP_ADD_ROBOT_TYPE;
50
57
  'guild.exit': GUILD_DELETE_TYPE | GROUP_DEL_ROBOT_TYPE;
51
58
  'guild.update': GUILD_UPDATE_TYPE;
52
- 'member.add': GUILD_MEMBER_ADD_TYPE;
53
- 'member.remove': GUILD_MEMBER_REMOVE_TYPE;
59
+ 'member.add': GUILD_MEMBER_ADD_TYPE | GROUP_MEMBER_ADD;
60
+ 'member.remove': GUILD_MEMBER_REMOVE_TYPE | GROUP_MEMBER_REMOVE;
54
61
  'member.ban': undefined;
55
62
  'member.unban': undefined;
56
63
  'member.update': GUILD_MEMBER_UPDATE_TYPE;
57
- 'notice.create': GROUP_MSG_RECEIVE_TYPE | GROUP_MSG_REJECT_TYPE | MESSAGE_AUDIT_PASS_TYPE | MESSAGE_AUDIT_REJECT_TYPE | GROUP_JOIN_REQUEST_TYPE;
64
+ 'notice.create': SUBSCRIBE_MESSAGE_STATUS_TYPE | GROUP_MSG_RECEIVE_TYPE | GROUP_MSG_REJECT_TYPE | MESSAGE_AUDIT_PASS_TYPE | MESSAGE_AUDIT_REJECT_TYPE | GUILD_AUDIT_TYPE | GROUP_JOIN_REQUEST_TYPE | FORUM_EVENT_TYPE | AUDIO_EVENT_TYPE | AUDIO_OR_LIVE_CHANNEL_MEMBER_EVENT_TYPE | READY_TYPE;
58
65
  'private.message.update': undefined;
59
66
  'private.message.delete': DIRECT_MESSAGE_DELETE_TYPE;
60
67
  'private.friend.add': FRIEND_ADD_TYPE;
61
68
  'private.friend.remove': FRIEND_DEL_TYPE;
62
69
  'private.guild.add': undefined;
63
- 'private.notice.create': C2C_MSG_RECEIVE_TYPE | C2C_MSG_REJECT_TYPE;
70
+ 'private.notice.create': C2C_MSG_RECEIVE_TYPE | C2C_MSG_REJECT_TYPE | SUBSCRIBE_MESSAGE_STATUS_TYPE;
64
71
  };
72
+ type EventValues = MAP & { [K in Exclude<EventKeys, keyof MAP>]: unknown; };
73
+ /** 保留完整官方事件数据,不需要 useClient。 */
74
+ declare const useValue: <T extends EventKeys>(event: Events[T]) => readonly [EventValues[T]];
65
75
  /**
66
76
  *
67
77
  * @param event
68
78
  * @returns
69
79
  */
70
- declare const useValue: <T extends EventKeys>(event: Events[T]) => readonly [MAP[T]];
71
- /**
72
- *
73
- * @param event
74
- * @returns
75
- */
76
- declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [QQBotAPI, MAP[T]];
80
+ declare const useClient: <T extends EventKeys>(event: Events[T]) => readonly [QQBotAPI, EventValues[T]];
77
81
  /**
78
82
  * 判断当前模式
79
83
  * @param event
package/lib/hook.js CHANGED
@@ -1,14 +1,10 @@
1
1
  import { QQBotAPI } from "./sdk/api.js";
2
- import { createEventValue, useClient as useClient$1 } from "alemonjs";
2
+ import { useClient as useClient$1 } from "alemonjs";
3
3
 
4
4
  //#region src/hook.ts
5
- /**
6
- *
7
- * @param event
8
- * @returns
9
- */
5
+ /** 保留完整官方事件数据,不需要 useClient。 */
10
6
  const useValue = (event) => {
11
- return [createEventValue(event)];
7
+ return [event.value];
12
8
  };
13
9
  /**
14
10
  *
@@ -17,7 +13,7 @@ const useValue = (event) => {
17
13
  */
18
14
  const useClient = (event) => {
19
15
  const [client] = useClient$1(event, QQBotAPI);
20
- return [client, createEventValue(event)];
16
+ return [client, event.value];
21
17
  };
22
18
  /**
23
19
  * 判断当前模式
@@ -25,7 +21,7 @@ const useClient = (event) => {
25
21
  * @returns
26
22
  */
27
23
  const useMode = (event) => {
28
- const tag = event._tag;
24
+ const tag = "_tag" in event ? event._tag : void 0;
29
25
  let currentMode = "group";
30
26
  if (tag === "GROUP_AT_MESSAGE_CREATE") currentMode = "group";
31
27
  if (tag === "GROUP_MESSAGE_CREATE") currentMode = "group";
package/lib/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
+ import { ApiRequestData, ButtonType, FileType, GlobalMuteRule, GroupAction, JoinApprovalStrategy, JoinRequest, KeyboardType, MarkdownType, MemberMuteState, MessageType, Options, SetMemberMuteState, StreamMessageData, StreamMessageResult, UploadConfig, UploadPart, UploadPartFinishData, UploadPrepareData, UploadPrepareResult, VerifyInfo } from "./sdk/typing.js";
1
2
  import { platform } from "./config.js";
3
+ import { QQBotArkData, QQBotAttachment, QQBotBlacklistUser, QQBotGroupMember, QQBotInteractionResolved, QQBotMenu, QQBotMenuItem, QQBotMessageContent, QQBotMessageElement, QQBotMessageResult, QQBotMessageUser, QQBotPage, QQBotPanel, QQBotPanelCreate, QQBotPanelRecord, QQBotPanelScope } from "./sdk/non-channel-types.js";
2
4
  import { QQBotAPI } from "./sdk/api.js";
3
5
  import { useClient, useMode, useValue } from "./hook.js";
6
+ import { QQBotGroupEventMap } from "./sdk/message.group.js";
7
+ import { QQBotPublicEventMap } from "./sdk/message.public.js";
4
8
  //#region src/index.d.ts
5
9
  declare const _default: () => any;
6
10
  //#endregion
7
- export { QQBotAPI as API, _default as default, platform, useClient, useMode, useValue };
11
+ export { QQBotAPI as API, type ApiRequestData, type ButtonType, type FileType, type GlobalMuteRule, type GroupAction, type JoinApprovalStrategy, type JoinRequest, type KeyboardType, type MarkdownType, type MemberMuteState, type MessageType, type Options, type QQBotArkData, type QQBotAttachment, type QQBotBlacklistUser, type QQBotGroupEventMap, type QQBotGroupMember, type QQBotInteractionResolved, type QQBotMenu, type QQBotMenuItem, type QQBotMessageContent, type QQBotMessageElement, type QQBotMessageResult, type QQBotMessageUser, type QQBotPage, type QQBotPanel, type QQBotPanelCreate, type QQBotPanelRecord, type QQBotPanelScope, type QQBotPublicEventMap, type SetMemberMuteState, type StreamMessageData, type StreamMessageResult, type UploadConfig, type UploadPart, type UploadPartFinishData, type UploadPrepareData, type UploadPrepareResult, type VerifyInfo, _default as default, platform, useClient, useMode, useValue };
@@ -109,7 +109,9 @@ const connectAll = (registry) => {
109
109
  "GUILD_MEMBERS",
110
110
  "GUILD_MESSAGE_REACTIONS",
111
111
  "DIRECT_MESSAGE",
112
- "PUBLIC_GUILD_MESSAGES"
112
+ "PUBLIC_GUILD_MESSAGES",
113
+ "MESSAGE_AUDIT",
114
+ "AUDIO_ACTION"
113
115
  ];
114
116
  const isPrivateIntents = [
115
117
  "GUILDS",
@@ -117,7 +119,9 @@ const connectAll = (registry) => {
117
119
  "GUILD_MESSAGES",
118
120
  "GUILD_MESSAGE_REACTIONS",
119
121
  "DIRECT_MESSAGE",
120
- "FORUMS_EVENT"
122
+ "FORUMS_EVENT",
123
+ "MESSAGE_AUDIT",
124
+ "AUDIO_ACTION"
121
125
  ];
122
126
  const isGroupIntents = ["GROUP_AND_C2C_EVENT", "GROUP_MEMBER_EVENT"];
123
127
  const pubIntents = ["INTERACTION"];
@@ -0,0 +1,20 @@
1
+ //#region src/message/AUDIO_EVENT.d.ts
2
+ /** 音频机器人网关事件(AUDIO_START / FINISH / ON_MIC / OFF_MIC)。 */
3
+ type AUDIO_EVENT_TYPE = {
4
+ channel_id: string;
5
+ guild_id?: string;
6
+ audio_url?: string;
7
+ text?: string;
8
+ status?: 0 | 1 | 2 | 3;
9
+ event_id?: string;
10
+ };
11
+ /** 音视频或直播子频道成员进出事件。 */
12
+ type AUDIO_OR_LIVE_CHANNEL_MEMBER_EVENT_TYPE = {
13
+ guild_id: string;
14
+ channel_id: string;
15
+ /** 2:音视频子频道;5:直播子频道。 */
16
+ channel_type: 2 | 5;
17
+ user_id: string;
18
+ };
19
+ //#endregion
20
+ export { AUDIO_EVENT_TYPE, AUDIO_OR_LIVE_CHANNEL_MEMBER_EVENT_TYPE };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,33 @@
1
+ //#region src/message/FORUM_EVENT.d.ts
2
+ type QQBotForumThread = {
3
+ thread_id: string;
4
+ title?: string;
5
+ content?: string;
6
+ datetime?: string;
7
+ };
8
+ type QQBotForumPost = {
9
+ post_id: string;
10
+ content?: string;
11
+ datetime?: string;
12
+ };
13
+ type QQBotForumReply = {
14
+ reply_id: string;
15
+ content?: string;
16
+ datetime?: string;
17
+ };
18
+ /** 私域论坛网关事件的公共字段。 */
19
+ type FORUM_EVENT_TYPE = {
20
+ guild_id: string;
21
+ channel_id: string;
22
+ author_id: string;
23
+ thread_info?: QQBotForumThread;
24
+ post_info?: QQBotForumPost;
25
+ reply_info?: QQBotForumReply;
26
+ audit_result?: {
27
+ task_id?: string;
28
+ result?: number;
29
+ err_msg?: string;
30
+ };
31
+ };
32
+ //#endregion
33
+ export { FORUM_EVENT_TYPE, QQBotForumPost, QQBotForumReply, QQBotForumThread };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ //#region src/message/GUILD_AUDIT.d.ts
2
+ /** 频道消息审核结果(MESSAGE_AUDIT_PASS / MESSAGE_AUDIT_REJECT)。 */
3
+ type GUILD_AUDIT_TYPE = {
4
+ audit_id: string;
5
+ audit_time: string;
6
+ channel_id?: string;
7
+ guild_id?: string;
8
+ message_id?: string;
9
+ create_time?: string;
10
+ /** 兼容群聊审核事件;频道事件不携带该字段。 */
11
+ group_openid?: string;
12
+ };
13
+ //#endregion
14
+ export { GUILD_AUDIT_TYPE };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,3 +1,4 @@
1
+ import { QQBotInteractionResolved } from "../sdk/non-channel-types.js";
1
2
  //#region src/message/INTERACTION_CREATE.d.ts
2
3
  /**
3
4
  * 交互消息事件 | 按钮消息
@@ -6,13 +7,11 @@
6
7
  */
7
8
  type INTERACTION_CREATE_TYPE = {
8
9
  application_id: string;
9
- chat_type: 1;
10
+ event_id?: string;
11
+ chat_type?: 1;
10
12
  data: {
11
- resolved: {
12
- button_data: string;
13
- button_id: number;
14
- };
15
- type: number;
13
+ type?: number;
14
+ resolved?: QQBotInteractionResolved;
16
15
  };
17
16
  group_member_openid: string;
18
17
  group_openid: string;
@@ -23,13 +22,11 @@ type INTERACTION_CREATE_TYPE = {
23
22
  version: number;
24
23
  } | {
25
24
  application_id: string;
26
- chat_type: 2;
25
+ event_id?: string;
26
+ chat_type?: 2;
27
27
  data: {
28
- resolved: {
29
- button_data: string;
30
- button_id: number;
31
- };
32
- type: number;
28
+ type?: number;
29
+ resolved?: QQBotInteractionResolved;
33
30
  };
34
31
  id: string;
35
32
  scene: 'c2c';
@@ -39,15 +36,11 @@ type INTERACTION_CREATE_TYPE = {
39
36
  version: number;
40
37
  } | {
41
38
  application_id: string;
42
- chat_type: 0;
39
+ event_id?: string;
40
+ chat_type?: 0;
43
41
  data: {
44
- resolved: {
45
- message_id: string;
46
- button_data: string;
47
- button_id: number;
48
- user_id: string;
49
- };
50
- type: number;
42
+ type?: number;
43
+ resolved?: QQBotInteractionResolved;
51
44
  };
52
45
  id: string;
53
46
  scene: 'guild';
@@ -1,12 +1,6 @@
1
+ import { AT_MESSAGE_CREATE_TYPE } from "./AT_MESSAGE_CREATE.js";
1
2
  //#region src/message/MESSAGE_CREATE.d.ts
2
- /**
3
- * *私域*
4
- */
5
- /**
6
- * 频道内的全部消息
7
- * @param event
8
- * @returns
9
- */
10
- type MESSAGE_CREATE_TYPE = any;
3
+ /** 私域全量频道消息与 AT_MESSAGE_CREATE 使用同一 Message 对象。 */
4
+ type MESSAGE_CREATE_TYPE = AT_MESSAGE_CREATE_TYPE;
11
5
  //#endregion
12
6
  export { MESSAGE_CREATE_TYPE };
@@ -7,6 +7,20 @@
7
7
  * @param event
8
8
  * @returns
9
9
  */
10
- type MESSAGE_DELETE_TYPE = any;
10
+ type MESSAGE_DELETE_TYPE = {
11
+ message: {
12
+ id: string;
13
+ channel_id: string;
14
+ guild_id: string;
15
+ author?: {
16
+ id: string;
17
+ username?: string;
18
+ bot?: boolean;
19
+ };
20
+ };
21
+ op_user?: {
22
+ id: string;
23
+ };
24
+ };
11
25
  //#endregion
12
26
  export { MESSAGE_DELETE_TYPE };
@@ -1,17 +1,7 @@
1
+ import { QQBotMessageContent, QQBotMessageUser } from "../../sdk/non-channel-types.js";
1
2
  //#region src/message/group/C2C_MESSAGE_CREATE.d.ts
2
- type C2C_MESSAGE_CREATE_TYPE = {
3
- attachments?: {
4
- id?: string;
5
- url?: string;
6
- content_type?: string;
7
- filename?: string;
8
- size?: number;
9
- }[];
10
- author: {
11
- id: string;
12
- user_openid: string;
13
- username: string;
14
- };
3
+ type C2C_MESSAGE_CREATE_TYPE = QQBotMessageContent & {
4
+ author: QQBotMessageUser;
15
5
  content: string;
16
6
  id: string;
17
7
  timestamp: string;
@@ -8,7 +8,7 @@ type C2C_MSG_RECEIVE_TYPE = {
8
8
  */
9
9
  id?: string;
10
10
  openid: string;
11
- timestamp: string;
11
+ timestamp: number | string;
12
12
  };
13
13
  //#endregion
14
14
  export { C2C_MSG_RECEIVE_TYPE };
@@ -4,7 +4,7 @@
4
4
  */
5
5
  type C2C_MSG_REJECT_TYPE = {
6
6
  openid: string;
7
- timestamp: string;
7
+ timestamp: number | string;
8
8
  };
9
9
  //#endregion
10
10
  export { C2C_MSG_REJECT_TYPE };
@@ -7,8 +7,14 @@ type FRIEND_ADD_TYPE = {
7
7
  * 网关信封事件 ID(SDK 从 payload.id 回填),可用于发送消息时的 event_id 被动回复
8
8
  */
9
9
  id?: string;
10
+ scene?: number;
11
+ scene_param?: string;
12
+ short_code?: string;
13
+ author?: {
14
+ union_openid?: string;
15
+ };
10
16
  openid: string;
11
- timestamp: string;
17
+ timestamp: number | string;
12
18
  };
13
19
  //#endregion
14
20
  export { FRIEND_ADD_TYPE };
@@ -3,8 +3,11 @@
3
3
  * 好友删除
4
4
  */
5
5
  type FRIEND_DEL_TYPE = {
6
+ author?: {
7
+ union_openid?: string;
8
+ };
6
9
  openid: string;
7
- timestamp: string;
10
+ timestamp: number | string;
8
11
  };
9
12
  //#endregion
10
13
  export { FRIEND_DEL_TYPE };
@@ -1,40 +1,19 @@
1
+ import { QQBotMessageContent, QQBotMessageUser } from "../../sdk/non-channel-types.js";
1
2
  //#region src/message/group/GROUP_AT_MESSAGE_CREATE.d.ts
2
3
  /**
3
4
  * 群消息事件 AT 事件
4
5
  */
5
- interface GROUP_AT_MESSAGE_CREATE_TYPE {
6
- attachments?: {
7
- id?: string;
8
- url?: string;
9
- content_type?: string;
10
- filename?: string;
11
- size?: number;
12
- }[];
13
- author: {
14
- bot?: boolean;
15
- id: string;
16
- member_openid: string;
17
- union_openid: string;
18
- username: string;
19
- };
6
+ interface GROUP_AT_MESSAGE_CREATE_TYPE extends QQBotMessageContent {
7
+ author: QQBotMessageUser;
20
8
  content: string;
21
9
  group_openid: string;
22
- group_id: string;
10
+ group_id?: string;
23
11
  id: string;
24
- mentions?: {
25
- bot?: boolean;
26
- id: string;
12
+ mentions?: (QQBotMessageUser & {
27
13
  is_you?: boolean;
28
- member_openid?: string;
29
14
  scope?: string;
30
- username: string;
31
- }[];
15
+ })[];
32
16
  timestamp: string;
33
- message_scene: {
34
- ext: string[];
35
- source: string;
36
- };
37
- message_type: number;
38
17
  }
39
18
  //#endregion
40
19
  export { GROUP_AT_MESSAGE_CREATE_TYPE };
@@ -1,9 +1,11 @@
1
1
  //#region src/message/group/GROUP_MEMBER_ADD.d.ts
2
2
  type GROUP_MEMBER_ADD = {
3
- op_member_openid: string;
3
+ op_member_openid?: string;
4
4
  member_openid: string;
5
+ timestamp?: number;
6
+ user_openid?: string;
5
7
  group_openid: string;
6
- username: string;
8
+ username?: string;
7
9
  };
8
10
  //#endregion
9
11
  export { GROUP_MEMBER_ADD };
@@ -1,9 +1,11 @@
1
1
  //#region src/message/group/GROUP_MEMBER_REMOVE.d.ts
2
2
  type GROUP_MEMBER_REMOVE = {
3
- op_member_openid: string;
3
+ op_member_openid?: string;
4
4
  member_openid: string;
5
+ timestamp?: number;
6
+ user_openid?: string;
5
7
  group_openid: string;
6
- username: string;
8
+ username?: string;
7
9
  };
8
10
  //#endregion
9
11
  export { GROUP_MEMBER_REMOVE };