@alemonjs/qq-bot 2.1.0-alpha.8 → 2.1.0-alpha.9
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.
- package/lib/register.js +13 -12
- package/lib/sdk/api.d.ts +5 -5
- package/lib/sdk/api.js +17 -13
- package/package.json +1 -1
package/lib/register.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfigValue, cbpPlatform, useUserHashKey,
|
|
1
|
+
import { getConfigValue, cbpPlatform, useUserHashKey, createResult, ResultCode } from 'alemonjs';
|
|
2
2
|
import { GROUP_AT_MESSAGE_CREATE, C2C_MESSAGE_CREATE, DIRECT_MESSAGE_CREATE, AT_MESSAGE_CREATE, MESSAGE_CREATE } from './sends.js';
|
|
3
3
|
|
|
4
4
|
// import dayjs from 'dayjs'
|
|
@@ -238,16 +238,17 @@ const register = (client) => {
|
|
|
238
238
|
cbp.send(e);
|
|
239
239
|
});
|
|
240
240
|
client.on('INTERACTION_CREATE', async (event) => {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
try {
|
|
242
|
+
if (event.scene === 'group' || event.scene === 'c2c') {
|
|
243
|
+
await client.interactionResponse('group', event.id);
|
|
244
|
+
}
|
|
245
|
+
else if (event.scene === 'guild') {
|
|
246
|
+
await client.interactionResponse('guild', event.id);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
createResult(ResultCode.Fail, err?.response?.data ?? err?.message ?? err, null);
|
|
251
|
+
}
|
|
251
252
|
if (event.scene === 'group') {
|
|
252
253
|
const master_key = config?.master_key ?? [];
|
|
253
254
|
const isMaster = master_key.includes(event.group_member_openid);
|
|
@@ -271,7 +272,7 @@ const register = (client) => {
|
|
|
271
272
|
IsMaster: isMaster,
|
|
272
273
|
IsBot: false,
|
|
273
274
|
// 格式化数据
|
|
274
|
-
MessageId: event.id
|
|
275
|
+
MessageId: `INTERACTION_CREATE:${event.id}`,
|
|
275
276
|
MessageText: MessageText,
|
|
276
277
|
OpenId: event.group_member_openid,
|
|
277
278
|
tag: 'INTERACTION_CREATE_GROUP',
|
package/lib/sdk/api.d.ts
CHANGED
|
@@ -162,11 +162,11 @@ declare class QQBotAPI {
|
|
|
162
162
|
markdown?: any;
|
|
163
163
|
}, image?: Buffer): Promise<any>;
|
|
164
164
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
* 私聊发送
|
|
166
|
+
* @param id 私信传频道id,公信传子频道id
|
|
167
|
+
* @param message {消息编号,图片,内容}
|
|
168
|
+
* @returns
|
|
169
|
+
*/
|
|
170
170
|
dmsMessages(guild_id: string, message: {
|
|
171
171
|
content?: string;
|
|
172
172
|
embed?: any;
|
package/lib/sdk/api.js
CHANGED
|
@@ -91,9 +91,11 @@ class QQBotAPI {
|
|
|
91
91
|
*/
|
|
92
92
|
async usersOpenMessages(openid, data) {
|
|
93
93
|
const db = {
|
|
94
|
-
...(data.event_id
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
...(data.event_id
|
|
95
|
+
? { event_id: data.event_id }
|
|
96
|
+
: {
|
|
97
|
+
msg_seq: this.getMessageSeq(data.msg_id || '')
|
|
98
|
+
}),
|
|
97
99
|
...data
|
|
98
100
|
};
|
|
99
101
|
return this.groupService({
|
|
@@ -127,9 +129,11 @@ class QQBotAPI {
|
|
|
127
129
|
*/
|
|
128
130
|
async groupOpenMessages(group_openid, data) {
|
|
129
131
|
const db = {
|
|
130
|
-
...(data.event_id
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
...(data.event_id
|
|
133
|
+
? { event_id: data.event_id }
|
|
134
|
+
: {
|
|
135
|
+
msg_seq: this.getMessageSeq(data.msg_id || '')
|
|
136
|
+
}),
|
|
133
137
|
...data
|
|
134
138
|
};
|
|
135
139
|
return this.groupService({
|
|
@@ -263,11 +267,11 @@ class QQBotAPI {
|
|
|
263
267
|
}).then(res => res?.data);
|
|
264
268
|
}
|
|
265
269
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
* 私聊发送
|
|
271
|
+
* @param id 私信传频道id,公信传子频道id
|
|
272
|
+
* @param message {消息编号,图片,内容}
|
|
273
|
+
* @returns
|
|
274
|
+
*/
|
|
271
275
|
async dmsMessages(guild_id, message, image) {
|
|
272
276
|
const formdata = new FormData();
|
|
273
277
|
for (const key in message) {
|
|
@@ -1065,7 +1069,7 @@ class QQBotAPI {
|
|
|
1065
1069
|
method: 'PUT',
|
|
1066
1070
|
url: `/interactions/${interaction_id}`,
|
|
1067
1071
|
data: {
|
|
1068
|
-
code: code || 0
|
|
1072
|
+
code: code || 0
|
|
1069
1073
|
}
|
|
1070
1074
|
}).then(res => res?.data);
|
|
1071
1075
|
}
|
|
@@ -1074,7 +1078,7 @@ class QQBotAPI {
|
|
|
1074
1078
|
method: 'PUT',
|
|
1075
1079
|
url: `/interactions/${interaction_id}`,
|
|
1076
1080
|
data: {
|
|
1077
|
-
code: code || 0
|
|
1081
|
+
code: code || 0
|
|
1078
1082
|
}
|
|
1079
1083
|
}).then(res => res?.data);
|
|
1080
1084
|
}
|