alemonjs 1.0.39 → 1.0.40
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/config/login.js +6 -6
- package/lib/core/apps.js +4 -4
- package/lib/core/dealmsg.js +9 -9
- package/lib/core/puppeteer.js +15 -15
- package/lib/core/qrcode.js +2 -2
- package/lib/core/screenshot.js +3 -3
- package/lib/default/types.js +1 -16
- package/lib/define/command.js +1 -1
- package/lib/define/main.js +4 -1
- package/lib/define/map.js +4 -4
- package/lib/koa/client.js +4 -4
- package/lib/koa/img.js +2 -2
- package/lib/kook/alemon/conversation.js +2 -2
- package/lib/kook/index.js +1 -1
- package/lib/kook/kook.js +1 -1
- package/lib/kook/login.js +2 -2
- package/lib/kook/sdk/ws.js +12 -12
- package/lib/log/event.js +2 -2
- package/lib/log/user.js +2 -2
- package/lib/login.js +1 -1
- package/lib/ntqq/alemon/message/C2C_MESSAGE_CREATE.js +3 -3
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +3 -3
- package/lib/ntqq/index.js +1 -1
- package/lib/ntqq/login.js +5 -5
- package/lib/ntqq/ntqq.js +17 -1
- package/lib/ntqq/sdk/wss.js +12 -12
- package/lib/qq/alemon/conversation.js +10 -13
- package/lib/qq/alemon/e.js +4 -4
- package/lib/qq/alemon/message/DIRECT_MESSAGE.js +2 -2
- package/lib/qq/alemon/message/GUILD_MEMBERS.js +2 -2
- package/lib/qq/login.js +2 -2
- package/lib/qq/qq.js +1 -1
- package/lib/qq/sdk/wss.js +5 -5
- package/lib/run.js +2 -2
- package/lib/villa/alemon/conversation.js +1 -1
- package/lib/villa/alemon/message/e.js +4 -4
- package/lib/villa/index.js +1 -1
- package/lib/villa/login.js +2 -2
- package/lib/villa/sdk/client.js +9 -9
- package/lib/villa/sdk/hs.js +1 -1
- package/lib/villa/villa.js +1 -1
- package/package.json +1 -1
- package/run.js +2 -2
- package/types/config/types.d.ts +9 -6
- package/types/default/types.d.ts +27 -157
- package/types/define/types.d.ts +7 -3
- package/types/kook/kook.d.ts +20 -2
- package/types/ntqq/ntqq.d.ts +72 -4
- package/types/qq/qq.d.ts +44 -2
- package/types/villa/villa.d.ts +52 -2
- package/lib/default/typings.js +0 -1
- package/lib/ntqq/sdk/types.js +0 -1
- package/types/default/typings.d.ts +0 -50
- package/types/ntqq/sdk/types.d.ts +0 -11
package/lib/config/login.js
CHANGED
|
@@ -2,10 +2,10 @@ import redis from '../default/redis.js';
|
|
|
2
2
|
import mysql from '../default/mysql.js';
|
|
3
3
|
import server from '../default/server.js';
|
|
4
4
|
import puppeteer from '../default/pup.js';
|
|
5
|
-
import kook from '../kook/kook.js';
|
|
6
|
-
import villa from '../villa/villa.js';
|
|
7
|
-
import qq from '../qq/qq.js';
|
|
8
|
-
import ntqq from '../ntqq/ntqq.js';
|
|
5
|
+
import { defineKOOK as kook } from '../kook/kook.js';
|
|
6
|
+
import { defineVILLA as villa } from '../villa/villa.js';
|
|
7
|
+
import { defineQQ as qq } from '../qq/qq.js';
|
|
8
|
+
import { defineNtqq as ntqq } from '../ntqq/ntqq.js';
|
|
9
9
|
/**
|
|
10
10
|
* *************
|
|
11
11
|
* defset-config
|
|
@@ -43,10 +43,10 @@ export function setBotConfigByKey(key, val) {
|
|
|
43
43
|
try {
|
|
44
44
|
config[key] = {};
|
|
45
45
|
config[key] = val[item];
|
|
46
|
-
console.info('
|
|
46
|
+
console.info('KEY secess');
|
|
47
47
|
}
|
|
48
48
|
catch {
|
|
49
|
-
console.info('
|
|
49
|
+
console.info('KEY err');
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
package/lib/core/apps.js
CHANGED
|
@@ -50,7 +50,7 @@ export function createApp(AppName) {
|
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
52
|
catch (err) {
|
|
53
|
-
console.error('
|
|
53
|
+
console.error('APP setArg', err);
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
},
|
|
@@ -65,7 +65,7 @@ export function createApp(AppName) {
|
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
67
|
catch (err) {
|
|
68
|
-
console.error('
|
|
68
|
+
console.error('APP setMessage', err);
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
},
|
|
@@ -113,7 +113,7 @@ export function createApp(AppName) {
|
|
|
113
113
|
return true;
|
|
114
114
|
}
|
|
115
115
|
catch (err) {
|
|
116
|
-
console.error('
|
|
116
|
+
console.error('APP component', err);
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
},
|
|
@@ -125,7 +125,7 @@ export function createApp(AppName) {
|
|
|
125
125
|
setApp(AppName, apps);
|
|
126
126
|
}
|
|
127
127
|
catch (err) {
|
|
128
|
-
console.error('
|
|
128
|
+
console.error('APP mount', err);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
};
|
package/lib/core/dealmsg.js
CHANGED
|
@@ -205,8 +205,8 @@ async function loadPlugins(dir) {
|
|
|
205
205
|
for await (const appname of apps) {
|
|
206
206
|
if (existsSync(`${dir}/${appname}${main}.${type}`)) {
|
|
207
207
|
await import(`file://${dir}/${appname}${main}.${type}`).catch(err => {
|
|
208
|
-
console.error(
|
|
209
|
-
console.error('
|
|
208
|
+
console.error(`file://${dir}/${appname}${main}.${type}`);
|
|
209
|
+
console.error('APP load', err);
|
|
210
210
|
process.exit();
|
|
211
211
|
});
|
|
212
212
|
}
|
|
@@ -268,7 +268,7 @@ export async function appsInit() {
|
|
|
268
268
|
// 生成指令json
|
|
269
269
|
createPluginHelp();
|
|
270
270
|
// 打印
|
|
271
|
-
console.info('[
|
|
271
|
+
console.info('[APP INIT]', `APPS*${Object.keys(plugins).length} `);
|
|
272
272
|
}
|
|
273
273
|
/**
|
|
274
274
|
* 得到指令大正则
|
|
@@ -348,7 +348,7 @@ export async function InstructionMatching(e) {
|
|
|
348
348
|
APPCACHE[item] = app;
|
|
349
349
|
}
|
|
350
350
|
catch (err) {
|
|
351
|
-
console.
|
|
351
|
+
console.error('APP ERR', err);
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
354
354
|
}
|
|
@@ -373,7 +373,7 @@ export async function InstructionMatching(e) {
|
|
|
373
373
|
.catch(logErr(data));
|
|
374
374
|
if (typeof res != 'boolean') {
|
|
375
375
|
e.reply(res).catch(err => {
|
|
376
|
-
console.error('
|
|
376
|
+
console.error('APP REPLY', err);
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
if (res != false)
|
|
@@ -411,7 +411,7 @@ export async function typeMessage(e) {
|
|
|
411
411
|
APPCACHE[item] = app;
|
|
412
412
|
}
|
|
413
413
|
catch (err) {
|
|
414
|
-
console.error('
|
|
414
|
+
console.error('APP', err);
|
|
415
415
|
return;
|
|
416
416
|
}
|
|
417
417
|
}
|
|
@@ -424,7 +424,7 @@ export async function typeMessage(e) {
|
|
|
424
424
|
const res = await app[data.fncName](...[e, ...(ARGCACHE[data.APP] ?? [])]);
|
|
425
425
|
if (typeof res != 'boolean') {
|
|
426
426
|
e.reply(res).catch(err => {
|
|
427
|
-
console.error('
|
|
427
|
+
console.error('APP REPLY', err);
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
if (res != false)
|
|
@@ -439,13 +439,13 @@ export async function typeMessage(e) {
|
|
|
439
439
|
}
|
|
440
440
|
function logErr(data) {
|
|
441
441
|
return (err) => {
|
|
442
|
-
console.error(`[${data.event}][${data.fncName}][${false}]\n[${err}]`);
|
|
442
|
+
console.error(`[${data.event}]`, `[${data.fncName}]`, `[${false}]\n`, `[${err}]`);
|
|
443
443
|
return false;
|
|
444
444
|
};
|
|
445
445
|
}
|
|
446
446
|
function info(data) {
|
|
447
447
|
return (res) => {
|
|
448
|
-
console.info(`[${data.event}][${data.fncName}][${true}]`);
|
|
448
|
+
console.info(`[${data.event}]`, `[${data.fncName}]`, `[${true}]`);
|
|
449
449
|
return res;
|
|
450
450
|
};
|
|
451
451
|
}
|
package/lib/core/puppeteer.js
CHANGED
|
@@ -59,12 +59,12 @@ export async function pupStartCheck() {
|
|
|
59
59
|
* 重置次数
|
|
60
60
|
*/
|
|
61
61
|
pic = 0;
|
|
62
|
-
console.info('
|
|
62
|
+
console.info('puppeteer close');
|
|
63
63
|
isBrowser = false;
|
|
64
64
|
browser.close().catch(err => {
|
|
65
|
-
console.error('
|
|
65
|
+
console.error('puppeteer close', err);
|
|
66
66
|
});
|
|
67
|
-
console.info('
|
|
67
|
+
console.info('puppeteer reopen');
|
|
68
68
|
if (!(await startChrom()))
|
|
69
69
|
return false;
|
|
70
70
|
pic++;
|
|
@@ -90,24 +90,24 @@ export async function screenshotByFile(htmlPath, Options) {
|
|
|
90
90
|
const page = await browser.newPage();
|
|
91
91
|
await page.goto(`file://${htmlPath}`, { timeout });
|
|
92
92
|
const body = await page.$(tab);
|
|
93
|
-
console.info('
|
|
93
|
+
console.info('puppeteer success');
|
|
94
94
|
const buff = await body
|
|
95
95
|
.screenshot(SOptions)
|
|
96
96
|
.catch(err => {
|
|
97
|
-
console.error('
|
|
97
|
+
console.error('puppeteer', 'screenshot', err);
|
|
98
98
|
return false;
|
|
99
99
|
});
|
|
100
100
|
await page.close().catch((err) => {
|
|
101
|
-
console.error('
|
|
101
|
+
console.error('puppeteer', 'page close', err);
|
|
102
102
|
});
|
|
103
103
|
if (!buff) {
|
|
104
|
-
console.error('
|
|
104
|
+
console.error('puppeteer', htmlPath);
|
|
105
105
|
return false;
|
|
106
106
|
}
|
|
107
107
|
return buff;
|
|
108
108
|
}
|
|
109
109
|
catch (err) {
|
|
110
|
-
console.error('
|
|
110
|
+
console.error('puppeteer newPage', err);
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -132,11 +132,11 @@ export async function screenshotByUrl(val) {
|
|
|
132
132
|
timeout: timeout ?? 120000,
|
|
133
133
|
waitUntil
|
|
134
134
|
});
|
|
135
|
-
console.info(`open ${isurl}`);
|
|
135
|
+
console.info(`screenshot open ${isurl}`);
|
|
136
136
|
const body = await page.$(tab);
|
|
137
137
|
if (!body) {
|
|
138
138
|
await page.close();
|
|
139
|
-
console.error('
|
|
139
|
+
console.error('screenshot tab err');
|
|
140
140
|
return false;
|
|
141
141
|
}
|
|
142
142
|
await new Promise(resolve => setTimeout(resolve, time ?? 1000));
|
|
@@ -147,18 +147,18 @@ export async function screenshotByUrl(val) {
|
|
|
147
147
|
path: ''
|
|
148
148
|
})
|
|
149
149
|
.catch(err => {
|
|
150
|
-
console.error('
|
|
150
|
+
console.error('screenshot page body', err);
|
|
151
151
|
return false;
|
|
152
152
|
});
|
|
153
153
|
await page.close();
|
|
154
154
|
if (!buff) {
|
|
155
|
-
console.error('
|
|
155
|
+
console.error('screenshot buffer err', url);
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
158
|
return buff;
|
|
159
159
|
}
|
|
160
160
|
catch (err) {
|
|
161
|
-
console.error('
|
|
161
|
+
console.error('screenshot newPage', err);
|
|
162
162
|
return false;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -170,12 +170,12 @@ export async function startChrom() {
|
|
|
170
170
|
try {
|
|
171
171
|
browser = await puppeteer.launch(LaunchCfg);
|
|
172
172
|
isBrowser = true;
|
|
173
|
-
console.info('
|
|
173
|
+
console.info('puppeteer open success');
|
|
174
174
|
return true;
|
|
175
175
|
}
|
|
176
176
|
catch (err) {
|
|
177
177
|
isBrowser = false;
|
|
178
|
-
console.error('
|
|
178
|
+
console.error('puppeteer err', err);
|
|
179
179
|
return false;
|
|
180
180
|
}
|
|
181
181
|
}
|
package/lib/core/qrcode.js
CHANGED
|
@@ -45,7 +45,7 @@ export const getBuffer = (localpath) => {
|
|
|
45
45
|
reject(err);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
console.info('
|
|
48
|
+
console.info('buffer read', localpath);
|
|
49
49
|
resolve(bufferData);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
@@ -60,7 +60,7 @@ export const setBuffer = (localpath, bufferData) => {
|
|
|
60
60
|
writeFile(localpath, bufferData, (err) => {
|
|
61
61
|
if (err)
|
|
62
62
|
throw err;
|
|
63
|
-
console.info('
|
|
63
|
+
console.info('buffer set', localpath);
|
|
64
64
|
});
|
|
65
65
|
return;
|
|
66
66
|
};
|
package/lib/core/screenshot.js
CHANGED
|
@@ -37,7 +37,7 @@ function watchCT(tplFile) {
|
|
|
37
37
|
* 模板改变,删除模板
|
|
38
38
|
*/
|
|
39
39
|
delete html[tplFile];
|
|
40
|
-
console.info('
|
|
40
|
+
console.info('html update', tplFile);
|
|
41
41
|
})
|
|
42
42
|
.on('close', () => {
|
|
43
43
|
/**
|
|
@@ -110,7 +110,7 @@ export function createHtml(AppName, tplFile) {
|
|
|
110
110
|
/**
|
|
111
111
|
* 打印反馈生成后的地址
|
|
112
112
|
*/
|
|
113
|
-
console.info('
|
|
113
|
+
console.info('html create', AdressHtml);
|
|
114
114
|
}
|
|
115
115
|
return {
|
|
116
116
|
// 模板地址
|
|
@@ -194,7 +194,7 @@ export function createStr(Options) {
|
|
|
194
194
|
/**
|
|
195
195
|
* 打印反馈生成后的地址
|
|
196
196
|
*/
|
|
197
|
-
console.info('
|
|
197
|
+
console.info('html create', AdressHtml);
|
|
198
198
|
}
|
|
199
199
|
return {
|
|
200
200
|
control,
|
package/lib/default/types.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* *****
|
|
3
|
-
* ntqq订阅
|
|
4
|
-
* ****
|
|
5
|
-
*/
|
|
6
|
-
export var NtQQEventsEnum;
|
|
7
|
-
(function (NtQQEventsEnum) {
|
|
8
|
-
/**
|
|
9
|
-
* 群聊消息
|
|
10
|
-
*/
|
|
11
|
-
NtQQEventsEnum["GROUP_AT_MESSAGE_CREATE"] = "GROUP_AT_MESSAGE_CREATE";
|
|
12
|
-
/**
|
|
13
|
-
* 单聊消息
|
|
14
|
-
*/
|
|
15
|
-
NtQQEventsEnum["C2C_MESSAGE_CREATE"] = "C2C_MESSAGE_CREATE";
|
|
16
|
-
})(NtQQEventsEnum = NtQQEventsEnum || (NtQQEventsEnum = {}));
|
|
1
|
+
export {};
|
package/lib/define/command.js
CHANGED
package/lib/define/main.js
CHANGED
|
@@ -145,7 +145,7 @@ export async function defineAlemonConfig(Options) {
|
|
|
145
145
|
* ********
|
|
146
146
|
*/
|
|
147
147
|
if (!Options?.login || Object.keys(Options?.login ?? {}).length == 0) {
|
|
148
|
-
console.info('
|
|
148
|
+
console.info('login no bot');
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* ***********
|
|
@@ -224,6 +224,9 @@ export async function defineAlemonConfig(Options) {
|
|
|
224
224
|
* ************
|
|
225
225
|
*/
|
|
226
226
|
if (Options?.mount !== false) {
|
|
227
|
+
if (Options?.regex) {
|
|
228
|
+
setAppProCoinfg('regex', Options?.regex);
|
|
229
|
+
}
|
|
227
230
|
await appsInit();
|
|
228
231
|
}
|
|
229
232
|
/**
|
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('
|
|
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('
|
|
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('
|
|
27
|
+
console.error('KOOK bot open err');
|
|
28
28
|
return false;
|
|
29
29
|
});
|
|
30
30
|
},
|
|
@@ -32,7 +32,7 @@ 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('
|
|
35
|
+
console.error('NTQQ bot open err');
|
|
36
36
|
return false;
|
|
37
37
|
});
|
|
38
38
|
}
|
package/lib/koa/client.js
CHANGED
|
@@ -42,17 +42,17 @@ export function createWeb(val, logFnc) {
|
|
|
42
42
|
*/
|
|
43
43
|
function handlePortConflict(err) {
|
|
44
44
|
if (err.code === 'EADDRINUSE') {
|
|
45
|
-
console.error(
|
|
45
|
+
console.error(`port ${currentPort} occupied, attempting to start a new port...`);
|
|
46
46
|
currentPort++;
|
|
47
47
|
size++;
|
|
48
48
|
if (size >= 10) {
|
|
49
|
-
console.error('
|
|
49
|
+
console.error('find port err');
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
createApp(currentPort);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
console.error('
|
|
55
|
+
console.error('An error occurred while starting the application', err);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -67,7 +67,7 @@ export function createWeb(val, logFnc) {
|
|
|
67
67
|
.listen(port, async () => {
|
|
68
68
|
if (logFnc)
|
|
69
69
|
await logFnc(port);
|
|
70
|
-
console.info('
|
|
70
|
+
console.info('server', `http://[::]:${port}`);
|
|
71
71
|
})
|
|
72
72
|
.on('error', handlePortConflict);
|
|
73
73
|
}
|
package/lib/koa/img.js
CHANGED
|
@@ -61,10 +61,10 @@ export async function setLocalImg(img) {
|
|
|
61
61
|
const filename = `${Math.floor(Math.random() * imgSize)}.${(await fileTypeFromBuffer(img))?.ext}`;
|
|
62
62
|
// 文件路径
|
|
63
63
|
const imagePath = join(process.cwd(), imgDir, filename);
|
|
64
|
-
console.
|
|
64
|
+
console.info('server create', imagePath);
|
|
65
65
|
// 将图片保存到文件系统中
|
|
66
66
|
writeFileSync(imagePath, img);
|
|
67
67
|
const url = `${http}://${ip}:${port}${imgRouter}/${filename}`;
|
|
68
|
-
console.info('
|
|
68
|
+
console.info('server url', url);
|
|
69
69
|
return url;
|
|
70
70
|
}
|
|
@@ -36,7 +36,7 @@ const ConversationMap = {
|
|
|
36
36
|
* @param event
|
|
37
37
|
*/
|
|
38
38
|
[255]: (event) => {
|
|
39
|
-
console.info('
|
|
39
|
+
console.info('system message', new Date(event.msg_timestamp));
|
|
40
40
|
// console.info('event', event)
|
|
41
41
|
}
|
|
42
42
|
};
|
|
@@ -50,7 +50,7 @@ export async function callBackByKOOK(event) {
|
|
|
50
50
|
return await ConversationMap[event.type](event);
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
// console.info('
|
|
53
|
+
// console.info('kook new message', event.type)
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
}
|
package/lib/kook/index.js
CHANGED
package/lib/kook/kook.js
CHANGED
package/lib/kook/login.js
CHANGED
|
@@ -14,7 +14,7 @@ export async function checkRobotByKOOK() {
|
|
|
14
14
|
setBotConfigByKey('kook', config);
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
-
console.error('
|
|
18
|
-
console.error('
|
|
17
|
+
console.error('login', '-----------------------');
|
|
18
|
+
console.error('login', 'KOOK config err');
|
|
19
19
|
return false;
|
|
20
20
|
}
|
package/lib/kook/sdk/ws.js
CHANGED
|
@@ -26,11 +26,11 @@ export async function getGatewayUrl(token, url = 'https://www.kookapp.cn/api/v3/
|
|
|
26
26
|
return response.data.data.url;
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
console.error('
|
|
29
|
+
console.error('http err', response.data.message);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
console.error('
|
|
33
|
+
console.error('token err', error.message);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -50,7 +50,7 @@ export async function createClient(token, callBack) {
|
|
|
50
50
|
if (gatewayUrl) {
|
|
51
51
|
const ws = new WebSocket(gatewayUrl);
|
|
52
52
|
ws.on('open', () => {
|
|
53
|
-
console.info('
|
|
53
|
+
console.info('token ok');
|
|
54
54
|
});
|
|
55
55
|
/**
|
|
56
56
|
* 标记是否已连接
|
|
@@ -115,12 +115,12 @@ export async function createClient(token, callBack) {
|
|
|
115
115
|
*/
|
|
116
116
|
case 1: {
|
|
117
117
|
if (data && data.code === 0) {
|
|
118
|
-
console.info('
|
|
118
|
+
console.info('ws ok');
|
|
119
119
|
sessionID = data.session_id;
|
|
120
120
|
isConnected = true;
|
|
121
121
|
}
|
|
122
122
|
else {
|
|
123
|
-
console.info('
|
|
123
|
+
console.info('ws err');
|
|
124
124
|
}
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
@@ -128,7 +128,7 @@ export async function createClient(token, callBack) {
|
|
|
128
128
|
* 心跳,ping
|
|
129
129
|
*/
|
|
130
130
|
case 2: {
|
|
131
|
-
console.info('
|
|
131
|
+
console.info('ws ping');
|
|
132
132
|
ws.send(JSON.stringify({
|
|
133
133
|
s: 3
|
|
134
134
|
}));
|
|
@@ -138,21 +138,21 @@ export async function createClient(token, callBack) {
|
|
|
138
138
|
* 心跳,pong
|
|
139
139
|
*/
|
|
140
140
|
case 3: {
|
|
141
|
-
console.info('
|
|
141
|
+
console.info('ws pong');
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
145
|
* resume, 恢复会话
|
|
146
146
|
*/
|
|
147
147
|
case 4: {
|
|
148
|
-
console.info('
|
|
148
|
+
console.info('ws resume');
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* reconnect, 要求客户端断开当前连接重新连接
|
|
153
153
|
*/
|
|
154
154
|
case 5: {
|
|
155
|
-
console.info('
|
|
155
|
+
console.info('ws Connection failed, reconnect');
|
|
156
156
|
/**
|
|
157
157
|
* 处理 RECONNECT 信令
|
|
158
158
|
* 断开当前连接并进行重新连接
|
|
@@ -171,11 +171,11 @@ export async function createClient(token, callBack) {
|
|
|
171
171
|
* resume ack
|
|
172
172
|
*/
|
|
173
173
|
case 6: {
|
|
174
|
-
console.info('
|
|
174
|
+
console.info('ws resume ack');
|
|
175
175
|
break;
|
|
176
176
|
}
|
|
177
177
|
default: {
|
|
178
|
-
console.info('
|
|
178
|
+
console.info('ws define');
|
|
179
179
|
break;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -192,7 +192,7 @@ export async function createClient(token, callBack) {
|
|
|
192
192
|
}
|
|
193
193
|
}, 30000);
|
|
194
194
|
ws.on('close', () => {
|
|
195
|
-
console.error('
|
|
195
|
+
console.error('ws close');
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
package/lib/log/event.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param text
|
|
6
6
|
*/
|
|
7
7
|
export function AlemonJSEventLog(event, eventType) {
|
|
8
|
-
console.info(
|
|
8
|
+
console.info(`[${event}] [${eventType}] [${true}]`);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 打印用户错误信息
|
|
@@ -15,6 +15,6 @@ export function AlemonJSEventLog(event, eventType) {
|
|
|
15
15
|
* @param text
|
|
16
16
|
*/
|
|
17
17
|
export function AlemonJSEventError(err, event, eventType) {
|
|
18
|
-
console.info(
|
|
18
|
+
console.info(`[${event}] [${eventType}] [${false}]`);
|
|
19
19
|
console.error(err);
|
|
20
20
|
}
|
package/lib/log/user.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param text
|
|
6
6
|
*/
|
|
7
7
|
export function AlemonJSLog(channel_id, user_name, text) {
|
|
8
|
-
console.info(
|
|
8
|
+
console.info(`[${channel_id}] [${user_name}] [${true}] ${text}`);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 打印用户错误信息
|
|
@@ -15,6 +15,6 @@ export function AlemonJSLog(channel_id, user_name, text) {
|
|
|
15
15
|
* @param text
|
|
16
16
|
*/
|
|
17
17
|
export function AlemonJSError(err, channel_id, user_name, text) {
|
|
18
|
-
console.info(
|
|
18
|
+
console.info(`[${channel_id}] [${user_name}] [${false}] ${text}`);
|
|
19
19
|
console.error(err);
|
|
20
20
|
}
|
package/lib/login.js
CHANGED
|
@@ -88,7 +88,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
88
88
|
for (const item of arr) {
|
|
89
89
|
try {
|
|
90
90
|
if (item.type == 'qq_ark' || item.type == 'qq_embed') {
|
|
91
|
-
console.info('
|
|
91
|
+
console.info('temporarily unavailable');
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
@@ -109,7 +109,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
109
109
|
* @returns
|
|
110
110
|
*/
|
|
111
111
|
e.replyEmoji = async (mid, boj) => {
|
|
112
|
-
console.info('
|
|
112
|
+
console.info('temporarily unavailable');
|
|
113
113
|
return false;
|
|
114
114
|
};
|
|
115
115
|
/**
|
|
@@ -119,7 +119,7 @@ export const C2C_MESSAGE_CREATE = async (event) => {
|
|
|
119
119
|
* @returns
|
|
120
120
|
*/
|
|
121
121
|
e.deleteEmoji = async (mid, boj) => {
|
|
122
|
-
console.info('
|
|
122
|
+
console.info('temporarily unavailable');
|
|
123
123
|
return false;
|
|
124
124
|
};
|
|
125
125
|
e.msg_txt = event.content;
|
|
@@ -116,7 +116,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
116
116
|
for (const item of arr) {
|
|
117
117
|
try {
|
|
118
118
|
if (item.type == 'qq_ark' || item.type == 'qq_embed') {
|
|
119
|
-
console.info('
|
|
119
|
+
console.info('temporarily unavailable');
|
|
120
120
|
return false;
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
@@ -135,7 +135,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
135
135
|
* @returns
|
|
136
136
|
*/
|
|
137
137
|
e.replyEmoji = async (mid, boj) => {
|
|
138
|
-
console.info('
|
|
138
|
+
console.info('temporarily unavailable');
|
|
139
139
|
return false;
|
|
140
140
|
};
|
|
141
141
|
/**
|
|
@@ -145,7 +145,7 @@ export const GROUP_AT_MESSAGE_CREATE = async (event) => {
|
|
|
145
145
|
* @returns
|
|
146
146
|
*/
|
|
147
147
|
e.deleteEmoji = async (mid, boj) => {
|
|
148
|
-
console.info('
|
|
148
|
+
console.info('temporarily unavailable');
|
|
149
149
|
return false;
|
|
150
150
|
};
|
|
151
151
|
/**
|
package/lib/ntqq/index.js
CHANGED
|
@@ -38,7 +38,7 @@ export async function createAlemonByNtqq() {
|
|
|
38
38
|
* 设置配置
|
|
39
39
|
*/
|
|
40
40
|
setBotNTQQConfig(g);
|
|
41
|
-
console.info('
|
|
41
|
+
console.info('refresh', data.expires_in, 's');
|
|
42
42
|
setTimeout(bal, data.expires_in * 1000);
|
|
43
43
|
};
|
|
44
44
|
setTimeout(bal, data.expires_in * 1000);
|