alemonjs 1.0.1 → 1.0.3
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 +4 -18
- package/lib/alemon/apps.js +1 -1
- package/lib/alemon/dealmsg.js +2 -2
- package/lib/alemon/dialogue.js +1 -1
- package/lib/alemon/plugin.js +3 -0
- package/lib/alemon/screenshot.js +6 -2
- package/lib/alemon/typings.js +3 -0
- package/lib/bot.js +66 -0
- package/lib/config/index.js +8 -0
- package/lib/{login.js → config/login.js} +44 -8
- package/lib/{types.js → config/types.js} +5 -0
- package/lib/discord/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/discord/index.js +1 -1
- package/lib/discord/login.js +1 -2
- package/lib/index.js +14 -6
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +1 -1
- package/lib/kook/index.js +1 -1
- package/lib/kook/login.js +1 -2
- package/lib/map.js +45 -0
- package/lib/ntqq/alemon/message/GROUP_AT_MESSAGE_CREATE.js +1 -1
- package/lib/ntqq/index.js +1 -1
- package/lib/ntqq/login.js +1 -3
- package/lib/qq/alemon/conversation.js +1 -1
- package/lib/qq/alemon/message/MESSAGE.js +1 -1
- package/lib/qq/index.js +1 -1
- package/lib/qq/login.js +1 -2
- package/lib/villa/alemon/message/MESSAGES.js +1 -1
- package/lib/villa/index.js +1 -1
- package/lib/villa/login.js +1 -2
- package/package.json +1 -1
- package/types/alemon/apps.d.ts +1 -1
- package/types/alemon/dealmsg.d.ts +1 -1
- package/types/alemon/plugin.d.ts +9 -0
- package/types/alemon/typings.d.ts +6 -0
- package/types/{main.d.ts → bot.d.ts} +14 -9
- package/types/config/index.d.ts +8 -0
- package/types/{types.d.ts → config/types.d.ts} +57 -16
- package/types/index.d.ts +3 -5
- package/types/map.d.ts +10 -0
- package/lib/main.js +0 -106
- /package/lib/{config.js → config/toml.js} +0 -0
- /package/types/{login.d.ts → config/login.d.ts} +0 -0
- /package/types/{config.d.ts → config/toml.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -13,33 +13,19 @@
|
|
|
13
13
|
| cli | 脚手架 | 开发模板脚手架 |
|
|
14
14
|
| web | 网站 | 共享平台插件贡献地址 |
|
|
15
15
|
|
|
16
|
-
## 快速开始
|
|
17
|
-
|
|
18
|
-
```shell
|
|
19
|
-
npm init almeonjs@latest -y #安装
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
cd alemon-bot #进入
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
npm run app qq #启动
|
|
28
|
-
```
|
|
29
|
-
|
|
30
16
|
## 配置管理
|
|
31
17
|
|
|
32
|
-
|
|
18
|
+
参考配置说明进行
|
|
33
19
|
|
|
34
|
-
|
|
20
|
+
更改[alemon.toml](./alemon.md)
|
|
35
21
|
|
|
36
22
|
### 共享平台
|
|
37
23
|
|
|
38
24
|
> 仓库只做资源收集,对齐安全性不做任何检查,请谨慎选择
|
|
39
25
|
|
|
40
|
-
Gitee ☞
|
|
26
|
+
[Gitee ☞ 贡献资源](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
|
|
41
27
|
|
|
42
|
-
Github ☞
|
|
28
|
+
[Github ☞ 贡献资源](https://gitee.com/ningmengchongshui/alemon/blob/web/docs/about/plugins.md)
|
|
43
29
|
|
|
44
30
|
### 平台推送
|
|
45
31
|
|
package/lib/alemon/apps.js
CHANGED
package/lib/alemon/dealmsg.js
CHANGED
|
@@ -25,7 +25,7 @@ const plugins = {};
|
|
|
25
25
|
/**
|
|
26
26
|
* 默认执行地址
|
|
27
27
|
*/
|
|
28
|
-
const route = '/
|
|
28
|
+
const route = '/public/defset';
|
|
29
29
|
/**
|
|
30
30
|
* 执行文件
|
|
31
31
|
*/
|
|
@@ -36,7 +36,7 @@ let addressMenu = join(process.cwd(), route);
|
|
|
36
36
|
let mergedRegex;
|
|
37
37
|
/**
|
|
38
38
|
* 设置指令json地址
|
|
39
|
-
* @param rt '/
|
|
39
|
+
* @param rt '/public/defset'
|
|
40
40
|
*/
|
|
41
41
|
export function setAppsHelp(rt = route) {
|
|
42
42
|
addressMenu = join(process.cwd(), rt);
|
package/lib/alemon/dialogue.js
CHANGED
package/lib/alemon/plugin.js
CHANGED
package/lib/alemon/screenshot.js
CHANGED
|
@@ -59,14 +59,18 @@ export function createStr(Options) {
|
|
|
59
59
|
* 插件路径
|
|
60
60
|
*/
|
|
61
61
|
const basePath = join(process.cwd(), appDir, AppName);
|
|
62
|
+
/**
|
|
63
|
+
* 数据路径
|
|
64
|
+
*/
|
|
65
|
+
const dataPath = join(process.cwd(), '.data', AppName);
|
|
62
66
|
/**
|
|
63
67
|
* 写入地址
|
|
64
68
|
*/
|
|
65
|
-
const AdressHtml = join(
|
|
69
|
+
const AdressHtml = join(dataPath, basename(tplFile));
|
|
66
70
|
/**
|
|
67
71
|
* 确保写入目录存在
|
|
68
72
|
*/
|
|
69
|
-
mkdirSync(
|
|
73
|
+
mkdirSync(dataPath, { recursive: true });
|
|
70
74
|
/**
|
|
71
75
|
* 判断初始模板是否改变
|
|
72
76
|
*/
|
package/lib/alemon/typings.js
CHANGED
package/lib/bot.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { setLanchConfig } from './alemon/index.js';
|
|
2
|
+
import { getBotConfigByKey, setBotConfig, getToml } from './config/index.js';
|
|
3
|
+
import { loadInit } from './alemon/index.js';
|
|
4
|
+
import { ClientAPIByQQ } from './ntqq/sdk/index.js';
|
|
5
|
+
import { compilationTools } from 'alemon-rollup';
|
|
6
|
+
import { createAlemon } from './map.js';
|
|
7
|
+
// 设置独立鉴权路径
|
|
8
|
+
export const setAuthenticationByNtqq = ClientAPIByQQ.setAuthentication;
|
|
9
|
+
let appDir = 'application';
|
|
10
|
+
/**
|
|
11
|
+
* 应用模块集成
|
|
12
|
+
* @param AppName
|
|
13
|
+
* @param name
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export function ApplicationTools(AppName, name = 'apps') {
|
|
17
|
+
return compilationTools({
|
|
18
|
+
aInput: `${appDir}/${AppName}/${name}/**/*.ts`,
|
|
19
|
+
aOutput: `${appDir}/${AppName}/apps.js`
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 创建机器人
|
|
24
|
+
* @param val
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export async function createBot(val = {
|
|
28
|
+
args: process.argv.slice(2),
|
|
29
|
+
mount: false,
|
|
30
|
+
address: 'application'
|
|
31
|
+
}) {
|
|
32
|
+
const { args, mount, cfg, address } = val;
|
|
33
|
+
// 配置快捷路径
|
|
34
|
+
appDir = address == undefined ? 'application' : address;
|
|
35
|
+
/**
|
|
36
|
+
* 加载配置
|
|
37
|
+
*/
|
|
38
|
+
await setBotConfig(getToml(cfg));
|
|
39
|
+
/**
|
|
40
|
+
* 设置浏览器配置
|
|
41
|
+
*/
|
|
42
|
+
await setLanchConfig(getBotConfigByKey('puppeteer'));
|
|
43
|
+
/**
|
|
44
|
+
* 控制
|
|
45
|
+
*/
|
|
46
|
+
const arr = [];
|
|
47
|
+
/**
|
|
48
|
+
* 开始启动
|
|
49
|
+
*/
|
|
50
|
+
for await (const item of args ?? process.argv.slice(2)) {
|
|
51
|
+
if (arr.indexOf(item) != -1)
|
|
52
|
+
continue;
|
|
53
|
+
if (!createAlemon[item])
|
|
54
|
+
continue;
|
|
55
|
+
arr.push(item);
|
|
56
|
+
await createAlemon[item]();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 启动插件加载
|
|
60
|
+
*/
|
|
61
|
+
await loadInit({
|
|
62
|
+
mount: mount == undefined ? false : mount,
|
|
63
|
+
address: address == undefined ? '/application' : `/${address}`
|
|
64
|
+
});
|
|
65
|
+
return compilationTools;
|
|
66
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bot-config
|
|
3
|
+
*/
|
|
1
4
|
const config = {
|
|
2
5
|
redis: {
|
|
3
6
|
host: '127.0.0.1',
|
|
@@ -62,6 +65,9 @@ const config = {
|
|
|
62
65
|
host: '127.0.0.1',
|
|
63
66
|
port: 5000
|
|
64
67
|
},
|
|
68
|
+
/**
|
|
69
|
+
* pup的配置的繁多的
|
|
70
|
+
*/
|
|
65
71
|
puppeteer: {
|
|
66
72
|
headless: 'new',
|
|
67
73
|
timeout: 30000,
|
|
@@ -82,11 +88,29 @@ const config = {
|
|
|
82
88
|
*/
|
|
83
89
|
export function setBotConfig(val) {
|
|
84
90
|
// 分布覆盖
|
|
85
|
-
for (const
|
|
91
|
+
for (const i in val) {
|
|
86
92
|
// 当且仅当存在同key的时候才会覆盖默认配置
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
if (Object.prototype.hasOwnProperty.call(config, i)) {
|
|
94
|
+
if (i == 'puppeteer') {
|
|
95
|
+
// pup 不用检查 直接覆盖
|
|
96
|
+
for (const j in val[i]) {
|
|
97
|
+
config[i][j] = val[i][j];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
for (const j in val[i]) {
|
|
102
|
+
// 当前仅当同属性名的时候才会覆盖默认配置
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(config[i], j)) {
|
|
104
|
+
config[i][j] = val[i][j];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.log('[alemonjs][存在无效参数]', val[i]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
console.log('[alemonjs][存在无效参数]', val[i]);
|
|
90
114
|
}
|
|
91
115
|
}
|
|
92
116
|
}
|
|
@@ -96,10 +120,22 @@ export function setBotConfig(val) {
|
|
|
96
120
|
* @param val
|
|
97
121
|
*/
|
|
98
122
|
export function setBotConfigByKey(key, val) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
123
|
+
if (key == 'puppeteer') {
|
|
124
|
+
// pup 不用检查 直接覆盖
|
|
125
|
+
for (const item in val) {
|
|
126
|
+
config[key][item] = val[item];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
for (const item in val) {
|
|
131
|
+
// 当前仅当同属性名的时候才会覆盖默认配置
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(config[key], item)) {
|
|
133
|
+
config[key][item] = val[item];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.log('[alemonjs][存在无效参数]', val[item]);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
103
139
|
}
|
|
104
140
|
}
|
|
105
141
|
/**
|
|
@@ -2,7 +2,7 @@ import { InstructionMatching } from '../../../alemon/index.js';
|
|
|
2
2
|
import { segmentDiscord } from '../segment.js';
|
|
3
3
|
import { getBotMsgByDiscord } from '../bot.js';
|
|
4
4
|
import { postImage } from '../api.js';
|
|
5
|
-
import { getBotConfigByKey } from '../../../
|
|
5
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* 公共
|
|
8
8
|
* @param event
|
package/lib/discord/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from 'discord.js';
|
|
|
2
2
|
import { checkRobotByDiscord } from './login.js';
|
|
3
3
|
import { callBackByDisdord } from './alemon/conversation.js';
|
|
4
4
|
import { setBotMsgByDiscord } from './alemon/bot.js';
|
|
5
|
-
import { getBotConfigByKey } from '../
|
|
5
|
+
import { getBotConfigByKey } from '../config/index.js';
|
|
6
6
|
export async function createAlemonByDiscord() {
|
|
7
7
|
/**
|
|
8
8
|
* 登录
|
package/lib/discord/login.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import { GatewayIntentBits } from 'discord.js';
|
|
3
|
-
import { setBotConfigByKey, getBotConfigByKey } from '../
|
|
4
|
-
import { getToml, writeToml } from '../config.js';
|
|
3
|
+
import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
|
|
5
4
|
/**
|
|
6
5
|
* 登录配置
|
|
7
6
|
* @param Bcf
|
package/lib/index.js
CHANGED
|
@@ -2,11 +2,19 @@ if (process.argv.slice(2).includes('discord') &&
|
|
|
2
2
|
!process.argv.slice(2).includes('not')) {
|
|
3
3
|
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
4
4
|
}
|
|
5
|
-
//
|
|
6
|
-
export
|
|
5
|
+
// 导出编译工具
|
|
6
|
+
export { compilationTools, integration } from 'alemon-rollup';
|
|
7
7
|
// 导出核心方法
|
|
8
8
|
export * from './alemon/index.js';
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
export
|
|
9
|
+
// 导出机器人
|
|
10
|
+
export * from './bot.js';
|
|
11
|
+
// 机器配置管理
|
|
12
|
+
export * from './config/index.js';
|
|
13
|
+
// 监听退出
|
|
14
|
+
process.on('SIGINT', signals => {
|
|
15
|
+
console.info(signals);
|
|
16
|
+
if (process.pid) {
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
});
|
|
@@ -2,7 +2,7 @@ import { InstructionMatching } from '../../../alemon/index.js';
|
|
|
2
2
|
import { KOOKApiClient } from 'kook-ws';
|
|
3
3
|
import { segmentKOOK } from '../segment.js';
|
|
4
4
|
import { getBotMsgByKOOK } from '../bot.js';
|
|
5
|
-
import { getBotConfigByKey } from '../../../
|
|
5
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
8
8
|
* @param event
|
package/lib/kook/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { checkRobotByKOOK } from './login.js';
|
|
|
2
2
|
import { callBackByKOOK } from './alemon/conversation.js';
|
|
3
3
|
import { createClient, KOOKApiClient } from 'kook-ws';
|
|
4
4
|
import { setBotMsgByKOOK } from './alemon/bot.js';
|
|
5
|
-
import { getBotConfigByKey } from '../
|
|
5
|
+
import { getBotConfigByKey } from '../config/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* 创建实例
|
|
8
8
|
* @returns
|
package/lib/kook/login.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
|
-
import { setBotConfigByKey, getBotConfigByKey } from '../
|
|
3
|
-
import { getToml, writeToml } from '../config.js';
|
|
2
|
+
import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
|
|
4
3
|
/**
|
|
5
4
|
* 登录配置
|
|
6
5
|
* @param Bcf
|
package/lib/map.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 启动机器人
|
|
3
|
+
*/
|
|
4
|
+
export const createAlemon = {
|
|
5
|
+
qq: async () => {
|
|
6
|
+
const { createAlemonByQQ: qq } = await import('./qq/index.js');
|
|
7
|
+
return qq().catch(err => {
|
|
8
|
+
console.error(err);
|
|
9
|
+
console.error('QQ机器人启动失败~');
|
|
10
|
+
return false;
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
villa: async () => {
|
|
14
|
+
const { createAlemonByVilla: villa } = await import('./villa/index.js');
|
|
15
|
+
return villa().catch(err => {
|
|
16
|
+
console.error(err);
|
|
17
|
+
console.error('Villa机器人启动失败~');
|
|
18
|
+
return false;
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
kook: async () => {
|
|
22
|
+
const { createAlemonByKOOK: kook } = await import('./kook/index.js');
|
|
23
|
+
return kook().catch(err => {
|
|
24
|
+
console.error(err);
|
|
25
|
+
console.error('KOOK机器人启动失败~');
|
|
26
|
+
return false;
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
discord: async () => {
|
|
30
|
+
const { createAlemonByDiscord: dc } = await import('./discord/index.js');
|
|
31
|
+
return dc().catch(err => {
|
|
32
|
+
console.error(err);
|
|
33
|
+
console.error('Discord机器人启动失败~');
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
ntqq: async () => {
|
|
38
|
+
const { createAlemonByNtqq: ntqq } = await import('./ntqq/index.js');
|
|
39
|
+
return ntqq().catch(err => {
|
|
40
|
+
console.error(err);
|
|
41
|
+
console.error('Ntqq机器人启动失败~');
|
|
42
|
+
return false;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -2,7 +2,7 @@ import { InstructionMatching } from '../../../alemon/index.js';
|
|
|
2
2
|
import { ClientAPIByQQ as Client, ClinetWeb, getWebConfig } from '../../sdk/index.js';
|
|
3
3
|
import { segmentQQ } from '../segment.js';
|
|
4
4
|
import { getBotMsgByNtqq } from '../bot.js';
|
|
5
|
-
import { getBotConfigByKey } from '../../../
|
|
5
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
6
6
|
import IMGS from 'image-size';
|
|
7
7
|
/**
|
|
8
8
|
* 获取ip
|
package/lib/ntqq/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkRobotByQQ } from './login.js';
|
|
2
|
-
import { getBotConfigByKey } from '../
|
|
2
|
+
import { getBotConfigByKey } from '../config/index.js';
|
|
3
3
|
import { conversation } from './alemon/conversation.js';
|
|
4
4
|
import { setBotConfig, createClient, ClientAPIByQQ, ClinetWeb, getWebConfig } from './sdk/index.js';
|
|
5
5
|
import { createWeb } from './sdk/web/client.js';
|
package/lib/ntqq/login.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
|
-
import { setBotConfigByKey, getBotConfigByKey } from '../
|
|
3
|
-
import { getToml, writeToml } from '../config.js';
|
|
4
|
-
import { NtQQEventsEnum } from '../types.js';
|
|
2
|
+
import { NtQQEventsEnum, setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
|
|
5
3
|
/**
|
|
6
4
|
* 登录配置
|
|
7
5
|
* @param Bcf
|
|
@@ -11,7 +11,7 @@ import { MESSAGE_AUDIT } from './message/MESSAGE_AUDIT.js';
|
|
|
11
11
|
import { AUDIO_ACTION } from './message/AUDIO_ACTION.js';
|
|
12
12
|
import { FORUMS_EVENT } from './message/FORUMS_EVENT.js';
|
|
13
13
|
import { setBotMsgByQQ } from './bot.js';
|
|
14
|
-
import { getBotConfigByKey } from '../../
|
|
14
|
+
import { getBotConfigByKey } from '../../config/index.js';
|
|
15
15
|
/**
|
|
16
16
|
* 会话事件分类
|
|
17
17
|
* @param ws
|
|
@@ -3,7 +3,7 @@ import { ClientAPIByQQ as Client } from 'qq-channel';
|
|
|
3
3
|
import { Private } from '../privatechat.js';
|
|
4
4
|
import { segmentQQ } from '../segment.js';
|
|
5
5
|
import { setBotMsgByQQ } from '../bot.js';
|
|
6
|
-
import { getBotConfigByKey } from '../../../
|
|
6
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
7
7
|
/**
|
|
8
8
|
* 公私域合并
|
|
9
9
|
* @param e
|
package/lib/qq/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createOpenAPI, createWebsocket } from 'qq-guild-bot';
|
|
|
3
3
|
import { setBotConfig } from 'qq-channel';
|
|
4
4
|
import { checkRobotByQQ } from './login.js';
|
|
5
5
|
import { createConversationByQQ } from './alemon/conversation.js';
|
|
6
|
-
import { getBotConfigByKey } from '../
|
|
6
|
+
import { getBotConfigByKey } from '../config/index.js';
|
|
7
7
|
export async function createAlemonByQQ() {
|
|
8
8
|
/**
|
|
9
9
|
* 登录
|
package/lib/qq/login.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
3
|
-
import { setBotConfigByKey, getBotConfigByKey } from '../
|
|
4
|
-
import { getToml, writeToml } from '../config.js';
|
|
3
|
+
import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
|
|
5
4
|
/**
|
|
6
5
|
* 登录配置
|
|
7
6
|
* @param Bcf
|
|
@@ -2,7 +2,7 @@ import { InstructionMatching } from '../../../alemon/index.js';
|
|
|
2
2
|
import { Client } from 'mys-villa';
|
|
3
3
|
import IMGS from 'image-size';
|
|
4
4
|
import { segmentVilla } from '../segment.js';
|
|
5
|
-
import { getBotConfigByKey } from '../../../
|
|
5
|
+
import { getBotConfigByKey } from '../../../config/index.js';
|
|
6
6
|
import { now_e } from './e.js';
|
|
7
7
|
/**
|
|
8
8
|
* 获取ip
|
package/lib/villa/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callBackByVilla } from './alemon/conversation.js';
|
|
2
2
|
import { checkRobotByVilla } from './login.js';
|
|
3
3
|
import { createClient, Client, hmacSha256 } from 'mys-villa';
|
|
4
|
-
import { getBotConfigByKey } from '../
|
|
4
|
+
import { getBotConfigByKey } from '../config/index.js';
|
|
5
5
|
export async function createAlemonByVilla() {
|
|
6
6
|
/**
|
|
7
7
|
* 登录
|
package/lib/villa/login.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
|
-
import { setBotConfigByKey, getBotConfigByKey } from '../
|
|
3
|
-
import { getToml, writeToml } from '../config.js';
|
|
2
|
+
import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
|
|
4
3
|
/**
|
|
5
4
|
* 登录配置
|
|
6
5
|
* @param Bcf
|
package/package.json
CHANGED
package/types/alemon/apps.d.ts
CHANGED
package/types/alemon/plugin.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { EventEnum, EventType } from './typings.js';
|
|
2
|
+
/**
|
|
3
|
+
* 插件类型
|
|
4
|
+
*/
|
|
2
5
|
export interface PluginInitType {
|
|
3
6
|
event?: (typeof EventEnum)[number];
|
|
4
7
|
eventType?: (typeof EventType)[number];
|
|
@@ -7,6 +10,9 @@ export interface PluginInitType {
|
|
|
7
10
|
dsc?: string;
|
|
8
11
|
rule?: PluginRuleType[];
|
|
9
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* 插件类型
|
|
15
|
+
*/
|
|
10
16
|
export interface PluginRuleType {
|
|
11
17
|
/**
|
|
12
18
|
* 正则
|
|
@@ -29,6 +35,9 @@ export interface PluginRuleType {
|
|
|
29
35
|
*/
|
|
30
36
|
priority?: number;
|
|
31
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* 插件模板
|
|
40
|
+
*/
|
|
32
41
|
export declare class plugin {
|
|
33
42
|
/**
|
|
34
43
|
* 模块名
|
|
@@ -517,7 +517,13 @@ export interface MuteController {
|
|
|
517
517
|
*/
|
|
518
518
|
muteMembers?: (...args: any[]) => any;
|
|
519
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* 卡片枚举
|
|
522
|
+
*/
|
|
520
523
|
export declare const CacrdEnum: readonly ["qq_embed", "qq_ark", "kook_card"];
|
|
524
|
+
/**
|
|
525
|
+
* 卡片类型
|
|
526
|
+
*/
|
|
521
527
|
export interface CardType {
|
|
522
528
|
type: (typeof CacrdEnum)[number];
|
|
523
529
|
card: any;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { ClientAPIByQQ } from './ntqq/sdk/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
export declare const setAuthenticationByNtqq: typeof ClientAPIByQQ.setAuthentication;
|
|
3
|
+
/**
|
|
4
|
+
* 应用模块集成
|
|
5
|
+
* @param AppName
|
|
6
|
+
* @param name
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function ApplicationTools(AppName: string, name?: string): any;
|
|
8
10
|
/**
|
|
9
11
|
* 创建机器人
|
|
10
12
|
* @param val
|
|
11
13
|
* @returns
|
|
12
14
|
*/
|
|
13
|
-
export declare function createBot(val?:
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export declare function createBot(val?: {
|
|
16
|
+
args?: string[];
|
|
17
|
+
mount?: boolean;
|
|
18
|
+
address?: string;
|
|
19
|
+
cfg?: string;
|
|
20
|
+
}): Promise<any>;
|
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
import { GatewayIntentBits } from 'discord.js';
|
|
2
2
|
import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
|
|
3
|
+
import { PuppeteerLaunchOptions } from 'puppeteer';
|
|
4
|
+
/**
|
|
5
|
+
* ******
|
|
6
|
+
* config
|
|
7
|
+
* ******
|
|
8
|
+
*/
|
|
9
|
+
export interface ConfigType {
|
|
10
|
+
redis: RedisConfig;
|
|
11
|
+
mysql: MysqlConfig;
|
|
12
|
+
discord: DiscordConfig;
|
|
13
|
+
kook: KookConfig;
|
|
14
|
+
villa: VillaConfig;
|
|
15
|
+
qq: QQConfig;
|
|
16
|
+
server: ServerConfig;
|
|
17
|
+
puppeteer: PuppeteerLaunchOptions;
|
|
18
|
+
ntqq: NtQQConfig;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ****
|
|
22
|
+
* redis
|
|
23
|
+
* *****
|
|
24
|
+
*/
|
|
3
25
|
export interface RedisConfig {
|
|
4
26
|
host: string;
|
|
5
27
|
port: number;
|
|
6
28
|
password: string;
|
|
7
29
|
db: number;
|
|
8
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* ***
|
|
33
|
+
* mysql
|
|
34
|
+
* **
|
|
35
|
+
*/
|
|
9
36
|
export interface MysqlConfig {
|
|
10
37
|
host: string;
|
|
11
38
|
port: number;
|
|
@@ -13,17 +40,32 @@ export interface MysqlConfig {
|
|
|
13
40
|
password: string;
|
|
14
41
|
database: string;
|
|
15
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* **
|
|
45
|
+
* discord
|
|
46
|
+
* **
|
|
47
|
+
*/
|
|
16
48
|
export interface DiscordConfig {
|
|
17
49
|
token: string;
|
|
18
50
|
masterID: string;
|
|
19
51
|
password: string;
|
|
20
52
|
intents: GatewayIntentBits[];
|
|
21
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* ****
|
|
56
|
+
* kook
|
|
57
|
+
* ***
|
|
58
|
+
*/
|
|
22
59
|
export interface KookConfig {
|
|
23
60
|
token: string;
|
|
24
61
|
masterID: string;
|
|
25
62
|
password: string;
|
|
26
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* ****
|
|
66
|
+
* villa
|
|
67
|
+
* *****
|
|
68
|
+
*/
|
|
27
69
|
export interface VillaConfig {
|
|
28
70
|
bot_id: string;
|
|
29
71
|
secret: string;
|
|
@@ -37,6 +79,11 @@ export interface VillaConfig {
|
|
|
37
79
|
img_url: string;
|
|
38
80
|
IMAGE_DIR: string;
|
|
39
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* *****
|
|
84
|
+
* ntqq
|
|
85
|
+
* ****
|
|
86
|
+
*/
|
|
40
87
|
export declare enum NtQQEventsEnum {
|
|
41
88
|
GROUP_AT_MESSAGE_CREATE = "GROUP_AT_MESSAGE_CREATE",
|
|
42
89
|
C2C_MESSAGE_CREATE = "C2C_MESSAGE_CREATE"
|
|
@@ -54,6 +101,11 @@ export interface NtQQConfig {
|
|
|
54
101
|
IMAGE_DIR: string;
|
|
55
102
|
http: string;
|
|
56
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* ******
|
|
106
|
+
* qq
|
|
107
|
+
* *****
|
|
108
|
+
*/
|
|
57
109
|
export interface QQConfig {
|
|
58
110
|
appID: string;
|
|
59
111
|
token: string;
|
|
@@ -63,23 +115,12 @@ export interface QQConfig {
|
|
|
63
115
|
isPrivate: boolean;
|
|
64
116
|
sandbox: boolean;
|
|
65
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* ******
|
|
120
|
+
* server
|
|
121
|
+
* *****
|
|
122
|
+
*/
|
|
66
123
|
export interface ServerConfig {
|
|
67
124
|
host: string;
|
|
68
125
|
port: number;
|
|
69
126
|
}
|
|
70
|
-
export interface PuppeteerConfig {
|
|
71
|
-
args: string[];
|
|
72
|
-
headless: 'new';
|
|
73
|
-
timeout: number;
|
|
74
|
-
}
|
|
75
|
-
export interface ConfigType {
|
|
76
|
-
redis?: RedisConfig;
|
|
77
|
-
mysql?: MysqlConfig;
|
|
78
|
-
discord?: DiscordConfig;
|
|
79
|
-
kook?: KookConfig;
|
|
80
|
-
villa?: VillaConfig;
|
|
81
|
-
qq?: QQConfig;
|
|
82
|
-
server?: ServerConfig;
|
|
83
|
-
puppeteer?: PuppeteerConfig;
|
|
84
|
-
ntqq?: NtQQConfig;
|
|
85
|
-
}
|
package/types/index.d.ts
CHANGED
package/types/map.d.ts
ADDED
package/lib/main.js
DELETED
|
@@ -1,106 +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;
|
|
99
|
-
// 监听退出
|
|
100
|
-
process.on('SIGINT', signals => {
|
|
101
|
-
console.info(signals);
|
|
102
|
-
if (process.pid) {
|
|
103
|
-
process.exit();
|
|
104
|
-
}
|
|
105
|
-
return;
|
|
106
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|