alemonjs 1.0.51 → 1.0.53
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/client/types.js +1 -0
- package/lib/client/typing.js +1 -0
- package/lib/config/login.js +3 -1
- package/lib/core/ip.js +3 -2
- package/lib/core/typings.js +2 -1
- package/lib/define/main.js +11 -3
- package/lib/define/map.js +12 -4
- package/lib/koa/img.js +7 -4
- package/lib/kook/alemon/segment.js +2 -0
- package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +4 -4
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +4 -4
- package/lib/ntqq/alemon/segment.js +3 -1
- package/lib/one/alemon/bot.js +11 -0
- package/lib/one/alemon/conversation.js +26 -0
- package/lib/one/alemon/message/DIRECT_MESSAGE.js +296 -0
- package/lib/one/alemon/message/MESSAGES.js +337 -0
- package/lib/one/alemon/segment.js +35 -0
- package/lib/one/index.js +22 -0
- package/lib/one/login.js +19 -0
- package/lib/one/one.js +6 -0
- package/lib/one/sdk/types.js +84 -0
- package/lib/one/sdk/wss.js +36 -0
- package/lib/qq/alemon/segment.js +2 -0
- package/lib/villa/alemon/message/GUILDS.js +2 -2
- package/lib/villa/alemon/message/GUILD_MEMBERS.js +2 -2
- package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +2 -2
- package/lib/villa/alemon/message/MESSAGES.js +2 -2
- package/lib/villa/alemon/message/MESSAGE_AUDIT.js +2 -2
- package/lib/villa/alemon/segment.js +3 -1
- package/lib/villa/sdk/client.js +6 -4
- package/package.json +3 -1
- package/types/client/types.d.ts +154 -0
- package/types/client/typing.d.ts +72 -0
- package/types/config/types.d.ts +2 -0
- package/types/core/ip.d.ts +2 -1
- package/types/core/typings.d.ts +10 -238
- package/types/default/types.d.ts +5 -0
- package/types/define/map.d.ts +1 -0
- package/types/koa/types.d.ts +5 -0
- package/types/kook/alemon/segment.d.ts +2 -0
- package/types/ntqq/alemon/segment.d.ts +3 -1
- package/types/one/alemon/bot.d.ts +8 -0
- package/types/one/alemon/conversation.d.ts +10 -0
- package/types/one/alemon/message/DIRECT_MESSAGE.d.ts +9 -0
- package/types/one/alemon/message/MESSAGES.d.ts +9 -0
- package/types/one/alemon/segment.d.ts +27 -0
- package/types/one/index.d.ts +1 -0
- package/types/one/login.d.ts +7 -0
- package/types/one/one.d.ts +29 -0
- package/types/one/sdk/types.d.ts +310 -0
- package/types/one/sdk/wss.d.ts +9 -0
- package/types/qq/alemon/segment.d.ts +2 -0
- package/types/villa/alemon/segment.d.ts +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/config/login.js
CHANGED
|
@@ -6,6 +6,7 @@ import { defineKOOK as kook } from '../kook/kook.js';
|
|
|
6
6
|
import { defineVILLA as villa } from '../villa/villa.js';
|
|
7
7
|
import { defineQQ as qq } from '../qq/qq.js';
|
|
8
8
|
import { defineNtqq as ntqq } from '../ntqq/ntqq.js';
|
|
9
|
+
import { defineOne as one } from '../one/one.js';
|
|
9
10
|
/**
|
|
10
11
|
* *************
|
|
11
12
|
* defset-config
|
|
@@ -19,7 +20,8 @@ const config = {
|
|
|
19
20
|
qq,
|
|
20
21
|
ntqq,
|
|
21
22
|
server,
|
|
22
|
-
puppeteer
|
|
23
|
+
puppeteer,
|
|
24
|
+
one
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
27
|
* 设置机器人基础配置
|
package/lib/core/ip.js
CHANGED
|
@@ -4,11 +4,12 @@ let myIp;
|
|
|
4
4
|
* 得到本机IP地址
|
|
5
5
|
* @returns
|
|
6
6
|
*/
|
|
7
|
-
export async function getIP() {
|
|
7
|
+
export async function getIP(options = {}) {
|
|
8
8
|
if (myIp)
|
|
9
9
|
return myIp;
|
|
10
10
|
return await publicIp({
|
|
11
|
-
|
|
11
|
+
onlyHttps: true,
|
|
12
|
+
...options
|
|
12
13
|
}).then(ip => {
|
|
13
14
|
if (/^(\d{1,3}\.){3}\d{1,3}$/.test(ip))
|
|
14
15
|
myIp = ip;
|
package/lib/core/typings.js
CHANGED
package/lib/define/main.js
CHANGED
|
@@ -4,7 +4,7 @@ import { nodeScripts } from './child_process.js';
|
|
|
4
4
|
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
5
5
|
import { ClientNTQQ } from '../ntqq/sdk/index.js';
|
|
6
6
|
import { command } from './command.js';
|
|
7
|
-
import { createApp, setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom } from '../core/index.js';
|
|
7
|
+
import { createApp, setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom, getIP } from '../core/index.js';
|
|
8
8
|
import { getPupPath, setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
|
|
9
9
|
import { createWeb } from '../koa/index.js';
|
|
10
10
|
import { autoClearImages } from '../koa/img.js';
|
|
@@ -130,6 +130,10 @@ export async function defineAlemonConfig(Options) {
|
|
|
130
130
|
// 自定义覆盖
|
|
131
131
|
setBotConfigByKey('villa', Options.login.villa);
|
|
132
132
|
}
|
|
133
|
+
if (Options.login?.one) {
|
|
134
|
+
// 自定义覆盖
|
|
135
|
+
setBotConfigByKey('one', Options.login.one);
|
|
136
|
+
}
|
|
133
137
|
for (const item in Options.login) {
|
|
134
138
|
if (arr.indexOf(item) != -1)
|
|
135
139
|
continue;
|
|
@@ -155,8 +159,12 @@ export async function defineAlemonConfig(Options) {
|
|
|
155
159
|
if (Options?.server?.state != false) {
|
|
156
160
|
// 创建server端
|
|
157
161
|
createWeb(Options?.server);
|
|
158
|
-
|
|
159
|
-
|
|
162
|
+
if (Options?.server?.clear != false) {
|
|
163
|
+
// 定时清除
|
|
164
|
+
autoClearImages();
|
|
165
|
+
}
|
|
166
|
+
// 缓存ip
|
|
167
|
+
getIP();
|
|
160
168
|
}
|
|
161
169
|
/**
|
|
162
170
|
* ***********
|
package/lib/define/map.js
CHANGED
|
@@ -8,7 +8,7 @@ export const rebotMap = {
|
|
|
8
8
|
const { createAlemonByQQ: qq } = await import('../qq/index.js');
|
|
9
9
|
return qq().catch(err => {
|
|
10
10
|
console.error(err);
|
|
11
|
-
console.error('QQ
|
|
11
|
+
console.error('QQ BOT open err');
|
|
12
12
|
return false;
|
|
13
13
|
});
|
|
14
14
|
},
|
|
@@ -16,7 +16,7 @@ export const rebotMap = {
|
|
|
16
16
|
const { createAlemonByVilla: villa } = await import('../villa/index.js');
|
|
17
17
|
return villa().catch(err => {
|
|
18
18
|
console.error(err);
|
|
19
|
-
console.error('VILLA
|
|
19
|
+
console.error('VILLA BOT open err');
|
|
20
20
|
return false;
|
|
21
21
|
});
|
|
22
22
|
},
|
|
@@ -24,7 +24,7 @@ export const rebotMap = {
|
|
|
24
24
|
const { createAlemonByKOOK: kook } = await import('../kook/index.js');
|
|
25
25
|
return kook().catch(err => {
|
|
26
26
|
console.error(err);
|
|
27
|
-
console.error('KOOK
|
|
27
|
+
console.error('KOOK BOT open err');
|
|
28
28
|
return false;
|
|
29
29
|
});
|
|
30
30
|
},
|
|
@@ -32,7 +32,15 @@ export const rebotMap = {
|
|
|
32
32
|
const { createAlemonByNtqq: ntqq } = await import('../ntqq/index.js');
|
|
33
33
|
return ntqq().catch(err => {
|
|
34
34
|
console.error(err);
|
|
35
|
-
console.error('NTQQ
|
|
35
|
+
console.error('NTQQ BOT open err');
|
|
36
|
+
return false;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
one: async () => {
|
|
40
|
+
const { createAlemonByONE: one } = await import('../one/index.js');
|
|
41
|
+
return one().catch(err => {
|
|
42
|
+
console.error(err);
|
|
43
|
+
console.error('ONE BOT open err');
|
|
36
44
|
return false;
|
|
37
45
|
});
|
|
38
46
|
}
|
package/lib/koa/img.js
CHANGED
|
@@ -56,10 +56,13 @@ export async function setLocalImg(img) {
|
|
|
56
56
|
const imgSize = getServerConfig('imgSize');
|
|
57
57
|
const port = getServerConfig('port');
|
|
58
58
|
const http = getServerConfig('http');
|
|
59
|
-
let ip =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
let ip = getServerConfig('ip');
|
|
60
|
+
if (ip == 'localhost') {
|
|
61
|
+
const ipp = await getIP();
|
|
62
|
+
if (ipp)
|
|
63
|
+
ip = ipp;
|
|
64
|
+
}
|
|
65
|
+
console.log('测试1');
|
|
63
66
|
// 生成文件名
|
|
64
67
|
const filename = `${Math.floor(Math.random() * imgSize)}.${(await fileTypeFromBuffer(img))?.ext}`;
|
|
65
68
|
// 文件路径
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getPathBuffer } from '../../core/buffer.js';
|
|
1
2
|
export const segmentKOOK = {
|
|
2
3
|
/**
|
|
3
4
|
* 艾特某人
|
|
@@ -14,6 +15,7 @@ export const segmentKOOK = {
|
|
|
14
15
|
atAll: () => {
|
|
15
16
|
return `(met)all(met)`;
|
|
16
17
|
},
|
|
18
|
+
img: getPathBuffer,
|
|
17
19
|
/**
|
|
18
20
|
* 标注GET请求
|
|
19
21
|
* @returns
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InstructionMatching, getUrlbuffer } from '../../../core/index.js';
|
|
2
2
|
import { ClientNTQQ } from '../../sdk/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { segmentNTQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByNtqq } from '../bot.js';
|
|
5
5
|
import IMGS from 'image-size';
|
|
6
6
|
import { ClientKOA } from '../../../koa/index.js';
|
|
@@ -56,7 +56,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
56
56
|
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
57
57
|
if (!url)
|
|
58
58
|
return false;
|
|
59
|
-
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `,
|
|
59
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, `${cont} `, event.id).catch(everyoneError);
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
62
|
console.error(err);
|
|
@@ -86,7 +86,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
86
86
|
return await ClientNTQQ.postFilesByUsers(event.author.user_openid, url).catch(everyoneError);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
return await ClientNTQQ.postMessageByUser(event.author.user_openid, content,
|
|
89
|
+
return await ClientNTQQ.postMessageByUser(event.author.user_openid, content, event.id).catch(everyoneError);
|
|
90
90
|
};
|
|
91
91
|
e.replyCard = async (arr) => {
|
|
92
92
|
for (const item of arr) {
|
|
@@ -137,7 +137,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
137
137
|
e.user_name = '柠檬冲水';
|
|
138
138
|
e.channel_id = event.author.user_openid; // 私聊重置为用户open编号
|
|
139
139
|
e.guild_id = event.author.user_openid;
|
|
140
|
-
e.segment =
|
|
140
|
+
e.segment = segmentNTQQ;
|
|
141
141
|
e.at_users = [];
|
|
142
142
|
e.at_user = {
|
|
143
143
|
id: '0',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { InstructionMatching, getUrlbuffer } from '../../../core/index.js';
|
|
2
2
|
import { ClientNTQQ } from '../../sdk/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { segmentNTQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByNtqq } from '../bot.js';
|
|
5
5
|
import { getBotConfigByKey } from '../../../config/index.js';
|
|
6
6
|
import { ClientKOA } from '../../../koa/index.js';
|
|
@@ -62,7 +62,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
62
62
|
const url = await ClientKOA.setLocalImg(msg[isBuffer]);
|
|
63
63
|
if (!url)
|
|
64
64
|
return false;
|
|
65
|
-
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `,
|
|
65
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, `${cont} `, event.id).catch(everyoneError);
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
68
68
|
console.error(err);
|
|
@@ -92,7 +92,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
92
92
|
return await ClientNTQQ.postFilesByGroup(event.group_id, url).catch(everyoneError);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
return await ClientNTQQ.postMessageByGroup(event.group_id, content,
|
|
95
|
+
return await ClientNTQQ.postMessageByGroup(event.group_id, content, event.id).catch(everyoneError);
|
|
96
96
|
};
|
|
97
97
|
e.replyCard = async (arr) => {
|
|
98
98
|
for (const item of arr) {
|
|
@@ -165,7 +165,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
165
165
|
/**
|
|
166
166
|
* 模块
|
|
167
167
|
*/
|
|
168
|
-
e.segment =
|
|
168
|
+
e.segment = segmentNTQQ;
|
|
169
169
|
/**
|
|
170
170
|
* 被艾特的用户
|
|
171
171
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { getPathBuffer } from '../../core/buffer.js';
|
|
2
|
+
export const segmentNTQQ = {
|
|
2
3
|
/**
|
|
3
4
|
* 艾特某人
|
|
4
5
|
* @param uid
|
|
@@ -15,6 +16,7 @@ export const segmentQQ = {
|
|
|
15
16
|
atAll: () => {
|
|
16
17
|
return '@everyone';
|
|
17
18
|
},
|
|
19
|
+
img: getPathBuffer,
|
|
18
20
|
/**
|
|
19
21
|
* 标注GET请求
|
|
20
22
|
* @returns
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { setBotMsgByONE } from './bot.js';
|
|
2
|
+
import { DIRECT_MESSAGE } from './message/DIRECT_MESSAGE.js';
|
|
3
|
+
import { MESSAGES } from './message/MESSAGES.js';
|
|
4
|
+
/**
|
|
5
|
+
* 会话控制
|
|
6
|
+
*/
|
|
7
|
+
export const conversation = {
|
|
8
|
+
meta: async (socket, event) => {
|
|
9
|
+
if (event.status && event.status.bots) {
|
|
10
|
+
const bot = event.status.bots[0];
|
|
11
|
+
setBotMsgByONE({
|
|
12
|
+
id: bot.self.user_id,
|
|
13
|
+
name: bot.self.nickname,
|
|
14
|
+
avatar: 'string' // 头像是什么
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
message: async (socket, event) => {
|
|
19
|
+
if (event.detail_type == 'private') {
|
|
20
|
+
DIRECT_MESSAGE(socket, event);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
MESSAGES(socket, event);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
2
|
+
import { InstructionMatching, getUrlbuffer } from '../../../core/index.js';
|
|
3
|
+
import { getBotMsgByONE } from '../bot.js';
|
|
4
|
+
import { segmentONE } from '../segment.js';
|
|
5
|
+
import { AlemonJSError, AlemonJSLog } from '../../../log/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* 公信事件
|
|
8
|
+
* @param socket
|
|
9
|
+
* @param event
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export async function DIRECT_MESSAGE(socket, event) {
|
|
13
|
+
const cfg = getBotConfigByKey('one');
|
|
14
|
+
const masterID = cfg.masterID;
|
|
15
|
+
const e = {
|
|
16
|
+
platform: 'one',
|
|
17
|
+
bot: getBotMsgByONE(),
|
|
18
|
+
isMaster: event.user_id == masterID ? true : false,
|
|
19
|
+
event: 'MESSAGES',
|
|
20
|
+
eventType: 'CREATE',
|
|
21
|
+
// 撤回
|
|
22
|
+
isRecall: false,
|
|
23
|
+
boundaries: 'publick',
|
|
24
|
+
isGroup: event.detail_type == 'private' ? true : false,
|
|
25
|
+
// 是私
|
|
26
|
+
isPrivate: event.detail_type == 'private' ? true : false,
|
|
27
|
+
// 是私聊
|
|
28
|
+
attribute: event.detail_type == 'private' ? 'single' : 'group'
|
|
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
|
+
socket.send(JSON.stringify({
|
|
41
|
+
// 行为 发送消息
|
|
42
|
+
action: 'send_message',
|
|
43
|
+
params: {
|
|
44
|
+
// 私聊回复
|
|
45
|
+
detail_type: event.detail_type,
|
|
46
|
+
// 用户
|
|
47
|
+
user_id: event.user_id,
|
|
48
|
+
// 消息体
|
|
49
|
+
message: [
|
|
50
|
+
{
|
|
51
|
+
type: 'image',
|
|
52
|
+
data: {
|
|
53
|
+
file_id: `base64://${msg.toString('base64')}`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
echo: '1234'
|
|
59
|
+
}));
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.error(err);
|
|
64
|
+
return err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(msg) && msg.find(item => Buffer.isBuffer(item))) {
|
|
68
|
+
const isBuffer = msg.findIndex(item => Buffer.isBuffer(item));
|
|
69
|
+
const cont = msg
|
|
70
|
+
.map(item => {
|
|
71
|
+
if (typeof item === 'number')
|
|
72
|
+
return String(item);
|
|
73
|
+
return item;
|
|
74
|
+
})
|
|
75
|
+
.filter(element => typeof element === 'string')
|
|
76
|
+
.join('');
|
|
77
|
+
try {
|
|
78
|
+
const buff = msg[isBuffer];
|
|
79
|
+
socket.send(JSON.stringify({
|
|
80
|
+
// 行为 发送消息
|
|
81
|
+
action: 'send_message',
|
|
82
|
+
params: {
|
|
83
|
+
// 私聊回复
|
|
84
|
+
detail_type: event.detail_type,
|
|
85
|
+
// 用户
|
|
86
|
+
user_id: event.user_id,
|
|
87
|
+
// 消息体
|
|
88
|
+
message: [
|
|
89
|
+
{
|
|
90
|
+
type: 'text',
|
|
91
|
+
data: {
|
|
92
|
+
text: cont
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'image',
|
|
97
|
+
data: {
|
|
98
|
+
file_id: `base64://${buff.toString('base64')}`
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
echo: '1234'
|
|
104
|
+
}));
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
console.error(err);
|
|
109
|
+
return err;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const content = Array.isArray(msg)
|
|
113
|
+
? msg.join('')
|
|
114
|
+
: typeof msg === 'string'
|
|
115
|
+
? msg
|
|
116
|
+
: typeof msg === 'number'
|
|
117
|
+
? `${msg}`
|
|
118
|
+
: '';
|
|
119
|
+
if (content == '')
|
|
120
|
+
return false;
|
|
121
|
+
/**
|
|
122
|
+
* http
|
|
123
|
+
*/
|
|
124
|
+
const match = content.match(/<http>(.*?)<\/http>/);
|
|
125
|
+
if (match) {
|
|
126
|
+
const getUrl = match[1];
|
|
127
|
+
const msg = await getUrlbuffer(getUrl);
|
|
128
|
+
if (Buffer.isBuffer(msg)) {
|
|
129
|
+
if (event.detail_type == 'private') {
|
|
130
|
+
socket.send(JSON.stringify({
|
|
131
|
+
// 行为 发送消息 send_group_msg
|
|
132
|
+
action: 'send_message',
|
|
133
|
+
params: {
|
|
134
|
+
// 私聊回复
|
|
135
|
+
detail_type: event.detail_type,
|
|
136
|
+
// 用户
|
|
137
|
+
user_id: event.user_id,
|
|
138
|
+
// 消息体
|
|
139
|
+
message: [
|
|
140
|
+
{
|
|
141
|
+
type: 'image',
|
|
142
|
+
data: {
|
|
143
|
+
file_id: `base64://${msg.toString('base64')}`
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
echo: '1234'
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// 群聊
|
|
153
|
+
socket.send(JSON.stringify({
|
|
154
|
+
action: 'send_group_msg',
|
|
155
|
+
params: {
|
|
156
|
+
group_id: '',
|
|
157
|
+
// 消息体
|
|
158
|
+
message: [
|
|
159
|
+
{
|
|
160
|
+
type: 'image',
|
|
161
|
+
data: {
|
|
162
|
+
file_id: `base64://${msg.toString('base64')}`
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
echo: '1234'
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 需要增加解析器
|
|
174
|
+
* <@xxxx> <@everyone>
|
|
175
|
+
*/
|
|
176
|
+
socket.send(JSON.stringify({
|
|
177
|
+
// 行为 发送消息
|
|
178
|
+
action: 'send_message',
|
|
179
|
+
params: {
|
|
180
|
+
// 私聊回复
|
|
181
|
+
detail_type: event.detail_type,
|
|
182
|
+
// 用户
|
|
183
|
+
user_id: event.user_id,
|
|
184
|
+
// 消息体
|
|
185
|
+
message: [
|
|
186
|
+
{
|
|
187
|
+
type: 'text',
|
|
188
|
+
data: {
|
|
189
|
+
text: content
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
echo: '1234'
|
|
195
|
+
}));
|
|
196
|
+
return true;
|
|
197
|
+
};
|
|
198
|
+
e.replyCard = async (arr) => {
|
|
199
|
+
for (const item of arr) {
|
|
200
|
+
try {
|
|
201
|
+
if (item.type == 'qq_ark' || item.type == 'qq_embed') {
|
|
202
|
+
console.info('temporarily unavailable');
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
console.error(err);
|
|
209
|
+
return err;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* 发送表情表态
|
|
216
|
+
* @param mid
|
|
217
|
+
* @param boj { emoji_type: number; emoji_id: string }
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
e.replyEmoji = async (mid, boj) => {
|
|
221
|
+
console.info('temporarily unavailable');
|
|
222
|
+
return false;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* 删除表情表态
|
|
226
|
+
* @param mid
|
|
227
|
+
* @param boj { emoji_type: number; emoji_id: string }
|
|
228
|
+
* @returns
|
|
229
|
+
*/
|
|
230
|
+
e.deleteEmoji = async (mid, boj) => {
|
|
231
|
+
console.info('temporarily unavailable');
|
|
232
|
+
return false;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* 消息原文
|
|
236
|
+
*/
|
|
237
|
+
e.msg_txt = event.raw_message;
|
|
238
|
+
/**
|
|
239
|
+
* 消息
|
|
240
|
+
*/
|
|
241
|
+
e.msg = event.raw_message.trim();
|
|
242
|
+
/**
|
|
243
|
+
* 消息编号
|
|
244
|
+
*/
|
|
245
|
+
e.msg_id = event.message_id;
|
|
246
|
+
/**
|
|
247
|
+
* 用户编号
|
|
248
|
+
*/
|
|
249
|
+
e.user_id = event.user_id;
|
|
250
|
+
/**
|
|
251
|
+
* 用户头像
|
|
252
|
+
*/
|
|
253
|
+
e.user_avatar =
|
|
254
|
+
event.platform == 'qq'
|
|
255
|
+
? `https://q1.qlogo.cn/g?b=qq&s=0&nk=${event.user_id}`
|
|
256
|
+
: 'https://q1.qlogo.cn/g?b=qq&s=0&nk=1715713638';
|
|
257
|
+
/**
|
|
258
|
+
* 用户名
|
|
259
|
+
*/
|
|
260
|
+
e.user_name = event.sender.nickname;
|
|
261
|
+
/**
|
|
262
|
+
* 子频道编号
|
|
263
|
+
*/
|
|
264
|
+
e.channel_id = '';
|
|
265
|
+
/**
|
|
266
|
+
* 频道编号
|
|
267
|
+
*/
|
|
268
|
+
e.guild_id = '';
|
|
269
|
+
/**
|
|
270
|
+
* 模块
|
|
271
|
+
*/
|
|
272
|
+
e.segment = segmentONE;
|
|
273
|
+
/**
|
|
274
|
+
* 被艾特的用户
|
|
275
|
+
*/
|
|
276
|
+
e.at_users = [];
|
|
277
|
+
/**
|
|
278
|
+
* 艾特消息处理
|
|
279
|
+
*/
|
|
280
|
+
e.at = false;
|
|
281
|
+
/**
|
|
282
|
+
* 存在at
|
|
283
|
+
*/
|
|
284
|
+
if (e.at) {
|
|
285
|
+
/**
|
|
286
|
+
* 得到第一个艾特
|
|
287
|
+
*/
|
|
288
|
+
e.at_user = e.at_users.find(item => item.bot != true);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* 业务处理
|
|
292
|
+
*/
|
|
293
|
+
return await InstructionMatching(e)
|
|
294
|
+
.then(() => AlemonJSLog(e.channel_id, e.user_name, e.msg_txt))
|
|
295
|
+
.catch(err => AlemonJSError(err, e.channel_id, e.user_name, e.msg_txt));
|
|
296
|
+
}
|