alemonjs 1.0.7 → 1.0.9
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/default/login/qq.js +1 -2
- package/lib/define/index.js +1 -0
- package/lib/define/main.js +44 -20
- package/package.json +1 -1
- package/types/define/index.d.ts +1 -0
- package/types/define/types.d.ts +4 -5
- package/lib/define/plugin.js +0 -65
- package/types/define/plugin.d.ts +0 -5
package/lib/default/login/qq.js
CHANGED
|
@@ -8,8 +8,7 @@ export default {
|
|
|
8
8
|
intents: [
|
|
9
9
|
AvailableIntentsEventsEnum.GUILDS,
|
|
10
10
|
AvailableIntentsEventsEnum.PUBLIC_GUILD_MESSAGES,
|
|
11
|
-
AvailableIntentsEventsEnum.DIRECT_MESSAGE
|
|
12
|
-
AvailableIntentsEventsEnum.GUILD_MEMBERS
|
|
11
|
+
AvailableIntentsEventsEnum.DIRECT_MESSAGE
|
|
13
12
|
],
|
|
14
13
|
isPrivate: false,
|
|
15
14
|
sandbox: false
|
package/lib/define/index.js
CHANGED
package/lib/define/main.js
CHANGED
|
@@ -5,8 +5,7 @@ import { nodeScripts } from './child_process.js';
|
|
|
5
5
|
import { ClientAPIByQQ as ClientByNTQQ } from '../ntqq/sdk/index.js';
|
|
6
6
|
import { createApp, loadInit, setBotConfigByKey, setLanchConfig, getPupPath, getBotConfigByKey, setAppRegex } from '../index.js';
|
|
7
7
|
import { command } from './command.js';
|
|
8
|
-
import {
|
|
9
|
-
import { join } from 'path';
|
|
8
|
+
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
10
9
|
// 设置ntqq独立鉴权路径
|
|
11
10
|
export const setAuthenticationByNtqq = ClientByNTQQ.setAuthentication;
|
|
12
11
|
let appDir = 'application';
|
|
@@ -84,28 +83,59 @@ export async function defineAlemonConfig(Options) {
|
|
|
84
83
|
const arr = [];
|
|
85
84
|
/**
|
|
86
85
|
* *********
|
|
87
|
-
*
|
|
86
|
+
* 登录机器人
|
|
88
87
|
* *********
|
|
89
88
|
*/
|
|
90
89
|
if (Options?.login) {
|
|
91
|
-
/**
|
|
92
|
-
* ********
|
|
93
|
-
* 配置载入
|
|
94
|
-
* *******
|
|
95
|
-
*/
|
|
96
90
|
if (Options.login?.discord) {
|
|
91
|
+
// 自定义覆盖
|
|
97
92
|
setBotConfigByKey('discord', Options.login.discord);
|
|
98
93
|
}
|
|
99
94
|
if (Options.login?.qq) {
|
|
95
|
+
// 开启私域
|
|
96
|
+
if (Options.login?.qq?.isPrivate) {
|
|
97
|
+
setBotConfigByKey('qq', {
|
|
98
|
+
intents: [
|
|
99
|
+
// 基础事件
|
|
100
|
+
AvailableIntentsEventsEnum.GUILDS,
|
|
101
|
+
AvailableIntentsEventsEnum.GUILD_MEMBERS,
|
|
102
|
+
AvailableIntentsEventsEnum.DIRECT_MESSAGE,
|
|
103
|
+
// 需申请的
|
|
104
|
+
AvailableIntentsEventsEnum.AUDIO_ACTION,
|
|
105
|
+
AvailableIntentsEventsEnum.MESSAGE_AUDIT,
|
|
106
|
+
AvailableIntentsEventsEnum.INTERACTION,
|
|
107
|
+
AvailableIntentsEventsEnum.GUILD_MESSAGE_REACTIONS,
|
|
108
|
+
// 私域特有
|
|
109
|
+
AvailableIntentsEventsEnum.GUILD_MESSAGES,
|
|
110
|
+
AvailableIntentsEventsEnum.FORUMS_EVENT //私域论坛
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
setBotConfigByKey('qq', {
|
|
116
|
+
intents: [
|
|
117
|
+
// 基础事件
|
|
118
|
+
AvailableIntentsEventsEnum.GUILDS,
|
|
119
|
+
AvailableIntentsEventsEnum.GUILD_MEMBERS,
|
|
120
|
+
AvailableIntentsEventsEnum.DIRECT_MESSAGE,
|
|
121
|
+
// 公域特有
|
|
122
|
+
AvailableIntentsEventsEnum.PUBLIC_GUILD_MESSAGES //公域事件
|
|
123
|
+
]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// 自定义覆盖
|
|
100
127
|
setBotConfigByKey('qq', Options.login.qq);
|
|
101
128
|
}
|
|
102
129
|
if (Options.login?.ntqq) {
|
|
130
|
+
// 自定义覆盖
|
|
103
131
|
setBotConfigByKey('ntqq', Options.login.ntqq);
|
|
104
132
|
}
|
|
105
133
|
if (Options.login?.kook) {
|
|
134
|
+
// 自定义覆盖
|
|
106
135
|
setBotConfigByKey('kook', Options.login.kook);
|
|
107
136
|
}
|
|
108
137
|
if (Options.login?.villa) {
|
|
138
|
+
// 自定义覆盖
|
|
109
139
|
setBotConfigByKey('villa', Options.login.villa);
|
|
110
140
|
}
|
|
111
141
|
for (const item in Options.login) {
|
|
@@ -147,23 +177,17 @@ export async function defineAlemonConfig(Options) {
|
|
|
147
177
|
RegexClose: Options?.plugin?.RegexClose
|
|
148
178
|
});
|
|
149
179
|
}
|
|
150
|
-
/**
|
|
151
|
-
* ***************
|
|
152
|
-
* 是否同步文件
|
|
153
|
-
* ***************
|
|
154
|
-
*/
|
|
155
|
-
if (Options?.plugin?.mountFile) {
|
|
156
|
-
copyAppsFile(join(process.cwd(), `/${address}`));
|
|
157
|
-
}
|
|
158
180
|
/**
|
|
159
181
|
* ************
|
|
160
182
|
* 扫描插件
|
|
161
183
|
* ************
|
|
162
184
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
if (Options?.plugin?.init) {
|
|
186
|
+
await loadInit({
|
|
187
|
+
mount: mount,
|
|
188
|
+
address: address == undefined ? '/application' : `/${address}`
|
|
189
|
+
});
|
|
190
|
+
}
|
|
167
191
|
/**
|
|
168
192
|
* ************
|
|
169
193
|
* 编译独立插件
|
package/package.json
CHANGED
package/types/define/index.d.ts
CHANGED
package/types/define/types.d.ts
CHANGED
|
@@ -59,14 +59,13 @@ export interface AlemonOptions {
|
|
|
59
59
|
*/
|
|
60
60
|
plugin?: {
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* 是否加载插件
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
init?: boolean;
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
* default true
|
|
66
|
+
* 插件目录
|
|
68
67
|
*/
|
|
69
|
-
|
|
68
|
+
directory?: string;
|
|
70
69
|
/**
|
|
71
70
|
* 插件名匹配规则
|
|
72
71
|
*/
|
package/lib/define/plugin.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, copyFileSync, mkdirSync } from 'fs';
|
|
2
|
-
import { getAppRegex } from '../alemon/index.js';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
/**
|
|
5
|
-
* 遍历复制方法
|
|
6
|
-
*/
|
|
7
|
-
const copyFiles = (source, destination) => {
|
|
8
|
-
if (!existsSync(destination)) {
|
|
9
|
-
mkdirSync(destination, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
const files = readdirSync(source);
|
|
12
|
-
for (const file of files) {
|
|
13
|
-
const sourcePath = join(source, file);
|
|
14
|
-
const destinationPath = join(destination, file);
|
|
15
|
-
copyFileSync(sourcePath, destinationPath);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* 同步挂载文件
|
|
20
|
-
* @param dir 插件目录
|
|
21
|
-
*/
|
|
22
|
-
export function copyAppsFile(dir) {
|
|
23
|
-
if (!existsSync(dir))
|
|
24
|
-
return;
|
|
25
|
-
const flies = readdirSync(dir);
|
|
26
|
-
if (flies.length === 0)
|
|
27
|
-
return;
|
|
28
|
-
const { RegexOpen, RegexClose } = getAppRegex();
|
|
29
|
-
// 插件名
|
|
30
|
-
const apps = flies
|
|
31
|
-
.filter(item => RegexOpen.test(item))
|
|
32
|
-
.filter(item => {
|
|
33
|
-
// 关闭符合条件的
|
|
34
|
-
if (!RegexClose) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (RegexClose.test(item)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
});
|
|
42
|
-
for (const appname of apps) {
|
|
43
|
-
const appPath = join(dir, appname);
|
|
44
|
-
if (existsSync(`${appPath}/assets`)) {
|
|
45
|
-
const originalAddress = `${appPath}/assets`;
|
|
46
|
-
const destinationAddress = join(process.cwd(), `/assets/.${appname}/assets`);
|
|
47
|
-
copyFiles(originalAddress, destinationAddress);
|
|
48
|
-
}
|
|
49
|
-
if (existsSync(`${appPath}/pages`)) {
|
|
50
|
-
const originalAddress = `${appPath}/pages`;
|
|
51
|
-
const destinationAddress = join(process.cwd(), `/pages/.${appname}/pages`);
|
|
52
|
-
copyFiles(originalAddress, destinationAddress);
|
|
53
|
-
}
|
|
54
|
-
if (existsSync(`${appPath}/plugins`)) {
|
|
55
|
-
const originalAddress = `${appPath}/plugins`;
|
|
56
|
-
const destinationAddress = join(process.cwd(), `/plugins/.${appname}/plugins`);
|
|
57
|
-
copyFiles(originalAddress, destinationAddress);
|
|
58
|
-
}
|
|
59
|
-
if (existsSync(`${appPath}/server`)) {
|
|
60
|
-
const originalAddress = `${appPath}/server`;
|
|
61
|
-
const destinationAddress = join(process.cwd(), `/server/.${appname}/server`);
|
|
62
|
-
copyFiles(originalAddress, destinationAddress);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|