@alemonjs/kook 0.2.7 → 0.2.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/dist/assets/index.css +1 -1
- package/dist/assets/index.js +10 -30
- package/lib/desktop.d.ts +2 -2
- package/lib/desktop.js +54 -55
- package/lib/index.d.ts +7 -7
- package/lib/index.js +182 -155
- package/lib/sdk/platform/kook/sdk/api.d.ts +267 -279
- package/lib/sdk/platform/kook/sdk/message/INTERACTION.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message/MEMBER_ADD.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message/MEMBER_REMOVE.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message/MESSAGES_DIRECT.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message/MESSAGES_PUBLIC.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message/REACTIONS.d.ts +3 -3
- package/lib/sdk/platform/kook/sdk/message.d.ts +15 -15
- package/lib/sdk/platform/kook/sdk/typings.d.ts +138 -167
- package/lib/sdk/platform/kook/sdk/wss.d.ts +22 -22
- package/lib/sdk/platform/kook/sdk/wss.types.d.ts +5 -5
- package/package.json +1 -1
package/lib/desktop.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const activate: (context: any) => void
|
|
1
|
+
declare const activate: (context: any) => void;
|
|
2
2
|
|
|
3
|
-
export { activate }
|
|
3
|
+
export { activate };
|
package/lib/desktop.js
CHANGED
|
@@ -1,61 +1,60 @@
|
|
|
1
|
-
import { readFileSync } from 'fs'
|
|
2
|
-
import { dirname, join } from 'path'
|
|
3
|
-
import { fileURLToPath } from 'url'
|
|
4
|
-
import { getConfig, getConfigValue } from 'alemonjs'
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { getConfig, getConfigValue } from 'alemonjs';
|
|
5
5
|
|
|
6
6
|
// 当前目录
|
|
7
|
-
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
// 被激活的时候。
|
|
9
9
|
const activate = context => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
// 创建一个 webview。
|
|
11
|
+
const webView = context.createSidebarWebView(context);
|
|
12
|
+
// 当命令被触发的时候。
|
|
13
|
+
context.onCommand('open.kook', () => {
|
|
14
|
+
const dir = join(__dirname, '../', 'dist', 'index.html');
|
|
15
|
+
const scriptReg = /<script.*?src="(.+?)".*?>/;
|
|
16
|
+
const styleReg = /<link.*?rel="stylesheet".*?href="(.+?)".*?>/;
|
|
17
|
+
const iconReg = /<link.*?rel="icon".*?href="(.+?)".*?>/g;
|
|
18
|
+
// 创建 webview 路径
|
|
19
|
+
const styleUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.css'));
|
|
20
|
+
const scriptUri = context.createExtensionDir(join(__dirname, '../', 'dist', 'assets', 'index.js'));
|
|
21
|
+
// 确保路径存在
|
|
22
|
+
const html = readFileSync(dir, 'utf-8')
|
|
23
|
+
.replace(iconReg, ``)
|
|
24
|
+
.replace(scriptReg, `<script type="module" crossorigin src="${scriptUri}"></script>`)
|
|
25
|
+
.replace(styleReg, `<link rel="stylesheet" crossorigin href="${styleUri}">`);
|
|
26
|
+
// 立即渲染 webview
|
|
27
|
+
webView.loadWebView(html);
|
|
28
|
+
});
|
|
29
|
+
// 监听 webview 的消息。
|
|
30
|
+
webView.onMessage(data => {
|
|
31
|
+
try {
|
|
32
|
+
if (data.type === 'kook.form.save') {
|
|
33
|
+
const db = data.data;
|
|
34
|
+
const config = getConfig();
|
|
35
|
+
const value = config.value ?? {};
|
|
36
|
+
value['kook'] = {
|
|
37
|
+
token: db.token ?? '',
|
|
38
|
+
master_key: db.master_key?.split(',') ?? null
|
|
39
|
+
};
|
|
40
|
+
config.saveValue(value);
|
|
41
|
+
context.notification('KOOK 配置保存成功~');
|
|
42
|
+
}
|
|
43
|
+
else if (data.type === 'kook.init') {
|
|
44
|
+
let config = getConfigValue();
|
|
45
|
+
if (!config)
|
|
46
|
+
config = {};
|
|
47
|
+
// 发送消息
|
|
48
|
+
webView.postMessage({
|
|
49
|
+
type: 'kook.init',
|
|
50
|
+
data: config.kook ?? {}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// 发送消息
|
|
50
|
-
webView.postMessage({
|
|
51
|
-
type: 'kook.init',
|
|
52
|
-
data: config.kook ?? {}
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
} catch (e) {
|
|
56
|
-
console.error(e)
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
console.error(e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
60
59
|
|
|
61
|
-
export { activate }
|
|
60
|
+
export { activate };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as alemonjs from 'alemonjs'
|
|
2
|
-
import { KOOKClient } from './sdk/platform/kook/sdk/wss.js'
|
|
1
|
+
import * as alemonjs from 'alemonjs';
|
|
2
|
+
import { KOOKClient } from './sdk/platform/kook/sdk/wss.js';
|
|
3
3
|
|
|
4
|
-
type Client = typeof KOOKClient.prototype
|
|
5
|
-
declare const platform =
|
|
6
|
-
declare const client: Client
|
|
7
|
-
declare const _default: alemonjs.DefineBotValue
|
|
4
|
+
type Client = typeof KOOKClient.prototype;
|
|
5
|
+
declare const platform = "kook";
|
|
6
|
+
declare const client: Client;
|
|
7
|
+
declare const _default: alemonjs.DefineBotValue;
|
|
8
8
|
|
|
9
|
-
export { type Client, client, _default as default, platform }
|
|
9
|
+
export { type Client, client, _default as default, platform };
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,8 @@ var index = defineBot(() => {
|
|
|
36
36
|
// 过滤机器人
|
|
37
37
|
if (event.extra?.author?.bot)
|
|
38
38
|
return false;
|
|
39
|
+
// 创建私聊标记
|
|
40
|
+
const data = await client.userChatCreate(event.extra.author.id).then(res => res?.data);
|
|
39
41
|
// 主人
|
|
40
42
|
const master_key = config?.master_key ?? [];
|
|
41
43
|
const isMaster = master_key.includes(event.author_id);
|
|
@@ -77,7 +79,7 @@ var index = defineBot(() => {
|
|
|
77
79
|
// message
|
|
78
80
|
MessageId: event.msg_id,
|
|
79
81
|
MessageText: msg,
|
|
80
|
-
OpenId:
|
|
82
|
+
OpenId: data?.code,
|
|
81
83
|
CreateAt: Date.now(),
|
|
82
84
|
//
|
|
83
85
|
tag: 'MESSAGES_PUBLIC',
|
|
@@ -167,172 +169,197 @@ var index = defineBot(() => {
|
|
|
167
169
|
});
|
|
168
170
|
// 客户端全局化。
|
|
169
171
|
global.client = client;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @param channel_id
|
|
175
|
+
* @param val
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
const sendChannel = (channel_id, val) => {
|
|
179
|
+
if (val.length < 0)
|
|
180
|
+
return Promise.all([]);
|
|
181
|
+
const content = val
|
|
182
|
+
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
183
|
+
.map(item => {
|
|
184
|
+
// if (item.type == 'Link') {
|
|
185
|
+
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
186
|
+
// } else
|
|
187
|
+
if (item.type == 'Mention') {
|
|
188
|
+
if (item.value == 'everyone' ||
|
|
189
|
+
item.value == 'all' ||
|
|
190
|
+
item.value == '' ||
|
|
191
|
+
typeof item.value != 'string') {
|
|
192
|
+
return `(met)all(met)`;
|
|
193
|
+
}
|
|
194
|
+
if (item.options?.belong == 'user') {
|
|
195
|
+
return `(met)${item.value}(met)`;
|
|
196
|
+
}
|
|
197
|
+
else if (item.options?.belong == 'channel') {
|
|
198
|
+
return `(chn)${item.value}(chn)`;
|
|
199
|
+
}
|
|
200
|
+
return '';
|
|
201
|
+
}
|
|
202
|
+
else if (item.type == 'Text') {
|
|
203
|
+
if (item.options?.style == 'block') {
|
|
204
|
+
return `\`${item.value}\``;
|
|
205
|
+
}
|
|
206
|
+
else if (item.options?.style == 'italic') {
|
|
207
|
+
return `*${item.value}*`;
|
|
208
|
+
}
|
|
209
|
+
else if (item.options?.style == 'bold') {
|
|
210
|
+
return `**${item.value}**`;
|
|
211
|
+
}
|
|
212
|
+
else if (item.options?.style == 'strikethrough') {
|
|
213
|
+
return `~~${item.value}~~`;
|
|
214
|
+
}
|
|
215
|
+
else if (item.options?.style == 'boldItalic') {
|
|
216
|
+
return `***${item.value}***`;
|
|
217
|
+
}
|
|
218
|
+
return item.value;
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
.join('');
|
|
222
|
+
if (content) {
|
|
223
|
+
return Promise.all([content].map(item => client.createMessage({
|
|
224
|
+
type: 9,
|
|
225
|
+
target_id: channel_id,
|
|
226
|
+
content: item
|
|
227
|
+
})));
|
|
228
|
+
}
|
|
229
|
+
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
230
|
+
if (images) {
|
|
231
|
+
return Promise.all(images.map(async (item) => {
|
|
232
|
+
if (item.type == 'ImageURL') {
|
|
233
|
+
return await client.createMessage({
|
|
234
|
+
type: 2,
|
|
235
|
+
target_id: channel_id,
|
|
236
|
+
content: item.value
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
let data = item.value;
|
|
240
|
+
if (item.type == 'ImageFile') {
|
|
241
|
+
data = readFileSync(item.value);
|
|
242
|
+
}
|
|
243
|
+
// 上传图片
|
|
244
|
+
const res = await client.postImage(data);
|
|
245
|
+
if (!res)
|
|
246
|
+
return Promise.resolve();
|
|
247
|
+
// 发送消息
|
|
248
|
+
return await client.createMessage({
|
|
249
|
+
type: 2,
|
|
250
|
+
target_id: channel_id,
|
|
251
|
+
content: res.data.url
|
|
252
|
+
});
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
return Promise.all([]);
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
* @param channel_id
|
|
260
|
+
* @param val
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
263
|
+
const sendUser = async (user_id, val) => {
|
|
264
|
+
if (val.length < 0)
|
|
265
|
+
return Promise.all([]);
|
|
266
|
+
// 创建私聊标记
|
|
267
|
+
const data = await client.userChatCreate(user_id).then(res => res?.data);
|
|
268
|
+
const open_id = data?.code;
|
|
269
|
+
const content = val
|
|
270
|
+
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
271
|
+
.map(item => {
|
|
272
|
+
// if (item.type == 'Link') {
|
|
273
|
+
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
274
|
+
// } else
|
|
275
|
+
if (item.type == 'Mention') {
|
|
276
|
+
if (item.value == 'everyone' ||
|
|
277
|
+
item.value == 'all' ||
|
|
278
|
+
item.value == '' ||
|
|
279
|
+
typeof item.value != 'string') {
|
|
280
|
+
return `(met)all(met)`;
|
|
281
|
+
}
|
|
282
|
+
if (item.options?.belong == 'user') {
|
|
283
|
+
return `(met)${item.value}(met)`;
|
|
284
|
+
}
|
|
285
|
+
else if (item.options?.belong == 'channel') {
|
|
286
|
+
return `(chn)${item.value}(chn)`;
|
|
287
|
+
}
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
290
|
+
else if (item.type == 'Text') {
|
|
291
|
+
if (item.options?.style == 'block') {
|
|
292
|
+
return `\`${item.value}\``;
|
|
293
|
+
}
|
|
294
|
+
else if (item.options?.style == 'italic') {
|
|
295
|
+
return `*${item.value}*`;
|
|
296
|
+
}
|
|
297
|
+
else if (item.options?.style == 'bold') {
|
|
298
|
+
return `**${item.value}**`;
|
|
299
|
+
}
|
|
300
|
+
else if (item.options?.style == 'strikethrough') {
|
|
301
|
+
return `~~${item.value}~~`;
|
|
302
|
+
}
|
|
303
|
+
else if (item.options?.style == 'boldItalic') {
|
|
304
|
+
return `***${item.value}***`;
|
|
305
|
+
}
|
|
306
|
+
return item.value;
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
.join('');
|
|
310
|
+
if (content) {
|
|
311
|
+
return Promise.all([content].map(item => client.createDirectMessage({
|
|
312
|
+
type: 9,
|
|
313
|
+
chat_code: open_id,
|
|
314
|
+
content: item
|
|
315
|
+
})));
|
|
316
|
+
}
|
|
317
|
+
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
318
|
+
if (images) {
|
|
319
|
+
return Promise.all(images.map(async (item) => {
|
|
320
|
+
if (item.type == 'ImageURL') {
|
|
321
|
+
return await client.createDirectMessage({
|
|
322
|
+
type: 2,
|
|
323
|
+
chat_code: open_id,
|
|
324
|
+
content: item.value
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
let data = item.value;
|
|
328
|
+
if (item.type == 'ImageFile') {
|
|
329
|
+
data = readFileSync(item.value);
|
|
330
|
+
}
|
|
331
|
+
// 上传图片
|
|
332
|
+
const res = await client.postImage(data);
|
|
333
|
+
if (!res)
|
|
334
|
+
return Promise.resolve();
|
|
335
|
+
// 发送消息
|
|
336
|
+
return await client.createDirectMessage({
|
|
337
|
+
type: 2,
|
|
338
|
+
chat_code: open_id,
|
|
339
|
+
content: res.data.url
|
|
340
|
+
});
|
|
341
|
+
}));
|
|
342
|
+
}
|
|
343
|
+
return Promise.all([]);
|
|
344
|
+
};
|
|
170
345
|
return {
|
|
171
346
|
platform,
|
|
172
347
|
api: {
|
|
173
348
|
active: {
|
|
174
349
|
send: {
|
|
175
|
-
channel:
|
|
176
|
-
|
|
177
|
-
return Promise.all([]);
|
|
178
|
-
const content = val
|
|
179
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
180
|
-
.map(item => {
|
|
181
|
-
// if (item.type == 'Link') {
|
|
182
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
183
|
-
// } else
|
|
184
|
-
if (item.type == 'Mention') {
|
|
185
|
-
if (item.value == 'everyone' ||
|
|
186
|
-
item.value == 'all' ||
|
|
187
|
-
item.value == '' ||
|
|
188
|
-
typeof item.value != 'string') {
|
|
189
|
-
return `(met)all(met)`;
|
|
190
|
-
}
|
|
191
|
-
if (item.options?.belong == 'user') {
|
|
192
|
-
return `(met)${item.value}(met)`;
|
|
193
|
-
}
|
|
194
|
-
else if (item.options?.belong == 'channel') {
|
|
195
|
-
return `(chn)${item.value}(chn)`;
|
|
196
|
-
}
|
|
197
|
-
return '';
|
|
198
|
-
}
|
|
199
|
-
else if (item.type == 'Text') {
|
|
200
|
-
if (item.options?.style == 'block') {
|
|
201
|
-
return `\`${item.value}\``;
|
|
202
|
-
}
|
|
203
|
-
else if (item.options?.style == 'italic') {
|
|
204
|
-
return `*${item.value}*`;
|
|
205
|
-
}
|
|
206
|
-
else if (item.options?.style == 'bold') {
|
|
207
|
-
return `**${item.value}**`;
|
|
208
|
-
}
|
|
209
|
-
else if (item.options?.style == 'strikethrough') {
|
|
210
|
-
return `~~${item.value}~~`;
|
|
211
|
-
}
|
|
212
|
-
else if (item.options?.style == 'boldItalic') {
|
|
213
|
-
return `***${item.value}***`;
|
|
214
|
-
}
|
|
215
|
-
return item.value;
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
.join('');
|
|
219
|
-
if (content) {
|
|
220
|
-
return Promise.all([content].map(item => client.createMessage({
|
|
221
|
-
type: 9,
|
|
222
|
-
target_id: channel_id,
|
|
223
|
-
content: item
|
|
224
|
-
})));
|
|
225
|
-
}
|
|
226
|
-
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageFile' || item.type == 'ImageURL');
|
|
227
|
-
if (images) {
|
|
228
|
-
return Promise.all(images.map(async (item) => {
|
|
229
|
-
if (item.type == 'ImageURL') {
|
|
230
|
-
return await client.createMessage({
|
|
231
|
-
type: 2,
|
|
232
|
-
target_id: channel_id,
|
|
233
|
-
content: item.value
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
let data = item.value;
|
|
237
|
-
if (item.type == 'ImageFile') {
|
|
238
|
-
data = readFileSync(item.value);
|
|
239
|
-
}
|
|
240
|
-
// 上传图片
|
|
241
|
-
const res = await client.postImage(data);
|
|
242
|
-
if (!res)
|
|
243
|
-
return Promise.resolve();
|
|
244
|
-
// 发送消息
|
|
245
|
-
return await client.createMessage({
|
|
246
|
-
type: 2,
|
|
247
|
-
target_id: channel_id,
|
|
248
|
-
content: res.data.url
|
|
249
|
-
});
|
|
250
|
-
}));
|
|
251
|
-
}
|
|
252
|
-
return Promise.all([]);
|
|
253
|
-
},
|
|
254
|
-
user: (channel_id, val) => {
|
|
255
|
-
return Promise.all([]);
|
|
256
|
-
}
|
|
350
|
+
channel: sendChannel,
|
|
351
|
+
user: sendUser
|
|
257
352
|
}
|
|
258
353
|
},
|
|
259
354
|
use: {
|
|
260
355
|
send: (event, val) => {
|
|
261
356
|
if (val.length < 0)
|
|
262
357
|
return Promise.all([]);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
.map(item => {
|
|
266
|
-
// if (item.type == 'Link') {
|
|
267
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
268
|
-
// } else
|
|
269
|
-
if (item.type == 'Mention') {
|
|
270
|
-
if (item.value == 'everyone' ||
|
|
271
|
-
item.value == 'all' ||
|
|
272
|
-
item.value == '' ||
|
|
273
|
-
typeof item.value != 'string') {
|
|
274
|
-
return `(met)all(met)`;
|
|
275
|
-
}
|
|
276
|
-
if (item.options?.belong == 'user') {
|
|
277
|
-
return `(met)${item.value}(met)`;
|
|
278
|
-
}
|
|
279
|
-
else if (item.options?.belong == 'channel') {
|
|
280
|
-
return `(chn)${item.value}(chn)`;
|
|
281
|
-
}
|
|
282
|
-
return '';
|
|
283
|
-
}
|
|
284
|
-
else if (item.type == 'Text') {
|
|
285
|
-
if (item.options?.style == 'block') {
|
|
286
|
-
return `\`${item.value}\``;
|
|
287
|
-
}
|
|
288
|
-
else if (item.options?.style == 'italic') {
|
|
289
|
-
return `*${item.value}*`;
|
|
290
|
-
}
|
|
291
|
-
else if (item.options?.style == 'bold') {
|
|
292
|
-
return `**${item.value}**`;
|
|
293
|
-
}
|
|
294
|
-
else if (item.options?.style == 'strikethrough') {
|
|
295
|
-
return `~~${item.value}~~`;
|
|
296
|
-
}
|
|
297
|
-
else if (item.options?.style == 'boldItalic') {
|
|
298
|
-
return `***${item.value}***`;
|
|
299
|
-
}
|
|
300
|
-
return item.value;
|
|
301
|
-
}
|
|
302
|
-
})
|
|
303
|
-
.join('');
|
|
304
|
-
if (content) {
|
|
305
|
-
return Promise.all([content].map(item => client.createMessage({
|
|
306
|
-
type: 9,
|
|
307
|
-
target_id: event.ChannelId,
|
|
308
|
-
content: item
|
|
309
|
-
})));
|
|
358
|
+
if (event.name == 'message.create') {
|
|
359
|
+
return sendChannel(event.ChannelId, val);
|
|
310
360
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return Promise.all(images.map(async (item) => {
|
|
314
|
-
if (item.type == 'ImageURL') {
|
|
315
|
-
return await client.createMessage({
|
|
316
|
-
type: 2,
|
|
317
|
-
target_id: event.ChannelId,
|
|
318
|
-
content: item.value
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
let data = item.value;
|
|
322
|
-
if (item.type == 'ImageFile') {
|
|
323
|
-
data = readFileSync(item.value);
|
|
324
|
-
}
|
|
325
|
-
// 上传图片
|
|
326
|
-
const res = await client.postImage(data);
|
|
327
|
-
if (!res)
|
|
328
|
-
return Promise.resolve();
|
|
329
|
-
// 发送消息
|
|
330
|
-
return await client.createMessage({
|
|
331
|
-
type: 2,
|
|
332
|
-
target_id: event.ChannelId,
|
|
333
|
-
content: res.data.url
|
|
334
|
-
});
|
|
335
|
-
}));
|
|
361
|
+
else if (event.name == 'private.message.create') {
|
|
362
|
+
return sendUser(event.UserId, val);
|
|
336
363
|
}
|
|
337
364
|
return Promise.all([]);
|
|
338
365
|
},
|