alemonjs 1.0.2 → 1.0.4
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 +6 -22
- package/bin/main.js +17 -0
- package/lib/alemon/dealmsg.js +66 -18
- package/lib/alemon/puppeteer.js +9 -16
- package/lib/config/index.js +8 -0
- package/lib/config/login.js +87 -0
- package/lib/config/pup.js +75 -0
- package/lib/config/types.js +1 -0
- package/lib/default/login/discord.js +16 -0
- package/lib/default/login/kook.js +5 -0
- package/lib/default/login/ntqq.js +17 -0
- package/lib/default/login/qq.js +16 -0
- package/lib/default/login/villa.js +13 -0
- package/lib/default/mysql.js +7 -0
- package/lib/default/pup.js +15 -0
- package/lib/default/redis.js +6 -0
- package/lib/default/server.js +4 -0
- package/lib/{types.js → default/types.js} +8 -2
- package/lib/define/api.js +23 -0
- package/lib/define/child_process.js +10 -0
- package/lib/define/command.js +22 -0
- package/lib/define/index.js +7 -0
- package/lib/define/main.js +205 -0
- package/lib/define/map.js +47 -0
- package/lib/define/plugin.js +25 -0
- package/lib/define/types.js +1 -0
- package/lib/discord/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/discord/index.js +1 -1
- package/lib/discord/login.js +18 -63
- package/lib/index.js +23 -7
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/kook/index.js +1 -1
- package/lib/kook/login.js +7 -40
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +1 -1
- package/lib/ntqq/index.js +2 -2
- package/lib/ntqq/login.js +15 -64
- package/lib/ntqq/sdk/wss.js +0 -1
- package/lib/qq/alemon/conversation.js +1 -1
- package/lib/qq/alemon/message/MESSAGE.js +1 -1
- package/lib/qq/index.js +14 -3
- package/lib/qq/login.js +3 -125
- package/lib/villa/alemon/message/MESSAGES.js +1 -1
- package/lib/villa/index.js +1 -1
- package/lib/villa/login.js +11 -52
- package/package.json +62 -60
- package/types/alemon/dealmsg.d.ts +10 -0
- package/types/config/index.d.ts +8 -0
- package/types/config/pup.d.ts +7 -0
- package/types/config/types.d.ts +18 -0
- package/types/default/login/discord.d.ts +8 -0
- package/types/default/login/kook.d.ts +6 -0
- package/types/default/login/ntqq.d.ts +16 -0
- package/types/default/login/qq.d.ts +12 -0
- package/types/default/login/villa.d.ts +14 -0
- package/types/default/mysql.d.ts +8 -0
- package/types/default/pup.d.ts +3 -0
- package/types/default/redis.d.ts +7 -0
- package/types/default/server.d.ts +5 -0
- package/types/default/types.d.ts +300 -0
- package/types/define/api.d.ts +30 -0
- package/types/define/child_process.d.ts +1 -0
- package/types/define/command.d.ts +1 -0
- package/types/define/index.d.ts +7 -0
- package/types/define/main.d.ts +20 -0
- package/types/define/map.d.ts +12 -0
- package/types/define/plugin.d.ts +4 -0
- package/types/define/types.d.ts +111 -0
- package/types/index.d.ts +17 -2
- package/lib/bot.js +0 -98
- package/lib/config.js +0 -25
- package/lib/login.js +0 -115
- package/types/bot.d.ts +0 -15
- package/types/config.d.ts +0 -12
- package/types/types.d.ts +0 -135
- /package/types/{login.d.ts → config/login.d.ts} +0 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { GatewayIntentBits } from 'discord.js';
|
|
2
|
+
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
3
|
+
/**
|
|
4
|
+
* *****
|
|
5
|
+
* login
|
|
6
|
+
* ****
|
|
7
|
+
*/
|
|
8
|
+
export interface LoginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* discord配置
|
|
11
|
+
*/
|
|
12
|
+
discord?: DiscordOptions;
|
|
13
|
+
/**
|
|
14
|
+
* kook配置
|
|
15
|
+
*/
|
|
16
|
+
kook?: KookOptionsg;
|
|
17
|
+
/**
|
|
18
|
+
* villa配置
|
|
19
|
+
*/
|
|
20
|
+
villa?: VillaOptions;
|
|
21
|
+
/**
|
|
22
|
+
* qq配置
|
|
23
|
+
*/
|
|
24
|
+
qq?: QqGuildOptions;
|
|
25
|
+
/**
|
|
26
|
+
* ntqq配置
|
|
27
|
+
*/
|
|
28
|
+
ntqq?: NtQQOptions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* ****
|
|
32
|
+
* redis
|
|
33
|
+
* *****
|
|
34
|
+
*/
|
|
35
|
+
export interface RedisOptions {
|
|
36
|
+
/**
|
|
37
|
+
* 地址
|
|
38
|
+
*/
|
|
39
|
+
host?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 端口
|
|
42
|
+
*/
|
|
43
|
+
port?: number;
|
|
44
|
+
/**
|
|
45
|
+
* 密码
|
|
46
|
+
*/
|
|
47
|
+
password?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 数据库名
|
|
50
|
+
*/
|
|
51
|
+
db?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* ***
|
|
55
|
+
* mysql
|
|
56
|
+
* **
|
|
57
|
+
*/
|
|
58
|
+
export interface MysqlOptions {
|
|
59
|
+
/**
|
|
60
|
+
* 地址
|
|
61
|
+
*/
|
|
62
|
+
host?: string;
|
|
63
|
+
/**
|
|
64
|
+
* 端口
|
|
65
|
+
*/
|
|
66
|
+
port?: number;
|
|
67
|
+
/**
|
|
68
|
+
* 用户名
|
|
69
|
+
*/
|
|
70
|
+
user?: string;
|
|
71
|
+
/**
|
|
72
|
+
* 密码
|
|
73
|
+
*/
|
|
74
|
+
password?: string;
|
|
75
|
+
/**
|
|
76
|
+
* 数据库名
|
|
77
|
+
*/
|
|
78
|
+
database?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* **
|
|
82
|
+
* discord
|
|
83
|
+
* **
|
|
84
|
+
*/
|
|
85
|
+
export interface DiscordOptions {
|
|
86
|
+
/**
|
|
87
|
+
* 钥匙
|
|
88
|
+
*/
|
|
89
|
+
token?: string;
|
|
90
|
+
/**
|
|
91
|
+
* 主人编号
|
|
92
|
+
*/
|
|
93
|
+
masterID?: string;
|
|
94
|
+
/**
|
|
95
|
+
* 主人密码
|
|
96
|
+
*/
|
|
97
|
+
password?: string;
|
|
98
|
+
/**
|
|
99
|
+
* 事件订阅
|
|
100
|
+
*/
|
|
101
|
+
intents?: GatewayIntentBits[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* ****
|
|
105
|
+
* kook
|
|
106
|
+
* ***
|
|
107
|
+
*/
|
|
108
|
+
export interface KookOptionsg {
|
|
109
|
+
/**
|
|
110
|
+
* 钥匙
|
|
111
|
+
*/
|
|
112
|
+
token?: string;
|
|
113
|
+
/**
|
|
114
|
+
* 主人编号
|
|
115
|
+
*/
|
|
116
|
+
masterID?: string;
|
|
117
|
+
/**
|
|
118
|
+
* 主人密码
|
|
119
|
+
*/
|
|
120
|
+
password?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* ****
|
|
124
|
+
* villa
|
|
125
|
+
* *****
|
|
126
|
+
*/
|
|
127
|
+
export interface VillaOptions {
|
|
128
|
+
/**
|
|
129
|
+
* 机器人编号
|
|
130
|
+
*/
|
|
131
|
+
bot_id?: string;
|
|
132
|
+
/**
|
|
133
|
+
* 密钥
|
|
134
|
+
*/
|
|
135
|
+
secret?: string;
|
|
136
|
+
/**
|
|
137
|
+
* 公匙
|
|
138
|
+
*/
|
|
139
|
+
pub_key?: string;
|
|
140
|
+
/**
|
|
141
|
+
* 主人编号
|
|
142
|
+
*/
|
|
143
|
+
masterID?: string;
|
|
144
|
+
/**
|
|
145
|
+
* 主人密码
|
|
146
|
+
*/
|
|
147
|
+
password?: string;
|
|
148
|
+
/**
|
|
149
|
+
* 回调地址
|
|
150
|
+
*/
|
|
151
|
+
url?: string;
|
|
152
|
+
/**
|
|
153
|
+
* 端口
|
|
154
|
+
*/
|
|
155
|
+
port?: number;
|
|
156
|
+
/**
|
|
157
|
+
* 随机数大小
|
|
158
|
+
*/
|
|
159
|
+
size?: number;
|
|
160
|
+
/**
|
|
161
|
+
* 图片路由
|
|
162
|
+
*/
|
|
163
|
+
img_url?: string;
|
|
164
|
+
/**
|
|
165
|
+
* 本地缓存图地址
|
|
166
|
+
*/
|
|
167
|
+
IMAGE_DIR?: string;
|
|
168
|
+
/**
|
|
169
|
+
* 头模式
|
|
170
|
+
*/
|
|
171
|
+
http?: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* *****
|
|
175
|
+
* ntqq订阅
|
|
176
|
+
* ****
|
|
177
|
+
*/
|
|
178
|
+
export declare enum NtQQEventsEnum {
|
|
179
|
+
/**
|
|
180
|
+
* 群聊消息
|
|
181
|
+
*/
|
|
182
|
+
GROUP_AT_MESSAGE_CREATE = "GROUP_AT_MESSAGE_CREATE",
|
|
183
|
+
/**
|
|
184
|
+
* 单聊消息
|
|
185
|
+
*/
|
|
186
|
+
C2C_MESSAGE_CREATE = "C2C_MESSAGE_CREATE"
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* *****
|
|
190
|
+
* ntqq
|
|
191
|
+
* ****
|
|
192
|
+
*/
|
|
193
|
+
export interface NtQQOptions {
|
|
194
|
+
/**
|
|
195
|
+
* 应用编号
|
|
196
|
+
*/
|
|
197
|
+
appID?: string;
|
|
198
|
+
/**
|
|
199
|
+
* 钥匙
|
|
200
|
+
*/
|
|
201
|
+
token?: string;
|
|
202
|
+
/**
|
|
203
|
+
* 密钥
|
|
204
|
+
*/
|
|
205
|
+
secret?: string;
|
|
206
|
+
/**
|
|
207
|
+
* 主人编号
|
|
208
|
+
*/
|
|
209
|
+
masterID?: string;
|
|
210
|
+
/**
|
|
211
|
+
* 主人密码
|
|
212
|
+
*/
|
|
213
|
+
password?: string;
|
|
214
|
+
/**
|
|
215
|
+
* 事件订阅
|
|
216
|
+
*/
|
|
217
|
+
intents?: NtQQEventsEnum[];
|
|
218
|
+
/**
|
|
219
|
+
* 分片
|
|
220
|
+
*/
|
|
221
|
+
shard?: number[];
|
|
222
|
+
/**
|
|
223
|
+
* 端口
|
|
224
|
+
*/
|
|
225
|
+
port?: number;
|
|
226
|
+
/**
|
|
227
|
+
* 随机数大小
|
|
228
|
+
*/
|
|
229
|
+
size?: number;
|
|
230
|
+
/**
|
|
231
|
+
* 图片路由
|
|
232
|
+
*/
|
|
233
|
+
img_url?: string;
|
|
234
|
+
/**
|
|
235
|
+
* 本地缓存图地址
|
|
236
|
+
*/
|
|
237
|
+
IMAGE_DIR?: string;
|
|
238
|
+
/**
|
|
239
|
+
* 头模式
|
|
240
|
+
*/
|
|
241
|
+
http?: string;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* ******
|
|
245
|
+
* qq
|
|
246
|
+
* *****
|
|
247
|
+
*/
|
|
248
|
+
export interface QqGuildOptions {
|
|
249
|
+
/**
|
|
250
|
+
* 应用编号
|
|
251
|
+
*/
|
|
252
|
+
appID?: string;
|
|
253
|
+
/**
|
|
254
|
+
* 钥匙
|
|
255
|
+
*/
|
|
256
|
+
token?: string;
|
|
257
|
+
/**
|
|
258
|
+
* 密钥
|
|
259
|
+
*/
|
|
260
|
+
secret?: string;
|
|
261
|
+
/**
|
|
262
|
+
* 分片
|
|
263
|
+
*/
|
|
264
|
+
shard?: number[];
|
|
265
|
+
/**
|
|
266
|
+
* 主人编号
|
|
267
|
+
*/
|
|
268
|
+
masterID?: string;
|
|
269
|
+
/**
|
|
270
|
+
* 主人密码
|
|
271
|
+
*/
|
|
272
|
+
password?: string;
|
|
273
|
+
/**
|
|
274
|
+
* 事件订阅
|
|
275
|
+
*/
|
|
276
|
+
intents?: AvailableIntentsEventsEnum[];
|
|
277
|
+
/**
|
|
278
|
+
* 是否是私域
|
|
279
|
+
*/
|
|
280
|
+
isPrivate?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* 是否是沙盒环境
|
|
283
|
+
*/
|
|
284
|
+
sandbox?: boolean;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* ******
|
|
288
|
+
* server
|
|
289
|
+
* *****
|
|
290
|
+
*/
|
|
291
|
+
export interface ServerOptions {
|
|
292
|
+
/**
|
|
293
|
+
* 地址
|
|
294
|
+
*/
|
|
295
|
+
host?: string;
|
|
296
|
+
/**
|
|
297
|
+
* 端口
|
|
298
|
+
*/
|
|
299
|
+
port?: number;
|
|
300
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ***********
|
|
3
|
+
* SDK接口管理
|
|
4
|
+
* ***********
|
|
5
|
+
*/
|
|
6
|
+
import { IOpenAPI } from 'qq-guild-bot';
|
|
7
|
+
import { ClientAPIByQQ as ClientByNTQQ } from '../ntqq/sdk/index.js';
|
|
8
|
+
declare global {
|
|
9
|
+
var clientApiByQQ: IOpenAPI;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* discord客户端
|
|
13
|
+
*/
|
|
14
|
+
export declare const ClientDISCORD: {};
|
|
15
|
+
/**
|
|
16
|
+
* qq客户端
|
|
17
|
+
*/
|
|
18
|
+
export declare const ClientQQ: any;
|
|
19
|
+
/**
|
|
20
|
+
* kook客户端
|
|
21
|
+
*/
|
|
22
|
+
export declare const ClientKOOK: any;
|
|
23
|
+
/**
|
|
24
|
+
* ntqq客户端
|
|
25
|
+
*/
|
|
26
|
+
export declare const ClientNTQQ: typeof ClientByNTQQ;
|
|
27
|
+
/**
|
|
28
|
+
* villa客户端
|
|
29
|
+
*/
|
|
30
|
+
export declare const ClientVILLA: any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function nodeScripts(name?: string, file?: string, ars?: any[]): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function command(cmd: string): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AlemonOptions } from './types.js';
|
|
2
|
+
import { ClientAPIByQQ as ClientByNTQQ } from '../ntqq/sdk/index.js';
|
|
3
|
+
export declare const setAuthenticationByNtqq: typeof ClientByNTQQ.setAuthentication;
|
|
4
|
+
/**
|
|
5
|
+
* 应用模块集成
|
|
6
|
+
* @param AppName
|
|
7
|
+
* @param name
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function ApplicationTools(AppName: string, name?: string): any;
|
|
11
|
+
/**
|
|
12
|
+
* 得到载入配置
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAlemonConfig(): AlemonOptions;
|
|
16
|
+
/**
|
|
17
|
+
* 机器人配置
|
|
18
|
+
* @param Options
|
|
19
|
+
*/
|
|
20
|
+
export declare function defineAlemonConfig(Options?: AlemonOptions): Promise<void>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { PuppeteerLaunchOptions } from 'puppeteer';
|
|
2
|
+
import { LoginOptions, MysqlOptions, RedisOptions, ServerOptions } from '../default/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* ******
|
|
5
|
+
* config
|
|
6
|
+
* ******
|
|
7
|
+
*/
|
|
8
|
+
export interface AlemonOptions {
|
|
9
|
+
app?: {
|
|
10
|
+
/**
|
|
11
|
+
* 应用名称
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 可执行的依赖包
|
|
16
|
+
*/
|
|
17
|
+
component?: any[];
|
|
18
|
+
/**
|
|
19
|
+
* 指令预览
|
|
20
|
+
*/
|
|
21
|
+
regJSon?: {
|
|
22
|
+
/**
|
|
23
|
+
* 是否生成
|
|
24
|
+
* defaukt true
|
|
25
|
+
*/
|
|
26
|
+
create?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 生成地址
|
|
29
|
+
* defaukt /publick/defset
|
|
30
|
+
*/
|
|
31
|
+
address?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 独立模块配置
|
|
35
|
+
*/
|
|
36
|
+
module?: {
|
|
37
|
+
/**
|
|
38
|
+
* 输入规则
|
|
39
|
+
*/
|
|
40
|
+
input?: string;
|
|
41
|
+
/**
|
|
42
|
+
* 输出规则
|
|
43
|
+
*/
|
|
44
|
+
output?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* 关闭指定应用
|
|
48
|
+
*/
|
|
49
|
+
close?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* 重定义消息对象
|
|
52
|
+
* @param args
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
redefineMessage?: (...args: any[]) => any;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 插件配置
|
|
59
|
+
*/
|
|
60
|
+
plugin?: {
|
|
61
|
+
/**
|
|
62
|
+
* 插件目录
|
|
63
|
+
*/
|
|
64
|
+
directory?: string;
|
|
65
|
+
/**
|
|
66
|
+
* 挂载文件
|
|
67
|
+
* default true
|
|
68
|
+
*/
|
|
69
|
+
mountFile?: string;
|
|
70
|
+
/**
|
|
71
|
+
* 插件名匹配规则
|
|
72
|
+
*/
|
|
73
|
+
RegexOpen?: RegExp;
|
|
74
|
+
/**
|
|
75
|
+
* 插件名关闭规则
|
|
76
|
+
*/
|
|
77
|
+
RegexClose?: RegExp;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* login配置
|
|
81
|
+
*/
|
|
82
|
+
login?: LoginOptions;
|
|
83
|
+
/**
|
|
84
|
+
* 附加指令
|
|
85
|
+
*/
|
|
86
|
+
command?: string[];
|
|
87
|
+
/**
|
|
88
|
+
* 附加运行脚本
|
|
89
|
+
*/
|
|
90
|
+
scripts?: {
|
|
91
|
+
ars?: string[];
|
|
92
|
+
name?: 'ts-node' | 'node';
|
|
93
|
+
file: string;
|
|
94
|
+
}[];
|
|
95
|
+
/**
|
|
96
|
+
* 服务配置
|
|
97
|
+
*/
|
|
98
|
+
server?: ServerOptions;
|
|
99
|
+
/**
|
|
100
|
+
* puppeteer配置
|
|
101
|
+
*/
|
|
102
|
+
puppeteer?: PuppeteerLaunchOptions;
|
|
103
|
+
/**
|
|
104
|
+
* redis配置
|
|
105
|
+
*/
|
|
106
|
+
redis?: RedisOptions;
|
|
107
|
+
/**
|
|
108
|
+
* mysql配置
|
|
109
|
+
*/
|
|
110
|
+
mysql?: MysqlOptions;
|
|
111
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* *******************
|
|
3
|
+
* 核心处理&公共方法
|
|
4
|
+
* *******************
|
|
5
|
+
*/
|
|
2
6
|
export * from './alemon/index.js';
|
|
3
|
-
|
|
7
|
+
/**
|
|
8
|
+
* *******************
|
|
9
|
+
* 初始化
|
|
10
|
+
* *******************
|
|
11
|
+
*/
|
|
12
|
+
export * from './define/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* **********
|
|
15
|
+
* 配置管理
|
|
16
|
+
* **********
|
|
17
|
+
*/
|
|
18
|
+
export * from './config/index.js';
|
package/lib/bot.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { setLanchConfig } from './alemon/index.js';
|
|
2
|
-
import { getBotConfigByKey, setBotConfig } from './login.js';
|
|
3
|
-
import { getToml } from './config.js';
|
|
4
|
-
import { loadInit } from './alemon/index.js';
|
|
5
|
-
import { ClientAPIByQQ } from './ntqq/sdk/index.js';
|
|
6
|
-
import { compilationTools } from 'alemon-rollup';
|
|
7
|
-
/**
|
|
8
|
-
* 启动机器人
|
|
9
|
-
*/
|
|
10
|
-
const createAlemon = {
|
|
11
|
-
qq: async () => {
|
|
12
|
-
const { createAlemonByQQ: qq } = await import('./qq/index.js');
|
|
13
|
-
return qq().catch(err => {
|
|
14
|
-
console.error(err);
|
|
15
|
-
console.error('QQ机器人启动失败~');
|
|
16
|
-
return false;
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
villa: async () => {
|
|
20
|
-
const { createAlemonByVilla: villa } = await import('./villa/index.js');
|
|
21
|
-
return villa().catch(err => {
|
|
22
|
-
console.error(err);
|
|
23
|
-
console.error('Villa机器人启动失败~');
|
|
24
|
-
return false;
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
kook: async () => {
|
|
28
|
-
const { createAlemonByKOOK: kook } = await import('./kook/index.js');
|
|
29
|
-
return kook().catch(err => {
|
|
30
|
-
console.error(err);
|
|
31
|
-
console.error('KOOK机器人启动失败~');
|
|
32
|
-
return false;
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
discord: async () => {
|
|
36
|
-
const { createAlemonByDiscord: dc } = await import('./discord/index.js');
|
|
37
|
-
return dc().catch(err => {
|
|
38
|
-
console.error(err);
|
|
39
|
-
console.error('Discord机器人启动失败~');
|
|
40
|
-
return false;
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
ntqq: async () => {
|
|
44
|
-
const { createAlemonByNtqq: ntqq } = await import('./ntqq/index.js');
|
|
45
|
-
return ntqq().catch(err => {
|
|
46
|
-
console.error(err);
|
|
47
|
-
console.error('Ntqq机器人启动失败~');
|
|
48
|
-
return false;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* 创建机器人
|
|
54
|
-
* @param val
|
|
55
|
-
* @returns
|
|
56
|
-
*/
|
|
57
|
-
export async function createBot(val = {
|
|
58
|
-
args: process.argv.slice(2),
|
|
59
|
-
mount: false,
|
|
60
|
-
address: '/application'
|
|
61
|
-
}) {
|
|
62
|
-
const { args, mount, cfg, address } = val;
|
|
63
|
-
/**
|
|
64
|
-
* 加载配置
|
|
65
|
-
*/
|
|
66
|
-
await setBotConfig(getToml(cfg));
|
|
67
|
-
/**
|
|
68
|
-
* 设置浏览器配置
|
|
69
|
-
*/
|
|
70
|
-
await setLanchConfig(getBotConfigByKey('puppeteer'));
|
|
71
|
-
/**
|
|
72
|
-
* 控制
|
|
73
|
-
*/
|
|
74
|
-
const arr = [];
|
|
75
|
-
/**
|
|
76
|
-
* 开始启动
|
|
77
|
-
*/
|
|
78
|
-
for await (const item of args ?? process.argv.slice(2)) {
|
|
79
|
-
if (arr.indexOf(item) != -1)
|
|
80
|
-
continue;
|
|
81
|
-
if (!createAlemon[item])
|
|
82
|
-
continue;
|
|
83
|
-
arr.push(item);
|
|
84
|
-
await createAlemon[item]();
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* 启动插件加载
|
|
88
|
-
*/
|
|
89
|
-
await loadInit({
|
|
90
|
-
mount: mount == undefined ? false : mount,
|
|
91
|
-
address: address == undefined ? '/application' : address
|
|
92
|
-
});
|
|
93
|
-
return compilationTools;
|
|
94
|
-
}
|
|
95
|
-
// 机器人配置
|
|
96
|
-
export { getBotConfigByKey, setBotConfigByKey } from './login.js';
|
|
97
|
-
// 设置独立鉴权路径
|
|
98
|
-
export const setAuthenticationByNtqq = ClientAPIByQQ.setAuthentication;
|
package/lib/config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { parse } from '@iarna/toml';
|
|
4
|
-
import { stringify } from '@iarna/toml';
|
|
5
|
-
let urlVal = '/alemon.toml';
|
|
6
|
-
/**
|
|
7
|
-
* 读取配置文件
|
|
8
|
-
* @param url
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export function getToml(url = urlVal) {
|
|
12
|
-
// 检验文件是否存在
|
|
13
|
-
urlVal = url;
|
|
14
|
-
const u = join(process.cwd(), urlVal);
|
|
15
|
-
if (!existsSync(u))
|
|
16
|
-
return {};
|
|
17
|
-
return parse(readFileSync(u, 'utf8'));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* 写入配置文件
|
|
21
|
-
* @param data
|
|
22
|
-
*/
|
|
23
|
-
export function writeToml(data) {
|
|
24
|
-
writeFileSync(join(process.cwd(), urlVal), stringify(data));
|
|
25
|
-
}
|