alemonjs 1.0.3 → 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.
Files changed (63) hide show
  1. package/README.md +7 -9
  2. package/bin/main.js +17 -0
  3. package/lib/alemon/dealmsg.js +66 -18
  4. package/lib/alemon/puppeteer.js +9 -16
  5. package/lib/config/index.js +1 -1
  6. package/lib/config/login.js +21 -82
  7. package/lib/config/pup.js +75 -0
  8. package/lib/config/types.js +1 -10
  9. package/lib/default/login/discord.js +16 -0
  10. package/lib/default/login/kook.js +5 -0
  11. package/lib/default/login/ntqq.js +17 -0
  12. package/lib/default/login/qq.js +16 -0
  13. package/lib/default/login/villa.js +13 -0
  14. package/lib/default/mysql.js +7 -0
  15. package/lib/default/pup.js +15 -0
  16. package/lib/default/redis.js +6 -0
  17. package/lib/default/server.js +4 -0
  18. package/lib/default/types.js +16 -0
  19. package/lib/define/api.js +23 -0
  20. package/lib/define/child_process.js +10 -0
  21. package/lib/define/command.js +22 -0
  22. package/lib/define/index.js +7 -0
  23. package/lib/define/main.js +205 -0
  24. package/lib/{map.js → define/map.js} +8 -6
  25. package/lib/define/plugin.js +25 -0
  26. package/lib/define/types.js +1 -0
  27. package/lib/discord/login.js +18 -62
  28. package/lib/index.js +22 -8
  29. package/lib/kook/login.js +7 -39
  30. package/lib/ntqq/index.js +1 -1
  31. package/lib/ntqq/login.js +15 -62
  32. package/lib/ntqq/sdk/wss.js +0 -1
  33. package/lib/qq/index.js +13 -2
  34. package/lib/qq/login.js +3 -124
  35. package/lib/villa/login.js +11 -51
  36. package/package.json +61 -59
  37. package/types/alemon/dealmsg.d.ts +10 -0
  38. package/types/config/index.d.ts +1 -1
  39. package/types/config/pup.d.ts +7 -0
  40. package/types/config/types.d.ts +9 -117
  41. package/types/default/login/discord.d.ts +8 -0
  42. package/types/default/login/kook.d.ts +6 -0
  43. package/types/default/login/ntqq.d.ts +16 -0
  44. package/types/default/login/qq.d.ts +12 -0
  45. package/types/default/login/villa.d.ts +14 -0
  46. package/types/default/mysql.d.ts +8 -0
  47. package/types/default/pup.d.ts +3 -0
  48. package/types/default/redis.d.ts +7 -0
  49. package/types/default/server.d.ts +5 -0
  50. package/types/default/types.d.ts +300 -0
  51. package/types/define/api.d.ts +30 -0
  52. package/types/define/child_process.d.ts +1 -0
  53. package/types/define/command.d.ts +1 -0
  54. package/types/define/index.d.ts +7 -0
  55. package/types/define/main.d.ts +20 -0
  56. package/types/{map.d.ts → define/map.d.ts} +3 -1
  57. package/types/define/plugin.d.ts +4 -0
  58. package/types/define/types.d.ts +111 -0
  59. package/types/index.d.ts +16 -2
  60. package/lib/bot.js +0 -66
  61. package/lib/config/toml.js +0 -25
  62. package/types/bot.d.ts +0 -20
  63. package/types/config/toml.d.ts +0 -12
package/lib/qq/login.js CHANGED
@@ -1,6 +1,5 @@
1
- import prompts from 'prompts';
2
1
  import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
3
- import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
2
+ import { setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
4
3
  /**
5
4
  * 登录配置
6
5
  * @param Bcf
@@ -25,126 +24,6 @@ export async function checkRobotByQQ() {
25
24
  }
26
25
  }
27
26
  console.info('[LOGIN]', '-----------------------');
28
- console.info('[LOGIN]', '推荐将机器人设置', '订阅推送', '打开');
29
- console.info('[LOGIN]', '推荐将机器人设置', '私聊权限', '打开');
30
- console.info('[LOGIN]', '非管理类机器推荐', '普通成员', '身份');
31
- console.info('[LOGIN]', '-----------------------');
32
- console.info('[LOGIN]', '退出重来?可按', '[CTRL+C]');
33
- console.info('[LOGIN]', '更改登录?执行', 'npm run login');
34
- console.info('[LOGIN]', '-----------------------');
35
- const timeoutId = setTimeout(() => {
36
- throw '超过1分钟未完成登录';
37
- }, 60000);
38
- const { appID, token, inputBot, imputDev } = await prompts([
39
- {
40
- type: 'password',
41
- name: 'appID',
42
- message: 'BotAppID: ',
43
- validate: value => value !== '' && typeof value === 'string' ? true : '机器人 appID: '
44
- },
45
- {
46
- type: 'password',
47
- name: 'token',
48
- message: 'BotToken: ',
49
- validate: value => value !== '' && typeof value === 'string' ? true : '机器人 token: '
50
- },
51
- {
52
- type: 'select',
53
- name: 'inputBot',
54
- message: '请选择机器人类型 :',
55
- choices: [
56
- { title: '公域', value: '0' },
57
- { title: '私域', value: '1' }
58
- ],
59
- /**
60
- * 默认公域
61
- */
62
- initial: 0
63
- },
64
- {
65
- type: 'select',
66
- name: 'imputDev',
67
- message: '请选择机器人环境 :',
68
- choices: [
69
- { title: '部署环境', value: '0' },
70
- { title: '开发环境', value: '1' }
71
- ],
72
- /**
73
- * 默认部署
74
- */
75
- initial: 0
76
- }
77
- ]).catch((err) => {
78
- console.error(err);
79
- process.exit();
80
- });
81
- if (!appID || !token || !inputBot || !imputDev) {
82
- return false;
83
- }
84
- clearTimeout(timeoutId);
85
- /**
86
- * 默认公域机器人
87
- */
88
- let intents = [
89
- AvailableIntentsEventsEnum.GUILDS,
90
- AvailableIntentsEventsEnum.GUILD_MEMBERS,
91
- AvailableIntentsEventsEnum.DIRECT_MESSAGE,
92
- /**
93
- * 公域特有
94
- */
95
- AvailableIntentsEventsEnum.PUBLIC_GUILD_MESSAGES //公域事件
96
- ];
97
- /**
98
- * 默认公域机器人
99
- */
100
- let isPrivate = false;
101
- if (inputBot == '1') {
102
- /**
103
- * 私域机器人
104
- */
105
- intents = [
106
- AvailableIntentsEventsEnum.GUILDS,
107
- AvailableIntentsEventsEnum.GUILD_MEMBERS,
108
- AvailableIntentsEventsEnum.DIRECT_MESSAGE,
109
- /**
110
- * 需申请的
111
- */
112
- AvailableIntentsEventsEnum.AUDIO_ACTION,
113
- AvailableIntentsEventsEnum.MESSAGE_AUDIT,
114
- AvailableIntentsEventsEnum.INTERACTION,
115
- AvailableIntentsEventsEnum.GUILD_MESSAGE_REACTIONS,
116
- /**
117
- * 私域特有
118
- */
119
- AvailableIntentsEventsEnum.GUILD_MESSAGES,
120
- AvailableIntentsEventsEnum.FORUMS_EVENT //私域论坛
121
- ];
122
- /**
123
- * 私域机器人
124
- */
125
- isPrivate = true;
126
- }
127
- // 默认部署
128
- let sandbox = false;
129
- // 开发环境
130
- if (imputDev == '1')
131
- sandbox = true;
132
- // 得到已变更的配置
133
- const db = getBotConfigByKey('qq');
134
- // 得到配置
135
- const data = getToml();
136
- data.qq = {
137
- ...db,
138
- // 覆盖新配置
139
- appID,
140
- token,
141
- intents,
142
- isPrivate,
143
- sandbox
144
- };
145
- // 写入配置
146
- writeToml(data);
147
- // 设置配置
148
- setBotConfigByKey('qq', data.qq);
149
- return true;
27
+ console.info('[LOGIN]', 'qq配置加载失败~');
28
+ process.exit();
150
29
  }
@@ -1,5 +1,4 @@
1
- import prompts from 'prompts';
2
- import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../config/index.js';
1
+ import { setBotConfigByKey, getBotConfigByKey } from '../config/index.js';
3
2
  /**
4
3
  * 登录配置
5
4
  * @param Bcf
@@ -7,55 +6,16 @@ import { setBotConfigByKey, getBotConfigByKey, getToml, writeToml } from '../con
7
6
  * @returns
8
7
  */
9
8
  export async function checkRobotByVilla() {
10
- // 重写登录
11
- if (process.argv.indexOf('login') == -1) {
12
- // 启动
13
- const config = getBotConfigByKey('villa');
14
- // 存在
15
- if ((config ?? '') !== '' &&
16
- (config.bot_id ?? '') !== '' &&
17
- (config.secret ?? '') !== '') {
18
- setBotConfigByKey('villa', config);
19
- return true;
20
- }
9
+ // 启动
10
+ const config = getBotConfigByKey('villa');
11
+ // 存在
12
+ if ((config ?? '') !== '' &&
13
+ (config.bot_id ?? '') !== '' &&
14
+ (config.secret ?? '') !== '') {
15
+ setBotConfigByKey('villa', config);
16
+ return true;
21
17
  }
22
18
  console.info('[LOGIN]', '-----------------------');
23
- const timeoutId = setTimeout(() => {
24
- throw '超过1分钟未完成登录';
25
- }, 60000);
26
- const { bot_id, secret } = await prompts([
27
- {
28
- type: 'password',
29
- name: 'bot_id',
30
- message: 'bot_id: ',
31
- validate: (value) => value !== '' && typeof value === 'string' ? true : 'bot_id: '
32
- },
33
- {
34
- type: 'password',
35
- name: 'secret',
36
- message: 'secret: ',
37
- validate: (value) => value !== '' && typeof value === 'string' ? true : 'secret: '
38
- }
39
- ]).catch((err) => {
40
- console.error(err);
41
- process.exit();
42
- });
43
- if (!bot_id || !secret)
44
- return false;
45
- clearTimeout(timeoutId);
46
- // 得到已变更的配置
47
- const db = getBotConfigByKey('villa');
48
- // 得到配置
49
- const data = getToml();
50
- data.villa = {
51
- ...db,
52
- // 覆盖新配置
53
- bot_id,
54
- secret
55
- };
56
- // 写入配置
57
- writeToml(data);
58
- // 设置配置
59
- setBotConfigByKey('villa', data.villa);
60
- return true;
19
+ console.info('[LOGIN]', 'villa配置加载失败~');
20
+ process.exit();
61
21
  }
package/package.json CHANGED
@@ -1,60 +1,62 @@
1
- {
2
- "name": "alemonjs",
3
- "version": "1.0.3",
4
- "description": "阿柠檬框架",
5
- "author": "ningmengchongshui",
6
- "main": "lib/index.js",
7
- "license": "GPL-2.0",
8
- "type": "module",
9
- "scripts": {
10
- "app": "ts-node index.ts",
11
- "login": "ts-node index.ts login",
12
- "tsc": "npx tsc",
13
- "format": "prettier --write .",
14
- "lint": "eslint . --ext .js,.ts --fix --ignore-path .gitignore"
15
- },
16
- "dependencies": {
17
- "@discordjs/builders": "^1.6.3",
18
- "@discordjs/core": "^0.6.0",
19
- "@discordjs/rest": "^1.7.1",
20
- "@iarna/toml": "^2.2.5",
21
- "alemon-rollup": "^1.0.2",
22
- "axios": "^1.4.0",
23
- "discord.js": "^14.11.0",
24
- "image-size": "^1.0.2",
25
- "kook-ws": "^1.0.4",
26
- "lodash": "^4.17.21",
27
- "mys-villa": "^1.1.8",
28
- "prompts": "^2.4.2",
29
- "puppeteer": "^20.7.1",
30
- "qq-channel": "^1.0.0",
31
- "qq-guild-bot": "^2.9.5",
32
- "qrcode": "^1.5.3"
33
- },
34
- "devDependencies": {
35
- "@types/lodash": "^4.14.186",
36
- "@types/node": "^20.2.4",
37
- "@types/progress": "^2.0.5",
38
- "@types/qrcode": "^1.5.0",
39
- "@types/ws": "^8.5.5",
40
- "@typescript-eslint/eslint-plugin": "^5.60.0",
41
- "@typescript-eslint/parser": "^5.60.0",
42
- "eslint": "^8.43.0",
43
- "eslint-config-prettier": "^8.8.0",
44
- "eslint-plugin-prettier": "^4.2.1",
45
- "prettier": "^2.8.8",
46
- "ts-node": "^10.9.1",
47
- "typescript": ">=5.0.4 <5.1.0"
48
- },
49
- "types": "types",
50
- "files": [
51
- "lib",
52
- "types"
53
- ],
54
- "publishConfig": {
55
- "registry": "https://registry.npmjs.org"
56
- },
57
- "engines": {
58
- "node": ">=16.14.0"
59
- }
1
+ {
2
+ "name": "alemonjs",
3
+ "version": "1.0.4",
4
+ "description": "阿柠檬框架",
5
+ "author": "ningmengchongshui",
6
+ "main": "lib/index.js",
7
+ "license": "GPL-2.0",
8
+ "type": "module",
9
+ "scripts": {
10
+ "app": "alemonjs",
11
+ "dev": "alemonjs dev",
12
+ "tsc": "npx tsc",
13
+ "format": "prettier --write .",
14
+ "lint": "eslint . --ext .js,.ts --fix --ignore-path .gitignore"
15
+ },
16
+ "dependencies": {
17
+ "@discordjs/builders": "^1.6.3",
18
+ "@discordjs/core": "^0.6.0",
19
+ "@discordjs/rest": "^1.7.1",
20
+ "alemon-rollup": "^1.0.2",
21
+ "axios": "^1.4.0",
22
+ "discord.js": "^14.11.0",
23
+ "image-size": "^1.0.2",
24
+ "kook-ws": "^1.0.4",
25
+ "lodash": "^4.17.21",
26
+ "mys-villa": "^1.1.8",
27
+ "puppeteer": "^20.7.1",
28
+ "qq-channel": "^1.0.0",
29
+ "qq-guild-bot": "^2.9.5",
30
+ "qrcode": "^1.5.3"
31
+ },
32
+ "devDependencies": {
33
+ "@types/lodash": "^4.14.186",
34
+ "@types/node": "^20.2.4",
35
+ "@types/progress": "^2.0.5",
36
+ "@types/qrcode": "^1.5.0",
37
+ "@types/ws": "^8.5.5",
38
+ "@typescript-eslint/eslint-plugin": "^5.60.0",
39
+ "@typescript-eslint/parser": "^5.60.0",
40
+ "eslint": "^8.43.0",
41
+ "eslint-config-prettier": "^8.8.0",
42
+ "eslint-plugin-prettier": "^4.2.1",
43
+ "prettier": "^2.8.8",
44
+ "ts-node": "^10.9.1",
45
+ "typescript": ">=5.0.4 <5.1.0"
46
+ },
47
+ "types": "types",
48
+ "files": [
49
+ "bin",
50
+ "lib",
51
+ "types"
52
+ ],
53
+ "bin": {
54
+ "alemonjs": "bin/main.js"
55
+ },
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org"
58
+ },
59
+ "engines": {
60
+ "node": ">=16.14.0"
61
+ }
60
62
  }
@@ -1,4 +1,13 @@
1
1
  import { AMessage } from './typings.js';
2
+ interface RegexControl {
3
+ RegexOpen?: RegExp;
4
+ RegexClose?: RegExp;
5
+ }
6
+ /**
7
+ * 插件名匹配
8
+ * @param val
9
+ */
10
+ export declare function setAppRegex(val: RegexControl): void;
2
11
  /**
3
12
  * 设置指令json地址
4
13
  * @param rt '/public/defset'
@@ -39,3 +48,4 @@ export declare function InstructionMatching(e: AMessage): Promise<boolean>;
39
48
  * @returns
40
49
  */
41
50
  export declare function typeMessage(e: AMessage): Promise<boolean>;
51
+ export {};
@@ -4,5 +4,5 @@
4
4
  * ********
5
5
  */
6
6
  export * from './login.js';
7
- export * from './toml.js';
8
7
  export * from './types.js';
8
+ export * from './pup.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @type {import("puppeteer").Configuration}
3
+ */
4
+ export declare function getPupPath(): {
5
+ skipDownload: boolean;
6
+ executablePath: string;
7
+ };
@@ -1,126 +1,18 @@
1
- import { GatewayIntentBits } from 'discord.js';
2
- import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
3
1
  import { PuppeteerLaunchOptions } from 'puppeteer';
2
+ import { DiscordOptions, KookOptionsg, MysqlOptions, NtQQOptions, QqGuildOptions, RedisOptions, VillaOptions, ServerOptions } from '../default/types.js';
4
3
  /**
5
4
  * ******
6
5
  * config
7
6
  * ******
8
7
  */
9
8
  export interface ConfigType {
10
- redis: RedisConfig;
11
- mysql: MysqlConfig;
12
- discord: DiscordConfig;
13
- kook: KookConfig;
14
- villa: VillaConfig;
15
- qq: QQConfig;
16
- server: ServerConfig;
9
+ redis: RedisOptions;
10
+ mysql: MysqlOptions;
11
+ discord: DiscordOptions;
12
+ kook: KookOptionsg;
13
+ villa: VillaOptions;
14
+ qq: QqGuildOptions;
15
+ server: ServerOptions;
17
16
  puppeteer: PuppeteerLaunchOptions;
18
- ntqq: NtQQConfig;
19
- }
20
- /**
21
- * ****
22
- * redis
23
- * *****
24
- */
25
- export interface RedisConfig {
26
- host: string;
27
- port: number;
28
- password: string;
29
- db: number;
30
- }
31
- /**
32
- * ***
33
- * mysql
34
- * **
35
- */
36
- export interface MysqlConfig {
37
- host: string;
38
- port: number;
39
- user: string;
40
- password: string;
41
- database: string;
42
- }
43
- /**
44
- * **
45
- * discord
46
- * **
47
- */
48
- export interface DiscordConfig {
49
- token: string;
50
- masterID: string;
51
- password: string;
52
- intents: GatewayIntentBits[];
53
- }
54
- /**
55
- * ****
56
- * kook
57
- * ***
58
- */
59
- export interface KookConfig {
60
- token: string;
61
- masterID: string;
62
- password: string;
63
- }
64
- /**
65
- * ****
66
- * villa
67
- * *****
68
- */
69
- export interface VillaConfig {
70
- bot_id: string;
71
- secret: string;
72
- pub_key: string;
73
- masterID: string;
74
- password: string;
75
- http: string;
76
- url: string;
77
- port: number;
78
- size: number;
79
- img_url: string;
80
- IMAGE_DIR: string;
81
- }
82
- /**
83
- * *****
84
- * ntqq
85
- * ****
86
- */
87
- export declare enum NtQQEventsEnum {
88
- GROUP_AT_MESSAGE_CREATE = "GROUP_AT_MESSAGE_CREATE",
89
- C2C_MESSAGE_CREATE = "C2C_MESSAGE_CREATE"
90
- }
91
- export interface NtQQConfig {
92
- appID: string;
93
- token: string;
94
- secret: string;
95
- masterID: string;
96
- password: string;
97
- intents: NtQQEventsEnum[];
98
- port: number;
99
- size: number;
100
- img_url: string;
101
- IMAGE_DIR: string;
102
- http: string;
103
- }
104
- /**
105
- * ******
106
- * qq
107
- * *****
108
- */
109
- export interface QQConfig {
110
- appID: string;
111
- token: string;
112
- masterID: string;
113
- password: string;
114
- intents: AvailableIntentsEventsEnum[];
115
- isPrivate: boolean;
116
- sandbox: boolean;
117
- }
118
- /**
119
- * ******
120
- * server
121
- * *****
122
- */
123
- export interface ServerConfig {
124
- host: string;
125
- port: number;
17
+ ntqq: NtQQOptions;
126
18
  }
@@ -0,0 +1,8 @@
1
+ import { GatewayIntentBits } from 'discord.js';
2
+ declare const _default: {
3
+ token: string;
4
+ masterID: string;
5
+ password: string;
6
+ intents: GatewayIntentBits[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ token: string;
3
+ masterID: string;
4
+ password: string;
5
+ };
6
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { NtQQEventsEnum } from '../types.js';
2
+ declare const _default: {
3
+ appID: string;
4
+ token: string;
5
+ secret: string;
6
+ masterID: string;
7
+ password: string;
8
+ intents: NtQQEventsEnum[];
9
+ shard: number[];
10
+ port: number;
11
+ size: number;
12
+ img_url: string;
13
+ IMAGE_DIR: string;
14
+ http: string;
15
+ };
16
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { AvailableIntentsEventsEnum } from 'qq-guild-bot';
2
+ declare const _default: {
3
+ appID: string;
4
+ token: string;
5
+ secret: string;
6
+ masterID: string;
7
+ password: string;
8
+ intents: AvailableIntentsEventsEnum[];
9
+ isPrivate: boolean;
10
+ sandbox: boolean;
11
+ };
12
+ export default _default;
@@ -0,0 +1,14 @@
1
+ declare const _default: {
2
+ bot_id: string;
3
+ secret: string;
4
+ pub_key: string;
5
+ masterID: string;
6
+ password: string;
7
+ http: string;
8
+ url: string;
9
+ port: number;
10
+ size: number;
11
+ img_url: string;
12
+ IMAGE_DIR: string;
13
+ };
14
+ export default _default;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ host: string;
3
+ port: number;
4
+ user: string;
5
+ password: string;
6
+ database: string;
7
+ };
8
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { PuppeteerLaunchOptions } from 'puppeteer';
2
+ declare const _default: PuppeteerLaunchOptions;
3
+ export default _default;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ host: string;
3
+ port: number;
4
+ password: string;
5
+ db: number;
6
+ };
7
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ host: string;
3
+ port: number;
4
+ };
5
+ export default _default;