alemonjs 1.0.8 → 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 +38 -22
- package/package.json +1 -1
- package/types/define/index.d.ts +1 -0
- package/types/define/types.d.ts +0 -10
- package/lib/define/plugin.js +0 -27
- 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,20 +177,6 @@ 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}`).replace(/\\/g, '/'), Options?.plugin?.monutControl ?? [
|
|
157
|
-
'assets',
|
|
158
|
-
'pages',
|
|
159
|
-
'public',
|
|
160
|
-
'plugins',
|
|
161
|
-
'server'
|
|
162
|
-
]);
|
|
163
|
-
}
|
|
164
180
|
/**
|
|
165
181
|
* ************
|
|
166
182
|
* 扫描插件
|
package/package.json
CHANGED
package/types/define/index.d.ts
CHANGED
package/types/define/types.d.ts
CHANGED
|
@@ -66,16 +66,6 @@ export interface AlemonOptions {
|
|
|
66
66
|
* 插件目录
|
|
67
67
|
*/
|
|
68
68
|
directory?: string;
|
|
69
|
-
/**
|
|
70
|
-
* 挂载文件
|
|
71
|
-
* default true
|
|
72
|
-
*/
|
|
73
|
-
mountFile?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* 选择性挂载
|
|
76
|
-
* 默认 ['assets', 'pages', 'public', 'plugins', 'server']
|
|
77
|
-
*/
|
|
78
|
-
monutControl?: string[];
|
|
79
69
|
/**
|
|
80
70
|
* 插件名匹配规则
|
|
81
71
|
*/
|
package/lib/define/plugin.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, cpSync } from 'fs';
|
|
2
|
-
import { getAppRegex } from '../alemon/index.js';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
/**
|
|
5
|
-
* 同步挂载文件
|
|
6
|
-
* @param dir 插件目录
|
|
7
|
-
*/
|
|
8
|
-
export function copyAppsFile(dir, control = []) {
|
|
9
|
-
if (!existsSync(dir))
|
|
10
|
-
return;
|
|
11
|
-
const flies = readdirSync(dir);
|
|
12
|
-
if (flies.length === 0)
|
|
13
|
-
return;
|
|
14
|
-
const { RegexOpen, RegexClose } = getAppRegex();
|
|
15
|
-
for (const appname of flies) {
|
|
16
|
-
const appPath = join(dir, appname);
|
|
17
|
-
if (RegexOpen.test(appname) && (!RegexClose || !RegexClose.test(appname))) {
|
|
18
|
-
for (const name of control) {
|
|
19
|
-
if (existsSync(`${appPath}/${name}`)) {
|
|
20
|
-
const originalAddress = `${appPath}/${name}`;
|
|
21
|
-
const destinationAddress = join(process.cwd(), `./${name}/.${appname}`);
|
|
22
|
-
cpSync(originalAddress, destinationAddress, { recursive: true });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|