alemonjs 1.0.55 → 1.0.56
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/api.js +7 -5
- package/lib/core/buffer.js +43 -1
- package/lib/define/main.js +1 -1
- package/lib/index.js +6 -6
- package/lib/koa/img.js +0 -1
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +16 -3
- package/lib/kook/alemon/segment.js +3 -0
- package/lib/kook/index.js +2 -0
- package/lib/kook/sdk/api.js +5 -31
- package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +63 -102
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +65 -99
- package/lib/ntqq/alemon/segment.js +12 -1
- package/lib/ntqq/index.js +2 -0
- package/lib/ntqq/sdk/api.js +58 -8
- package/lib/ntqq/sdk/typings.js +8 -2
- package/lib/one/alemon/message/DIRECT_MESSAGE.js +5 -8
- package/lib/one/alemon/message/MESSAGES.js +5 -44
- package/lib/one/alemon/segment.js +3 -0
- package/lib/qq/alemon/message/AUDIO_ACTION.js +32 -4
- package/lib/qq/alemon/message/DIRECT_MESSAGE.js +19 -33
- package/lib/qq/alemon/message/FORUMS_EVENT.js +25 -12
- package/lib/qq/alemon/message/GUILDS.js +96 -20
- package/lib/qq/alemon/message/GUILD_MEMBERS.js +23 -119
- package/lib/qq/alemon/message/GUILD_MESSAGES.js +28 -3
- package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +36 -10
- package/lib/qq/alemon/message/INTERACTION.js +28 -3
- package/lib/qq/alemon/message/MESSAGE.js +0 -15
- package/lib/qq/alemon/message/MESSAGE_AUDIT.js +28 -3
- package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +25 -11
- package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +28 -3
- package/lib/qq/alemon/segment.js +3 -0
- package/lib/qq/alemon/types.js +0 -4
- package/lib/qq/index.js +2 -0
- package/lib/qq/sdk/api.js +5 -31
- package/lib/villa/alemon/conversation.js +1 -1
- package/lib/villa/alemon/message/GUILDS.js +16 -4
- package/lib/villa/alemon/message/GUILD_MEMBERS.js +19 -11
- package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +26 -6
- package/lib/villa/alemon/message/MESSAGES.js +39 -77
- package/lib/villa/alemon/message/MESSAGE_AUDIT.js +18 -5
- package/lib/villa/alemon/segment.js +3 -0
- package/lib/villa/index.js +2 -0
- package/lib/villa/sdk/api.js +188 -42
- package/lib/villa/sdk/client.js +3 -3
- package/lib/villa/sdk/mechanism.js +1 -1
- package/lib/villa/sdk/types.js +2 -0
- package/package.json +2 -1
- package/types/api.d.ts +4 -11
- package/types/core/buffer.d.ts +13 -0
- package/types/core/typings.d.ts +21 -17
- package/types/define/types.d.ts +1 -1
- package/types/index.d.ts +6 -6
- package/types/kook/alemon/segment.d.ts +3 -0
- package/types/kook/index.d.ts +1 -0
- package/types/kook/kook.d.ts +5 -5
- package/types/kook/sdk/api.d.ts +1 -1
- package/types/ntqq/alemon/segment.d.ts +3 -0
- package/types/ntqq/index.d.ts +1 -0
- package/types/ntqq/ntqq.d.ts +18 -14
- package/types/ntqq/sdk/api.d.ts +45 -5
- package/types/ntqq/sdk/typings.d.ts +2 -2
- package/types/one/alemon/segment.d.ts +3 -0
- package/types/qq/alemon/message/AUDIO_ACTION.d.ts +1 -1
- package/types/qq/alemon/message/DIRECT_MESSAGE.d.ts +34 -1
- package/types/qq/alemon/message/FORUMS_EVENT.d.ts +17 -4
- package/types/qq/alemon/message/GUILDS.d.ts +1 -8
- package/types/qq/alemon/message/GUILD_MEMBERS.d.ts +19 -4
- package/types/qq/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +19 -4
- package/types/qq/alemon/message/MESSAGE.d.ts +41 -2
- package/types/qq/alemon/message/OPEN_FORUMS_EVENT.d.ts +18 -4
- package/types/qq/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +41 -2
- package/types/qq/alemon/segment.d.ts +3 -0
- package/types/qq/alemon/types.d.ts +0 -62
- package/types/qq/index.d.ts +1 -0
- package/types/qq/qq.d.ts +10 -10
- package/types/villa/alemon/conversation.d.ts +1 -2
- package/types/villa/alemon/message/GUILDS.d.ts +26 -2
- package/types/villa/alemon/message/GUILD_MEMBERS.d.ts +30 -7
- package/types/villa/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +33 -2
- package/types/villa/alemon/message/MESSAGES.d.ts +33 -2
- package/types/villa/alemon/message/MESSAGE_AUDIT.d.ts +24 -3
- package/types/villa/alemon/segment.d.ts +3 -0
- package/types/villa/index.d.ts +1 -0
- package/types/villa/sdk/api.d.ts +55 -36
- package/types/villa/sdk/client.d.ts +3 -3
- package/types/villa/sdk/mechanism.d.ts +1 -1
- package/types/villa/sdk/reply.d.ts +6 -6
- package/types/villa/sdk/types.d.ts +5 -66
- package/types/villa/villa.d.ts +13 -13
- package/lib/qq/alemon/e.js +0 -41
- package/lib/qq/alemon/privatechat.js +0 -90
- package/lib/villa/alemon/message/e.js +0 -41
- package/types/qq/alemon/e.d.ts +0 -38
- package/types/qq/alemon/privatechat.d.ts +0 -17
- package/types/villa/alemon/message/e.d.ts +0 -37
package/lib/api.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ***********
|
|
3
|
+
* SDK接口管理
|
|
4
|
+
* ***********
|
|
3
5
|
*/
|
|
4
|
-
export
|
|
6
|
+
export { ClientQQ } from './qq/index.js';
|
|
5
7
|
/**
|
|
6
8
|
* villa客户端
|
|
7
9
|
*/
|
|
8
|
-
export { ClientVILLA } from './villa/
|
|
10
|
+
export { ClientVILLA } from './villa/index.js';
|
|
9
11
|
/**
|
|
10
12
|
* ntqq客户端
|
|
11
13
|
*/
|
|
12
|
-
export { ClientNTQQ } from './ntqq/
|
|
14
|
+
export { ClientNTQQ } from './ntqq/index.js';
|
|
13
15
|
/**
|
|
14
16
|
* server客户端
|
|
15
17
|
*/
|
|
@@ -17,4 +19,4 @@ export { ClientKOA } from './koa/index.js';
|
|
|
17
19
|
/**
|
|
18
20
|
* kook客户端
|
|
19
21
|
*/
|
|
20
|
-
export { ClientKOOK } from './kook/
|
|
22
|
+
export { ClientKOOK } from './kook/index.js';
|
package/lib/core/buffer.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'fs';
|
|
1
|
+
import { existsSync, readFileSync, createReadStream } from 'fs';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
+
import { Readable, isReadable } from 'stream';
|
|
5
|
+
import { basename } from 'path';
|
|
6
|
+
import { fileTypeFromBuffer, fileTypeFromStream } from 'file-type';
|
|
4
7
|
/**
|
|
5
8
|
* 异步请求图片
|
|
6
9
|
* @param url 网络地址
|
|
@@ -37,3 +40,42 @@ export function getPathBuffer(val) {
|
|
|
37
40
|
}
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 创建form
|
|
45
|
+
* @param image
|
|
46
|
+
* @param name
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export async function createPicFrom(image, name = 'image.jpg') {
|
|
50
|
+
let picData;
|
|
51
|
+
// 是 string
|
|
52
|
+
if (typeof image === 'string') {
|
|
53
|
+
if (!existsSync(image)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (!name) {
|
|
57
|
+
name = basename(image);
|
|
58
|
+
}
|
|
59
|
+
picData = createReadStream(image);
|
|
60
|
+
// 是 buffer
|
|
61
|
+
}
|
|
62
|
+
else if (Buffer.isBuffer(image)) {
|
|
63
|
+
if (!name) {
|
|
64
|
+
name = 'file.' + (await fileTypeFromBuffer(image)).ext;
|
|
65
|
+
}
|
|
66
|
+
picData = new Readable();
|
|
67
|
+
picData.push(image);
|
|
68
|
+
picData.push(null);
|
|
69
|
+
// 是 文件流
|
|
70
|
+
}
|
|
71
|
+
else if (isReadable(image)) {
|
|
72
|
+
if (!name) {
|
|
73
|
+
name = 'file.' + (await fileTypeFromStream(image)).ext;
|
|
74
|
+
}
|
|
75
|
+
picData = image;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return { picData, image, name };
|
|
81
|
+
}
|
package/lib/define/main.js
CHANGED
|
@@ -156,7 +156,7 @@ export async function defineAlemonConfig(Options) {
|
|
|
156
156
|
* 挂起web服务
|
|
157
157
|
* **********
|
|
158
158
|
*/
|
|
159
|
-
if (Options?.server?.state
|
|
159
|
+
if (Options?.server?.state) {
|
|
160
160
|
// 创建server端
|
|
161
161
|
createWeb(Options?.server);
|
|
162
162
|
if (Options?.server?.clear != false) {
|
package/lib/index.js
CHANGED
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
* *************
|
|
5
5
|
*/
|
|
6
6
|
export * from './core/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* *************
|
|
9
|
-
* define
|
|
10
|
-
* *************
|
|
11
|
-
*/
|
|
12
|
-
export * from './define/index.js';
|
|
13
7
|
/**
|
|
14
8
|
* *************
|
|
15
9
|
* config system
|
|
@@ -22,6 +16,12 @@ export * from './config/index.js';
|
|
|
22
16
|
* *************
|
|
23
17
|
*/
|
|
24
18
|
export * from './login.js';
|
|
19
|
+
/**
|
|
20
|
+
* *************
|
|
21
|
+
* define
|
|
22
|
+
* *************
|
|
23
|
+
*/
|
|
24
|
+
export * from './define/index.js';
|
|
25
25
|
/**
|
|
26
26
|
* api
|
|
27
27
|
*/
|
package/lib/koa/img.js
CHANGED
|
@@ -56,20 +56,33 @@ export const PUBLIC_GUILD_MESSAGES_KOOK = async (event) => {
|
|
|
56
56
|
const avatar = event.extra.author.avatar;
|
|
57
57
|
const e = {
|
|
58
58
|
platform: 'kook',
|
|
59
|
-
bot: getBotMsgByKOOK(),
|
|
60
59
|
event: 'MESSAGES',
|
|
61
60
|
eventType: 'CREATE',
|
|
61
|
+
boundaries: 'private',
|
|
62
|
+
attribute: event.channel_type == 'GROUP'
|
|
63
|
+
? 'group'
|
|
64
|
+
: 'single',
|
|
65
|
+
bot: getBotMsgByKOOK(),
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
62
69
|
isPrivate: true,
|
|
63
70
|
isRecall: false,
|
|
64
71
|
isMaster: event.msg_id == masterID ? true : false,
|
|
65
72
|
isGroup: event.channel_type == 'GROUP' ? true : false,
|
|
66
|
-
boundaries: 'private',
|
|
67
|
-
attribute: event.channel_type == 'GROUP' ? 'group' : 'single',
|
|
68
73
|
at,
|
|
69
74
|
at_users,
|
|
70
75
|
at_user,
|
|
71
76
|
msg,
|
|
72
77
|
msg_id: event.msg_id,
|
|
78
|
+
/**
|
|
79
|
+
* 特殊消息
|
|
80
|
+
*/
|
|
81
|
+
attachments: [],
|
|
82
|
+
/**
|
|
83
|
+
* 特殊消息
|
|
84
|
+
*/
|
|
85
|
+
specials: [],
|
|
73
86
|
msg_txt: event.content,
|
|
74
87
|
msg_create_time: event.msg_timestamp,
|
|
75
88
|
guild_id: event.target_id,
|
package/lib/kook/index.js
CHANGED
package/lib/kook/sdk/api.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import FormData from 'form-data';
|
|
3
|
-
import { existsSync, createReadStream } from 'fs';
|
|
4
|
-
import { Readable, isReadable } from 'stream';
|
|
5
|
-
import { basename } from 'path';
|
|
6
|
-
import { fileTypeFromBuffer, fileTypeFromStream } from 'file-type';
|
|
7
3
|
import { ApiEnum } from './typings.js';
|
|
8
4
|
import { getKookToken } from './config.js';
|
|
5
|
+
import { createPicFrom } from '../../core/index.js';
|
|
9
6
|
/**
|
|
10
7
|
* KOOK服务
|
|
11
8
|
* @param config
|
|
@@ -33,34 +30,11 @@ export function kookService(config) {
|
|
|
33
30
|
* @param message {消息编号,图片,内容}
|
|
34
31
|
* @returns
|
|
35
32
|
*/
|
|
36
|
-
export async function postImage(file,
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
if (!existsSync(file)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (!name) {
|
|
43
|
-
name = basename(file);
|
|
44
|
-
}
|
|
45
|
-
picData = createReadStream(file);
|
|
46
|
-
}
|
|
47
|
-
else if (Buffer.isBuffer(file)) {
|
|
48
|
-
if (!name) {
|
|
49
|
-
name = 'file.' + (await fileTypeFromBuffer(file)).ext;
|
|
50
|
-
}
|
|
51
|
-
picData = new Readable();
|
|
52
|
-
picData.push(file);
|
|
53
|
-
picData.push(null);
|
|
54
|
-
}
|
|
55
|
-
else if (isReadable(file)) {
|
|
56
|
-
if (!name) {
|
|
57
|
-
name = 'file.' + (await fileTypeFromStream(file)).ext;
|
|
58
|
-
}
|
|
59
|
-
picData = file;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
33
|
+
export async function postImage(file, Name = 'image.jpg') {
|
|
34
|
+
const from = await createPicFrom(file, Name);
|
|
35
|
+
if (!from)
|
|
62
36
|
return false;
|
|
63
|
-
}
|
|
37
|
+
const { picData, name } = from;
|
|
64
38
|
const formdata = new FormData();
|
|
65
39
|
formdata.append('file', picData, name);
|
|
66
40
|
const url = await createUrl(formdata);
|
|
@@ -11,120 +11,81 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
11
11
|
const masterID = cfg.masterID;
|
|
12
12
|
const e = {
|
|
13
13
|
platform: 'ntqq',
|
|
14
|
-
bot: getBotMsgByNtqq(),
|
|
15
|
-
isMaster: event.author.id == masterID ? true : false,
|
|
16
14
|
event: 'MESSAGES',
|
|
17
15
|
eventType: 'CREATE',
|
|
18
|
-
|
|
16
|
+
boundaries: 'publick',
|
|
17
|
+
attribute: 'single',
|
|
18
|
+
bot: getBotMsgByNtqq(),
|
|
19
|
+
isMaster: event.author.id == masterID ? true : false,
|
|
19
20
|
isPrivate: false,
|
|
20
21
|
isRecall: false,
|
|
21
22
|
isGroup: false,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/* 消息发送机制 */
|
|
27
|
-
e.reply = async (msg, select) => {
|
|
28
|
-
// isBuffer
|
|
29
|
-
if (Buffer.isBuffer(msg)) {
|
|
30
|
-
try {
|
|
31
|
-
const url = await ClientKOA.setLocalImg(msg);
|
|
32
|
-
if (!url)
|
|
33
|
-
return false;
|
|
34
|
-
return await ClientNTQQ.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
console.error(err);
|
|
38
|
-
return err;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* isString arr and find buffer
|
|
43
|
-
*/
|
|
44
|
-
if (Array.isArray(msg) && msg.find(item => Buffer.isBuffer(item))) {
|
|
45
|
-
const isBuffer = msg.findIndex(item => Buffer.isBuffer(item));
|
|
46
|
-
const cont = msg
|
|
47
|
-
.map(item => {
|
|
48
|
-
if (typeof item === 'number')
|
|
49
|
-
return String(item);
|
|
50
|
-
return item;
|
|
51
|
-
})
|
|
52
|
-
.filter(element => typeof element === 'string')
|
|
53
|
-
.join('');
|
|
54
|
-
try {
|
|
55
|
-
const dimensions = IMGS.imageSize(msg[isBuffer]);
|
|
56
|
-
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
57
|
-
if (!url)
|
|
58
|
-
return false;
|
|
59
|
-
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `, event.id).catch(everyoneError);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
console.error(err);
|
|
63
|
-
return err;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const content = Array.isArray(msg)
|
|
67
|
-
? msg.join('')
|
|
68
|
-
: typeof msg === 'string'
|
|
69
|
-
? msg
|
|
70
|
-
: typeof msg === 'number'
|
|
71
|
-
? `${msg}`
|
|
72
|
-
: '';
|
|
73
|
-
if (content == '')
|
|
74
|
-
return false;
|
|
75
|
-
/**
|
|
76
|
-
* https
|
|
77
|
-
*/
|
|
78
|
-
const match = content.match(/<http>(.*?)<\/http>/);
|
|
79
|
-
if (match) {
|
|
80
|
-
const getUrl = match[1];
|
|
81
|
-
const msg = await getUrlbuffer(getUrl);
|
|
23
|
+
attachments: [],
|
|
24
|
+
specials: [],
|
|
25
|
+
reply: async (msg, select) => {
|
|
26
|
+
// isBuffer
|
|
82
27
|
if (Buffer.isBuffer(msg)) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
28
|
+
try {
|
|
29
|
+
const url = await ClientKOA.setLocalImg(msg);
|
|
30
|
+
if (!url)
|
|
31
|
+
return false;
|
|
32
|
+
return await ClientNTQQ.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
console.error(err);
|
|
36
|
+
return err;
|
|
37
|
+
}
|
|
87
38
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
39
|
+
/**
|
|
40
|
+
* isString arr and find buffer
|
|
41
|
+
*/
|
|
42
|
+
if (Array.isArray(msg) && msg.find(item => Buffer.isBuffer(item))) {
|
|
43
|
+
const isBuffer = msg.findIndex(item => Buffer.isBuffer(item));
|
|
44
|
+
const cont = msg
|
|
45
|
+
.map(item => {
|
|
46
|
+
if (typeof item === 'number')
|
|
47
|
+
return String(item);
|
|
48
|
+
return item;
|
|
49
|
+
})
|
|
50
|
+
.filter(element => typeof element === 'string')
|
|
51
|
+
.join('');
|
|
52
|
+
try {
|
|
53
|
+
const dimensions = IMGS.imageSize(msg[isBuffer]);
|
|
54
|
+
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
55
|
+
if (!url)
|
|
56
|
+
return false;
|
|
57
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `, event.id).catch(everyoneError);
|
|
97
58
|
}
|
|
98
|
-
|
|
99
|
-
|
|
59
|
+
catch (err) {
|
|
60
|
+
console.error(err);
|
|
61
|
+
return err;
|
|
100
62
|
}
|
|
101
63
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
64
|
+
const content = Array.isArray(msg)
|
|
65
|
+
? msg.join('')
|
|
66
|
+
: typeof msg === 'string'
|
|
67
|
+
? msg
|
|
68
|
+
: typeof msg === 'number'
|
|
69
|
+
? `${msg}`
|
|
70
|
+
: '';
|
|
71
|
+
if (content == '')
|
|
72
|
+
return false;
|
|
73
|
+
/**
|
|
74
|
+
* https
|
|
75
|
+
*/
|
|
76
|
+
const match = content.match(/<http>(.*?)<\/http>/);
|
|
77
|
+
if (match) {
|
|
78
|
+
const getUrl = match[1];
|
|
79
|
+
const msg = await getUrlbuffer(getUrl);
|
|
80
|
+
if (Buffer.isBuffer(msg)) {
|
|
81
|
+
const url = await ClientKOA.setLocalImg(msg);
|
|
82
|
+
if (!url)
|
|
83
|
+
return false;
|
|
84
|
+
return await ClientNTQQ.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
|
|
85
|
+
}
|
|
105
86
|
}
|
|
87
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, content, event.id).catch(everyoneError);
|
|
106
88
|
}
|
|
107
|
-
return true;
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* 发送表情表态
|
|
111
|
-
* @param mid
|
|
112
|
-
* @param boj { emoji_type: number; emoji_id: string }
|
|
113
|
-
* @returns
|
|
114
|
-
*/
|
|
115
|
-
e.replyEmoji = async (mid, boj) => {
|
|
116
|
-
console.info('temporarily unavailable');
|
|
117
|
-
return false;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* 删除表情表态
|
|
121
|
-
* @param mid
|
|
122
|
-
* @param boj
|
|
123
|
-
* @returns
|
|
124
|
-
*/
|
|
125
|
-
e.deleteEmoji = async (mid, boj) => {
|
|
126
|
-
console.info('temporarily unavailable');
|
|
127
|
-
return false;
|
|
128
89
|
};
|
|
129
90
|
e.msg_txt = event.content;
|
|
130
91
|
e.msg = event.content;
|
|
@@ -17,118 +17,84 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
17
17
|
const masterID = cfg.masterID;
|
|
18
18
|
const e = {
|
|
19
19
|
platform: 'ntqq',
|
|
20
|
-
bot: getBotMsgByNtqq(),
|
|
21
|
-
isMaster: event.author.id == masterID ? true : false,
|
|
22
20
|
event: 'MESSAGES',
|
|
23
21
|
eventType: 'CREATE',
|
|
22
|
+
boundaries: 'publick',
|
|
23
|
+
attribute: 'group',
|
|
24
|
+
bot: getBotMsgByNtqq(),
|
|
25
|
+
isMaster: event.author.id == masterID ? true : false,
|
|
24
26
|
isPrivate: false,
|
|
25
27
|
isRecall: false,
|
|
26
28
|
isGroup: true,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* 消息发送机制
|
|
32
|
-
* @param msg 消息
|
|
33
|
-
* @param img
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
e.reply = async (msg, select) => {
|
|
37
|
-
// is buffer
|
|
38
|
-
if (Buffer.isBuffer(msg)) {
|
|
39
|
-
try {
|
|
40
|
-
const url = await ClientKOA.setLocalImg(msg);
|
|
41
|
-
if (!url)
|
|
42
|
-
return false;
|
|
43
|
-
return await ClientNTQQ.postFilesByGroup(event.group_id, url).catch(everyoneError);
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
console.error(err);
|
|
47
|
-
return err;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (Array.isArray(msg) && msg.find(item => Buffer.isBuffer(item))) {
|
|
51
|
-
const isBuffer = msg.findIndex(item => Buffer.isBuffer(item));
|
|
52
|
-
const cont = msg
|
|
53
|
-
.map(item => {
|
|
54
|
-
if (typeof item === 'number')
|
|
55
|
-
return String(item);
|
|
56
|
-
return item;
|
|
57
|
-
})
|
|
58
|
-
.filter(element => typeof element === 'string')
|
|
59
|
-
.join('');
|
|
60
|
-
try {
|
|
61
|
-
const dimensions = IMGS.imageSize(msg[isBuffer]);
|
|
62
|
-
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
63
|
-
if (!url)
|
|
64
|
-
return false;
|
|
65
|
-
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `, event.id).catch(everyoneError);
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
console.error(err);
|
|
69
|
-
return err;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const content = Array.isArray(msg)
|
|
73
|
-
? msg.join('')
|
|
74
|
-
: typeof msg === 'string'
|
|
75
|
-
? msg
|
|
76
|
-
: typeof msg === 'number'
|
|
77
|
-
? `${msg}`
|
|
78
|
-
: '';
|
|
79
|
-
if (content == '')
|
|
80
|
-
return false;
|
|
29
|
+
attachments: [],
|
|
30
|
+
specials: [],
|
|
81
31
|
/**
|
|
82
|
-
*
|
|
32
|
+
* 消息发送机制
|
|
33
|
+
* @param msg 消息
|
|
34
|
+
* @param img
|
|
35
|
+
* @returns
|
|
83
36
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const getUrl = match[1];
|
|
87
|
-
const msg = await getUrlbuffer(getUrl);
|
|
37
|
+
reply: async (msg, select) => {
|
|
38
|
+
// is buffer
|
|
88
39
|
if (Buffer.isBuffer(msg)) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
40
|
+
try {
|
|
41
|
+
const url = await ClientKOA.setLocalImg(msg);
|
|
42
|
+
if (!url)
|
|
43
|
+
return false;
|
|
44
|
+
return await ClientNTQQ.postFilesByGroup(event.group_id, url).catch(everyoneError);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
console.error(err);
|
|
48
|
+
return err;
|
|
49
|
+
}
|
|
93
50
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
51
|
+
if (Array.isArray(msg) && msg.find(item => Buffer.isBuffer(item))) {
|
|
52
|
+
const isBuffer = msg.findIndex(item => Buffer.isBuffer(item));
|
|
53
|
+
const cont = msg
|
|
54
|
+
.map(item => {
|
|
55
|
+
if (typeof item === 'number')
|
|
56
|
+
return String(item);
|
|
57
|
+
return item;
|
|
58
|
+
})
|
|
59
|
+
.filter(element => typeof element === 'string')
|
|
60
|
+
.join('');
|
|
61
|
+
try {
|
|
62
|
+
const dimensions = IMGS.imageSize(msg[isBuffer]);
|
|
63
|
+
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
64
|
+
if (!url)
|
|
65
|
+
return false;
|
|
66
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `, event.id).catch(everyoneError);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
console.error(err);
|
|
70
|
+
return err;
|
|
103
71
|
}
|
|
104
|
-
return false;
|
|
105
72
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
73
|
+
const content = Array.isArray(msg)
|
|
74
|
+
? msg.join('')
|
|
75
|
+
: typeof msg === 'string'
|
|
76
|
+
? msg
|
|
77
|
+
: typeof msg === 'number'
|
|
78
|
+
? `${msg}`
|
|
79
|
+
: '';
|
|
80
|
+
if (content == '')
|
|
81
|
+
return false;
|
|
82
|
+
/**
|
|
83
|
+
* http
|
|
84
|
+
*/
|
|
85
|
+
const match = content.match(/<http>(.*?)<\/http>/);
|
|
86
|
+
if (match) {
|
|
87
|
+
const getUrl = match[1];
|
|
88
|
+
const msg = await getUrlbuffer(getUrl);
|
|
89
|
+
if (Buffer.isBuffer(msg)) {
|
|
90
|
+
const url = await ClientKOA.setLocalImg(msg);
|
|
91
|
+
if (!url)
|
|
92
|
+
return false;
|
|
93
|
+
return await ClientNTQQ.postFilesByGroup(event.group_id, url).catch(everyoneError);
|
|
94
|
+
}
|
|
109
95
|
}
|
|
96
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, content, event.id).catch(everyoneError);
|
|
110
97
|
}
|
|
111
|
-
return true;
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* 发送表情表态
|
|
115
|
-
* @param mid
|
|
116
|
-
* @param boj { emoji_type: number; emoji_id: string }
|
|
117
|
-
* @returns
|
|
118
|
-
*/
|
|
119
|
-
e.replyEmoji = async (mid, boj) => {
|
|
120
|
-
console.info('temporarily unavailable');
|
|
121
|
-
return false;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* 删除表情表态
|
|
125
|
-
* @param mid
|
|
126
|
-
* @param boj { emoji_type: number; emoji_id: string }
|
|
127
|
-
* @returns
|
|
128
|
-
*/
|
|
129
|
-
e.deleteEmoji = async (mid, boj) => {
|
|
130
|
-
console.info('temporarily unavailable');
|
|
131
|
-
return false;
|
|
132
98
|
};
|
|
133
99
|
/**
|
|
134
100
|
* 消息原文
|
|
@@ -7,7 +7,7 @@ export const segmentNTQQ = {
|
|
|
7
7
|
*/
|
|
8
8
|
at: (uid) => {
|
|
9
9
|
// 暂时用户@
|
|
10
|
-
return
|
|
10
|
+
return `<@${uid}>`;
|
|
11
11
|
},
|
|
12
12
|
/**
|
|
13
13
|
* 艾特全体
|
|
@@ -16,6 +16,9 @@ export const segmentNTQQ = {
|
|
|
16
16
|
atAll: () => {
|
|
17
17
|
return '@everyone';
|
|
18
18
|
},
|
|
19
|
+
/**
|
|
20
|
+
* 本地图片
|
|
21
|
+
*/
|
|
19
22
|
img: getPathBuffer,
|
|
20
23
|
/**
|
|
21
24
|
* 标注GET请求
|
|
@@ -36,3 +39,11 @@ export const segmentNTQQ = {
|
|
|
36
39
|
return `[🔗${title}](${centent})`;
|
|
37
40
|
}
|
|
38
41
|
};
|
|
42
|
+
// 标题
|
|
43
|
+
// 加粗
|
|
44
|
+
// 下划线加粗
|
|
45
|
+
// 斜体
|
|
46
|
+
// 星号斜体
|
|
47
|
+
// 加粗斜体
|
|
48
|
+
// 删除线
|
|
49
|
+
// 块引用
|