alemonjs 1.1.18 → 1.1.19
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/README.md +0 -2
- package/lib/core/apps.js +88 -23
- package/lib/core/cache.js +1 -1
- package/lib/core/ip.js +7 -0
- package/lib/define/main.js +7 -3
- package/lib/discord/alemon/bot.js +1 -1
- package/lib/discord/sdk/wss.js +1 -1
- package/lib/kook/alemon/bot.js +1 -1
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/kook/sdk/ws.js +2 -2
- package/lib/ntqq/alemon/conversation.js +1 -1
- package/lib/ntqq/alemon/group/bot.js +1 -1
- package/lib/ntqq/sdk/api/group.js +2 -2
- package/lib/ntqq/sdk/wss.js +7 -7
- package/lib/one/alemon/bot.js +1 -1
- package/lib/one/alemon/conversation.js +1 -1
- package/lib/qq/alemon/bot.js +1 -1
- package/lib/qq/alemon/conversation.js +1 -1
- package/lib/qq/alemon/message/GUILD_MESSAGES.js +1 -1
- package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/qq/sdk/typings.js +1 -1
- package/lib/qq/sdk/wss.js +4 -4
- package/lib/villa/alemon/message/MESSAGES.js +2 -2
- package/lib/villa/sdk/wss.js +43 -22
- package/package.json +2 -1
- package/types/core/apps.d.ts +50 -21
- package/types/core/cache.d.ts +1 -1
- package/types/core/ip.d.ts +5 -0
- package/types/discord/sdk/config.d.ts +1 -2
- package/types/kook/sdk/config.d.ts +1 -2
- package/types/ntqq/sdk/config.d.ts +3 -3
- package/types/ntqq/sdk/wss.d.ts +2 -2
- package/types/qq/sdk/config.d.ts +10 -3
- package/types/qq/sdk/typings.d.ts +2 -9
- package/types/villa/sdk/config.d.ts +7 -1
- package/types/villa/sdk/types.d.ts +0 -10
- package/types/villa/sdk/wss.d.ts +1 -1
- package/types/villa/villa.d.ts +2 -2
package/README.md
CHANGED
package/lib/core/apps.js
CHANGED
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { setAppMessage, setAppArg, setAppCharacter, setAppEvent, setAppPriority } from './cache.js';
|
|
4
4
|
import { setApp } from './app.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* 应用路径
|
|
7
7
|
* @param url
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
@@ -34,17 +34,19 @@ export function getAppName(url) {
|
|
|
34
34
|
/**
|
|
35
35
|
* 创建应用对象
|
|
36
36
|
* @param url import.meta.url
|
|
37
|
-
|
|
37
|
+
@deprecated createApp()
|
|
38
|
+
* @returns
|
|
38
39
|
*/
|
|
39
40
|
export function createApps(url) {
|
|
40
|
-
return createApp(
|
|
41
|
+
return createApp(url);
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* 创建应用对象
|
|
44
|
-
* @param
|
|
45
|
-
* @returns
|
|
45
|
+
* @param url import.meta.url
|
|
46
|
+
* @returns
|
|
46
47
|
*/
|
|
47
|
-
export function createApp(
|
|
48
|
+
export function createApp(url) {
|
|
49
|
+
const AppName = getAppName(url);
|
|
48
50
|
/**
|
|
49
51
|
* 应用集
|
|
50
52
|
*/
|
|
@@ -56,8 +58,11 @@ export function createApp(AppName) {
|
|
|
56
58
|
/**
|
|
57
59
|
* 设置默认指令规则
|
|
58
60
|
*/
|
|
59
|
-
setAppCharacter(AppName
|
|
60
|
-
|
|
61
|
+
setAppCharacter(AppName);
|
|
62
|
+
/**
|
|
63
|
+
* 应用
|
|
64
|
+
*/
|
|
65
|
+
const app = {
|
|
61
66
|
/**
|
|
62
67
|
* 设置正则最低优先级
|
|
63
68
|
* 当设置了500,而所有优先级为5000时
|
|
@@ -66,30 +71,28 @@ export function createApp(AppName) {
|
|
|
66
71
|
* @param val
|
|
67
72
|
* @returns
|
|
68
73
|
*/
|
|
69
|
-
|
|
74
|
+
priority: (val) => {
|
|
70
75
|
try {
|
|
71
76
|
setAppPriority(AppName, val);
|
|
72
|
-
return true;
|
|
73
77
|
}
|
|
74
78
|
catch (err) {
|
|
75
79
|
console.error('APP setEvent', err);
|
|
76
|
-
return false;
|
|
77
80
|
}
|
|
81
|
+
return app;
|
|
78
82
|
},
|
|
79
83
|
/**
|
|
80
84
|
* 设置正则默认消息
|
|
81
85
|
* @param val
|
|
82
86
|
* @returns
|
|
83
87
|
*/
|
|
84
|
-
|
|
88
|
+
event: (val) => {
|
|
85
89
|
try {
|
|
86
90
|
setAppEvent(AppName, val);
|
|
87
|
-
return true;
|
|
88
91
|
}
|
|
89
92
|
catch (err) {
|
|
90
93
|
console.error('APP setEvent', err);
|
|
91
|
-
return false;
|
|
92
94
|
}
|
|
95
|
+
return app;
|
|
93
96
|
},
|
|
94
97
|
/**
|
|
95
98
|
* 设置指令规则
|
|
@@ -97,12 +100,11 @@ export function createApp(AppName) {
|
|
|
97
100
|
setCharacter: (val) => {
|
|
98
101
|
try {
|
|
99
102
|
setAppCharacter(AppName, val);
|
|
100
|
-
return true;
|
|
101
103
|
}
|
|
102
104
|
catch (err) {
|
|
103
105
|
console.error('APP setCharacter', err);
|
|
104
|
-
return false;
|
|
105
106
|
}
|
|
107
|
+
return app;
|
|
106
108
|
},
|
|
107
109
|
/**
|
|
108
110
|
* 设置扩展参
|
|
@@ -110,31 +112,45 @@ export function createApp(AppName) {
|
|
|
110
112
|
setArg: (fnc) => {
|
|
111
113
|
try {
|
|
112
114
|
setAppArg(AppName, fnc);
|
|
113
|
-
return true;
|
|
114
115
|
}
|
|
115
116
|
catch (err) {
|
|
116
117
|
console.error('APP setArg', err);
|
|
117
|
-
return false;
|
|
118
118
|
}
|
|
119
|
+
return app;
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* 重定义事件
|
|
123
|
+
* @param fnc 回调函数
|
|
124
|
+
* @returns 是否成功定义
|
|
125
|
+
*/
|
|
126
|
+
reSetEvent: (fnc) => {
|
|
127
|
+
try {
|
|
128
|
+
setAppMessage(AppName, fnc);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
console.error('APP setMessage', err);
|
|
132
|
+
}
|
|
133
|
+
return app;
|
|
119
134
|
},
|
|
120
135
|
/**
|
|
121
|
-
*
|
|
136
|
+
* 重定义事件
|
|
122
137
|
* @param fnc 回调函数
|
|
138
|
+
* @deprecated 废弃,请使用reSetEvent()
|
|
123
139
|
* @returns 是否成功定义
|
|
124
140
|
*/
|
|
125
141
|
setMessage: (fnc) => {
|
|
126
142
|
try {
|
|
127
143
|
setAppMessage(AppName, fnc);
|
|
128
|
-
return true;
|
|
129
144
|
}
|
|
130
145
|
catch (err) {
|
|
131
146
|
console.error('APP setMessage', err);
|
|
132
|
-
return false;
|
|
133
147
|
}
|
|
148
|
+
return app;
|
|
134
149
|
},
|
|
135
150
|
/**
|
|
136
151
|
* 创建应用
|
|
137
152
|
* @param app 应用对象
|
|
153
|
+
* @deprecated 废弃,请使用use()
|
|
138
154
|
*/
|
|
139
155
|
component: (urlObject = {}) => {
|
|
140
156
|
try {
|
|
@@ -173,15 +189,62 @@ export function createApp(AppName) {
|
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
191
|
}
|
|
176
|
-
return true;
|
|
177
192
|
}
|
|
178
193
|
catch (err) {
|
|
179
194
|
console.error('APP component', err);
|
|
180
|
-
return false;
|
|
181
195
|
}
|
|
196
|
+
return app;
|
|
197
|
+
},
|
|
198
|
+
/**
|
|
199
|
+
* 创建应用
|
|
200
|
+
* @param app 应用对象
|
|
201
|
+
*/
|
|
202
|
+
use: (urlObject = {}) => {
|
|
203
|
+
try {
|
|
204
|
+
for (const item in urlObject) {
|
|
205
|
+
/**
|
|
206
|
+
* 如果该导出是class
|
|
207
|
+
*/
|
|
208
|
+
if (urlObject[item].prototype) {
|
|
209
|
+
if (!Object.prototype.hasOwnProperty.call(apps, item)) {
|
|
210
|
+
/**
|
|
211
|
+
* 不重名
|
|
212
|
+
*/
|
|
213
|
+
apps[item] = urlObject[item];
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const T = true;
|
|
217
|
+
while (T) {
|
|
218
|
+
const keyName = `${item}$${acount}`;
|
|
219
|
+
if (!Object.prototype.hasOwnProperty.call(apps, keyName)) {
|
|
220
|
+
/**
|
|
221
|
+
* 不重名
|
|
222
|
+
*/
|
|
223
|
+
apps[keyName] = urlObject[item];
|
|
224
|
+
/**
|
|
225
|
+
* 重置为0
|
|
226
|
+
*/
|
|
227
|
+
acount = 0;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
/**
|
|
232
|
+
* 加1
|
|
233
|
+
*/
|
|
234
|
+
acount++;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
console.error('APP use', err);
|
|
242
|
+
}
|
|
243
|
+
return app;
|
|
182
244
|
},
|
|
183
245
|
/**
|
|
184
246
|
* 挂起应用
|
|
247
|
+
* @returns
|
|
185
248
|
*/
|
|
186
249
|
mount: () => {
|
|
187
250
|
try {
|
|
@@ -190,6 +253,8 @@ export function createApp(AppName) {
|
|
|
190
253
|
catch (err) {
|
|
191
254
|
console.error('APP mount', err);
|
|
192
255
|
}
|
|
256
|
+
return app;
|
|
193
257
|
}
|
|
194
258
|
};
|
|
259
|
+
return app;
|
|
195
260
|
}
|
package/lib/core/cache.js
CHANGED
package/lib/core/ip.js
CHANGED
package/lib/define/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import { rebotMap } from './map.js';
|
|
|
3
3
|
import { nodeScripts } from './child_process.js';
|
|
4
4
|
import { command } from './command.js';
|
|
5
5
|
import { AppNameError } from '../log/index.js';
|
|
6
|
-
import { setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom, getPublicIP } from '../core/index.js';
|
|
6
|
+
import { setLanchConfig, loadInit, appsInit, setAppProCoinfg, startChrom, getPublicIP, setPublicIP } from '../core/index.js';
|
|
7
7
|
import { getPupPath, setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
|
|
8
8
|
import { createWeb } from '../koa/index.js';
|
|
9
9
|
import { autoClearFiles } from '../koa/file.js';
|
|
@@ -222,8 +222,12 @@ export async function defineAlemonConfig(Options) {
|
|
|
222
222
|
// 定时清除
|
|
223
223
|
autoClearFiles();
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
if (Options?.server?.ip) {
|
|
226
|
+
setPublicIP(Options?.server?.ip);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
getPublicIP();
|
|
230
|
+
}
|
|
227
231
|
}
|
|
228
232
|
/**
|
|
229
233
|
* ***********
|
package/lib/discord/sdk/wss.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getBotConfig } from './config.js';
|
|
|
10
10
|
export async function createClient(conversation, shard = [0, 1]) {
|
|
11
11
|
const { url } = await gateway();
|
|
12
12
|
if (!url) {
|
|
13
|
-
console.error('
|
|
13
|
+
console.error('[getway] token err');
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
const wsConn = new WebSocket(`${url}?v=10&encoding=json`);
|
package/lib/kook/alemon/bot.js
CHANGED
package/lib/kook/sdk/ws.js
CHANGED
|
@@ -24,11 +24,11 @@ export async function getGatewayUrl(token, url = 'https://www.kookapp.cn/api/v3/
|
|
|
24
24
|
return response.data.data.url;
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
console.error('http err', response.data.message);
|
|
27
|
+
console.error('[getway] http err', response.data.message);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
console.error('token err', error.message);
|
|
31
|
+
console.error('[getway] token err', error.message);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
@@ -35,11 +35,11 @@ export async function gateway() {
|
|
|
35
35
|
return url;
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
|
-
console.error('http err:', null);
|
|
38
|
+
console.error('[getway] http err:', null);
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
41
|
.catch(error => {
|
|
42
|
-
console.error('token err:', error.message);
|
|
42
|
+
console.error('[getway] token err:', error.message);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
package/lib/ntqq/sdk/wss.js
CHANGED
|
@@ -48,7 +48,7 @@ export async function createClient(cfg, conversation) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
setTimeout(() => {
|
|
51
|
-
console.info('reconnecting...');
|
|
51
|
+
console.info('[ws] reconnecting...');
|
|
52
52
|
// 重新starrt
|
|
53
53
|
start();
|
|
54
54
|
// 记录
|
|
@@ -84,26 +84,26 @@ export async function createClient(cfg, conversation) {
|
|
|
84
84
|
}
|
|
85
85
|
// Resumed Event,恢复连接成功
|
|
86
86
|
if (t === 'RESUMED') {
|
|
87
|
-
console.info('restore connection');
|
|
87
|
+
console.info('[ws] restore connection');
|
|
88
88
|
// 重制次数
|
|
89
89
|
counter.setID(0);
|
|
90
90
|
}
|
|
91
91
|
return;
|
|
92
92
|
},
|
|
93
93
|
6: ({ d }) => {
|
|
94
|
-
console.info('connection attempt', d);
|
|
94
|
+
console.info('[ws] connection attempt', d);
|
|
95
95
|
return;
|
|
96
96
|
},
|
|
97
97
|
7: async ({ d }) => {
|
|
98
98
|
// 执行重新连接
|
|
99
|
-
console.info('reconnect', d);
|
|
99
|
+
console.info('[ws] reconnect', d);
|
|
100
100
|
// 取消鉴权发送
|
|
101
101
|
if (power)
|
|
102
102
|
clearInterval(power);
|
|
103
103
|
return;
|
|
104
104
|
},
|
|
105
105
|
9: ({ d, t }) => {
|
|
106
|
-
console.info('parameter error', d);
|
|
106
|
+
console.info('[ws] parameter error', d);
|
|
107
107
|
return;
|
|
108
108
|
},
|
|
109
109
|
10: ({ d }) => {
|
|
@@ -132,13 +132,13 @@ export async function createClient(cfg, conversation) {
|
|
|
132
132
|
},
|
|
133
133
|
11: () => {
|
|
134
134
|
// OpCode 11 Heartbeat ACK 消息,心跳发送成功
|
|
135
|
-
console.info('heartbeat transmission');
|
|
135
|
+
console.info('[ws] heartbeat transmission');
|
|
136
136
|
// 重制次数
|
|
137
137
|
counter.setID(0);
|
|
138
138
|
return;
|
|
139
139
|
},
|
|
140
140
|
12: ({ d }) => {
|
|
141
|
-
console.info('platform data', d);
|
|
141
|
+
console.info('[ws] platform data', d);
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
};
|
package/lib/one/alemon/bot.js
CHANGED
package/lib/qq/alemon/bot.js
CHANGED
package/lib/qq/sdk/typings.js
CHANGED
package/lib/qq/sdk/wss.js
CHANGED
|
@@ -15,11 +15,11 @@ export async function getGatewayUrl() {
|
|
|
15
15
|
return response.url;
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
console.error('http err:', null);
|
|
18
|
+
console.error('[getway] http err:', null);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
console.error('token err:', error.message);
|
|
22
|
+
console.error('[getway] token err:', error.message);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
@@ -118,7 +118,7 @@ export async function createClient(callBack, shard = [0, 4]) {
|
|
|
118
118
|
}
|
|
119
119
|
case 11: {
|
|
120
120
|
// OpCode 11 Heartbeat ACK 消息,心跳发送成功
|
|
121
|
-
console.info('heartbeat transmission');
|
|
121
|
+
console.info('[ws] heartbeat transmission');
|
|
122
122
|
break;
|
|
123
123
|
}
|
|
124
124
|
case 12: {
|
|
@@ -127,7 +127,7 @@ export async function createClient(callBack, shard = [0, 4]) {
|
|
|
127
127
|
}
|
|
128
128
|
});
|
|
129
129
|
ws.on('close', () => {
|
|
130
|
-
console.error('ws
|
|
130
|
+
console.error('[ws] close');
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -52,7 +52,7 @@ export async function MESSAGES(event) {
|
|
|
52
52
|
at_users.push({
|
|
53
53
|
id: item.entity.user_id,
|
|
54
54
|
name,
|
|
55
|
-
avatar: '
|
|
55
|
+
avatar: '',
|
|
56
56
|
bot: false
|
|
57
57
|
});
|
|
58
58
|
continue;
|
|
@@ -61,7 +61,7 @@ export async function MESSAGES(event) {
|
|
|
61
61
|
at_users.push({
|
|
62
62
|
id: item.entity.bot_id,
|
|
63
63
|
name,
|
|
64
|
-
avatar: '
|
|
64
|
+
avatar: '',
|
|
65
65
|
bot: true
|
|
66
66
|
});
|
|
67
67
|
continue;
|
package/lib/villa/sdk/wss.js
CHANGED
|
@@ -37,14 +37,14 @@ export async function createClient(options, conversation) {
|
|
|
37
37
|
setBotConfig('villa_id', options?.villa_id ?? 0);
|
|
38
38
|
const data = await getWebsocketInfo(options.bot_id, options.bot_secret).then(res => res.data);
|
|
39
39
|
if (!data?.websocket_url) {
|
|
40
|
-
console.log('
|
|
40
|
+
console.log('[getway] secret err');
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
let IntervalID = null;
|
|
44
|
+
let size = 0;
|
|
45
|
+
const time = 20 * 1000;
|
|
46
|
+
const getLoginData = () => {
|
|
47
|
+
return {
|
|
48
48
|
ID: counter.getNextID(),
|
|
49
49
|
Flag: 1, // 发送
|
|
50
50
|
BizType: 7,
|
|
@@ -58,19 +58,13 @@ export async function createClient(options, conversation) {
|
|
|
58
58
|
region: '',
|
|
59
59
|
meta: null
|
|
60
60
|
})
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
AppId: data.app_id,
|
|
69
|
-
BodyData: ProtoCommand('PHeartBeat').encode({
|
|
70
|
-
clientTimestamp: `${new Date().getTime()}`
|
|
71
|
-
})
|
|
72
|
-
}));
|
|
73
|
-
}, 20 * 1000);
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const ws = new WebSocket(data.websocket_url);
|
|
64
|
+
ws.on('open', async () => {
|
|
65
|
+
console.info('[ws] login open');
|
|
66
|
+
// login
|
|
67
|
+
ws.send(createMessage(getLoginData()));
|
|
74
68
|
});
|
|
75
69
|
ws.on('message', message => {
|
|
76
70
|
if (Buffer.isBuffer(message)) {
|
|
@@ -85,7 +79,23 @@ export async function createClient(options, conversation) {
|
|
|
85
79
|
console.log('PLoginReply:', LongToNumber(reply));
|
|
86
80
|
}
|
|
87
81
|
if (reply.code)
|
|
88
|
-
console.log('
|
|
82
|
+
console.log('[ws] login err');
|
|
83
|
+
else {
|
|
84
|
+
console.log('[ws] login success');
|
|
85
|
+
size = 0;
|
|
86
|
+
// 20s 心跳
|
|
87
|
+
IntervalID = setInterval(() => {
|
|
88
|
+
ws.send(createMessage({
|
|
89
|
+
ID: counter.getNextID(),
|
|
90
|
+
Flag: 1, // 发送
|
|
91
|
+
BizType: 6,
|
|
92
|
+
AppId: data.app_id,
|
|
93
|
+
BodyData: ProtoCommand('PHeartBeat').encode({
|
|
94
|
+
clientTimestamp: `${new Date().getTime()}`
|
|
95
|
+
})
|
|
96
|
+
}));
|
|
97
|
+
}, time);
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
100
|
else if (obj.bizType == 6) {
|
|
91
101
|
// 心跳
|
|
@@ -93,8 +103,19 @@ export async function createClient(options, conversation) {
|
|
|
93
103
|
if (process.env?.VILLA_WS == 'dev') {
|
|
94
104
|
console.log('PHeartBeatReply:', LongToNumber(reply));
|
|
95
105
|
}
|
|
96
|
-
if (reply.code)
|
|
97
|
-
console.log('心跳错误');
|
|
106
|
+
if (reply.code) {
|
|
107
|
+
console.log('[ws] 心跳错误');
|
|
108
|
+
// 心跳错误,关闭心跳记时器
|
|
109
|
+
if (IntervalID)
|
|
110
|
+
clearInterval(IntervalID);
|
|
111
|
+
if (size < 5) {
|
|
112
|
+
// 重新发送鉴权
|
|
113
|
+
ws.send(createMessage(getLoginData()));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.log('重鉴权次数上限');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
98
119
|
}
|
|
99
120
|
else if (obj.bizType == 8) {
|
|
100
121
|
// 退出登录
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alemonjs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
4
4
|
"description": "DOCS https://alemonjs.com/",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "ts-node alemon.config.ts",
|
|
7
7
|
"tsc": "tsc",
|
|
8
|
+
"ts": "ts-node",
|
|
8
9
|
"doc": "typedoc --options typedoc.json",
|
|
9
10
|
"format": "prettier --write .",
|
|
10
11
|
"lint": "eslint . --ext .js,.ts --fix --ignore-path .gitignore"
|
package/types/core/apps.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 应用路径
|
|
3
3
|
* @param url
|
|
4
4
|
* @returns
|
|
5
5
|
*/
|
|
@@ -22,7 +22,8 @@ export declare function getAppName(url: string | URL): string;
|
|
|
22
22
|
/**
|
|
23
23
|
* 创建应用对象
|
|
24
24
|
* @param url import.meta.url
|
|
25
|
-
|
|
25
|
+
@deprecated createApp()
|
|
26
|
+
* @returns
|
|
26
27
|
*/
|
|
27
28
|
export declare function createApps(url: string): {
|
|
28
29
|
/**
|
|
@@ -33,43 +34,57 @@ export declare function createApps(url: string): {
|
|
|
33
34
|
* @param val
|
|
34
35
|
* @returns
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
+
priority: (val: number) => any;
|
|
37
38
|
/**
|
|
38
39
|
* 设置正则默认消息
|
|
39
40
|
* @param val
|
|
40
41
|
* @returns
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
event: (val: "message" | "MESSAGES") => any;
|
|
43
44
|
/**
|
|
44
45
|
* 设置指令规则
|
|
45
46
|
*/
|
|
46
|
-
setCharacter: (val: "/" | "#") =>
|
|
47
|
+
setCharacter: (val: "/" | "#") => any;
|
|
47
48
|
/**
|
|
48
49
|
* 设置扩展参
|
|
49
50
|
*/
|
|
50
|
-
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) =>
|
|
51
|
+
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) => any;
|
|
52
|
+
/**
|
|
53
|
+
* 重定义事件
|
|
54
|
+
* @param fnc 回调函数
|
|
55
|
+
* @returns 是否成功定义
|
|
56
|
+
*/
|
|
57
|
+
reSetEvent: (fnc: (...args: any[]) => any) => any;
|
|
51
58
|
/**
|
|
52
|
-
*
|
|
59
|
+
* 重定义事件
|
|
53
60
|
* @param fnc 回调函数
|
|
61
|
+
* @deprecated 废弃,请使用reSetEvent()
|
|
54
62
|
* @returns 是否成功定义
|
|
55
63
|
*/
|
|
56
|
-
setMessage: (fnc: (...args: any[]) => any) =>
|
|
64
|
+
setMessage: (fnc: (...args: any[]) => any) => any;
|
|
57
65
|
/**
|
|
58
66
|
* 创建应用
|
|
59
67
|
* @param app 应用对象
|
|
68
|
+
* @deprecated 废弃,请使用use()
|
|
60
69
|
*/
|
|
61
|
-
component: (urlObject?: object) =>
|
|
70
|
+
component: (urlObject?: object) => any;
|
|
71
|
+
/**
|
|
72
|
+
* 创建应用
|
|
73
|
+
* @param app 应用对象
|
|
74
|
+
*/
|
|
75
|
+
use: (urlObject?: object) => any;
|
|
62
76
|
/**
|
|
63
77
|
* 挂起应用
|
|
78
|
+
* @returns
|
|
64
79
|
*/
|
|
65
|
-
mount: () =>
|
|
80
|
+
mount: () => any;
|
|
66
81
|
};
|
|
67
82
|
/**
|
|
68
83
|
* 创建应用对象
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
84
|
+
* @param url import.meta.url
|
|
85
|
+
* @returns
|
|
71
86
|
*/
|
|
72
|
-
export declare function createApp(
|
|
87
|
+
export declare function createApp(url: string): {
|
|
73
88
|
/**
|
|
74
89
|
* 设置正则最低优先级
|
|
75
90
|
* 当设置了500,而所有优先级为5000时
|
|
@@ -78,34 +93,48 @@ export declare function createApp(AppName: string): {
|
|
|
78
93
|
* @param val
|
|
79
94
|
* @returns
|
|
80
95
|
*/
|
|
81
|
-
|
|
96
|
+
priority: (val: number) => any;
|
|
82
97
|
/**
|
|
83
98
|
* 设置正则默认消息
|
|
84
99
|
* @param val
|
|
85
100
|
* @returns
|
|
86
101
|
*/
|
|
87
|
-
|
|
102
|
+
event: (val: 'MESSAGES' | 'message') => any;
|
|
88
103
|
/**
|
|
89
104
|
* 设置指令规则
|
|
90
105
|
*/
|
|
91
|
-
setCharacter: (val: '#' | '/') =>
|
|
106
|
+
setCharacter: (val: '#' | '/') => any;
|
|
92
107
|
/**
|
|
93
108
|
* 设置扩展参
|
|
94
109
|
*/
|
|
95
|
-
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) =>
|
|
110
|
+
setArg: (fnc: (...args: any[]) => any[] | Promise<any[]>) => any;
|
|
111
|
+
/**
|
|
112
|
+
* 重定义事件
|
|
113
|
+
* @param fnc 回调函数
|
|
114
|
+
* @returns 是否成功定义
|
|
115
|
+
*/
|
|
116
|
+
reSetEvent: (fnc: (...args: any[]) => any) => any;
|
|
96
117
|
/**
|
|
97
|
-
*
|
|
118
|
+
* 重定义事件
|
|
98
119
|
* @param fnc 回调函数
|
|
120
|
+
* @deprecated 废弃,请使用reSetEvent()
|
|
99
121
|
* @returns 是否成功定义
|
|
100
122
|
*/
|
|
101
|
-
setMessage: (fnc: (...args: any[]) => any) =>
|
|
123
|
+
setMessage: (fnc: (...args: any[]) => any) => any;
|
|
102
124
|
/**
|
|
103
125
|
* 创建应用
|
|
104
126
|
* @param app 应用对象
|
|
127
|
+
* @deprecated 废弃,请使用use()
|
|
105
128
|
*/
|
|
106
|
-
component: (urlObject?: object) =>
|
|
129
|
+
component: (urlObject?: object) => any;
|
|
130
|
+
/**
|
|
131
|
+
* 创建应用
|
|
132
|
+
* @param app 应用对象
|
|
133
|
+
*/
|
|
134
|
+
use: (urlObject?: object) => any;
|
|
107
135
|
/**
|
|
108
136
|
* 挂起应用
|
|
137
|
+
* @returns
|
|
109
138
|
*/
|
|
110
|
-
mount: () =>
|
|
139
|
+
mount: () => any;
|
|
111
140
|
};
|
package/types/core/cache.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare function getAppCharacter(key: string): "/" | "#";
|
|
|
43
43
|
* @param key 插件名
|
|
44
44
|
* @param val 字符
|
|
45
45
|
*/
|
|
46
|
-
export declare function setAppCharacter(key: string, val
|
|
46
|
+
export declare function setAppCharacter(key: string, val?: '/' | '#'): void;
|
|
47
47
|
/**
|
|
48
48
|
* 删除令规则
|
|
49
49
|
* @param key 插件名
|
package/types/core/ip.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface ClientConfig {
|
|
1
|
+
export interface ClientConfig {
|
|
2
2
|
token: string;
|
|
3
3
|
intent: number;
|
|
4
4
|
}
|
|
@@ -14,4 +14,3 @@ export declare function setBotConfig<T extends keyof ClientConfig>(key: T, val:
|
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
16
|
export declare function getBotConfig<T extends keyof ClientConfig>(key: T): ClientConfig[T] | undefined;
|
|
17
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface ClientConfig {
|
|
1
|
+
export interface ClientConfig {
|
|
2
2
|
token: string;
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
@@ -13,4 +13,3 @@ export declare function setBotConfig<T extends keyof ClientConfig>(key: T, val:
|
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
15
|
export declare function getBotConfig<T extends keyof ClientConfig>(key: T): ClientConfig[T] | undefined;
|
|
16
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface ClientConfig {
|
|
2
2
|
appID: string;
|
|
3
3
|
token: string;
|
|
4
4
|
secret: string;
|
|
@@ -12,10 +12,10 @@ export interface BotCaCheType {
|
|
|
12
12
|
* @param key
|
|
13
13
|
* @param val
|
|
14
14
|
*/
|
|
15
|
-
export declare function setBotConfig<T extends keyof
|
|
15
|
+
export declare function setBotConfig<T extends keyof ClientConfig>(key: T, val: ClientConfig[T]): void;
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @param key
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare function getBotConfig<T extends keyof
|
|
21
|
+
export declare function getBotConfig<T extends keyof ClientConfig>(key: T): ClientConfig[T] | undefined;
|
package/types/ntqq/sdk/wss.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ClientConfig } from './config.js';
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
4
|
* @param cfg
|
|
5
5
|
* @param conversation
|
|
6
6
|
*/
|
|
7
|
-
export declare function createClient(cfg:
|
|
7
|
+
export declare function createClient(cfg: ClientConfig, conversation: (...args: any[]) => any): Promise<void>;
|
|
8
8
|
/**
|
|
9
9
|
|
|
10
10
|
1 Heartbeat Send/Receive 客户端或服务端发送心跳
|
package/types/qq/sdk/config.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntentsEnum } from './typings.js';
|
|
2
|
+
export interface ClientConfig {
|
|
3
|
+
appID: string;
|
|
4
|
+
token: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
intents: IntentsEnum[];
|
|
7
|
+
sandbox: boolean;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
*
|
|
4
11
|
* @param key
|
|
5
12
|
* @param val
|
|
6
13
|
*/
|
|
7
|
-
export declare function setBotConfig<T extends keyof
|
|
14
|
+
export declare function setBotConfig<T extends keyof ClientConfig>(key: T, val: ClientConfig[T]): void;
|
|
8
15
|
/**
|
|
9
16
|
*
|
|
10
17
|
* @param key
|
|
11
18
|
* @returns
|
|
12
19
|
*/
|
|
13
|
-
export declare function getBotConfig<T extends keyof
|
|
20
|
+
export declare function getBotConfig<T extends keyof ClientConfig>(key: T): ClientConfig[T] | undefined;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 订阅枚举
|
|
3
3
|
*/
|
|
4
|
-
export interface BotConfig {
|
|
5
|
-
appID: string;
|
|
6
|
-
token: string;
|
|
7
|
-
secret: string;
|
|
8
|
-
intents: IntentsEnum[];
|
|
9
|
-
sandbox: boolean;
|
|
10
|
-
}
|
|
11
4
|
export type IntentsEnum = (typeof AvailableIntentsEventsEnum)[number];
|
|
12
5
|
/**
|
|
13
|
-
*
|
|
6
|
+
*
|
|
14
7
|
*/
|
|
15
8
|
export declare const AvailableIntentsEventsEnum: readonly ["GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", "DIRECT_MESSAGE", "FORUMS_EVENT", "AUDIO_ACTION", "PUBLIC_GUILD_MESSAGES", "MESSAGE_AUDIT", "INTERACTION"];
|
package/types/villa/sdk/wss.d.ts
CHANGED