alemonjs 1.1.40 → 1.2.0-rc.1
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 +14 -0
- package/lib/api/index.js +8 -17
- package/lib/config/login.js +35 -36
- package/lib/core/index.js +5 -7
- package/lib/core/main.js +9 -5
- package/lib/core/{dev → processor}/alemon.js +194 -60
- package/lib/core/{dev → processor}/application.js +29 -48
- package/lib/core/processor/configs.js +67 -0
- package/lib/core/processor/help.js +37 -0
- package/lib/core/{dev → processor}/listdouble.js +31 -31
- package/lib/{log/index.js → core/processor/log.js} +2 -8
- package/lib/core/{dev → processor}/plugin.js +44 -14
- package/lib/core/{dev → processor}/subscribe.js +7 -20
- package/lib/core/types.js +24 -0
- package/lib/core/utils/buffer.js +1 -37
- package/lib/core/utils/counter.js +17 -0
- package/lib/core/utils/index.js +1 -1
- package/lib/core/utils/ip.js +6 -14
- package/lib/core/utils/puppeteer.js +31 -26
- package/lib/core/utils/utils.js +1 -12
- package/lib/define/main.js +33 -106
- package/lib/discord/alemon/bot.js +3 -8
- package/lib/discord/alemon/controller.js +20 -41
- package/lib/discord/alemon/conversation.js +6 -12
- package/lib/discord/alemon/message/CHANNEL_TOPIC_UPDATE.js +1 -4
- package/lib/discord/alemon/message/CHANNEL_UPDATE.js +1 -4
- package/lib/discord/alemon/message/GUILD_MEMBER_ADD.js +1 -4
- package/lib/discord/alemon/message/GUILD_MEMBER_REMOVE.js +1 -4
- package/lib/discord/alemon/message/GUILD_MEMBER_UPDATE.js +1 -4
- package/lib/discord/alemon/message/MESSAGE_CREATE.js +10 -29
- package/lib/discord/alemon/message/MESSAGE_DELETE.js +1 -4
- package/lib/discord/alemon/message/MESSAGE_REACTION_ADD.js +1 -4
- package/lib/discord/alemon/message/MESSAGE_UPDATE.js +1 -4
- package/lib/discord/alemon/message/PRESENCE_UPDATE.js +1 -4
- package/lib/discord/alemon/message/TYPING_START.js +1 -4
- package/lib/discord/alemon/message/VOICE_CHANNEL_STATUS_UPDATE.js +1 -4
- package/lib/discord/alemon/message/VOICE_STATE_UPDATE.js +1 -4
- package/lib/discord/alemon/reply.js +7 -8
- package/lib/discord/index.js +12 -14
- package/lib/discord/sdk/api.js +240 -47
- package/lib/discord/sdk/config.js +6 -21
- package/lib/discord/sdk/index.js +1 -1
- package/lib/discord/sdk/log.js +4 -4
- package/lib/discord/sdk/wss.js +155 -111
- package/lib/index.js +9 -9
- package/lib/koa/back.js +2 -2
- package/lib/koa/client.js +7 -7
- package/lib/koa/config.js +3 -21
- package/lib/koa/file.js +78 -75
- package/lib/koa/index.js +1 -1
- package/lib/kook/alemon/bot.js +3 -8
- package/lib/kook/alemon/controller.js +35 -49
- package/lib/kook/alemon/conversation.js +2 -3
- package/lib/kook/alemon/direct.js +30 -39
- package/lib/kook/alemon/message/DIRECT_MESSAGE.js +9 -22
- package/lib/kook/alemon/message/GUILD_MESSAGE_REACTIONS.js +8 -25
- package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +9 -26
- package/lib/kook/alemon/reply.js +9 -10
- package/lib/kook/index.js +21 -30
- package/lib/kook/sdk/api.js +297 -249
- package/lib/kook/sdk/config.js +3 -20
- package/lib/kook/sdk/index.js +1 -1
- package/lib/kook/sdk/log.js +11 -0
- package/lib/kook/sdk/ws.js +107 -128
- package/lib/{login.js → login/index.js} +5 -1
- package/lib/ntqq/alemon/bot.js +6 -0
- package/lib/ntqq/alemon/{group/controller.js → controller.js} +27 -42
- package/lib/ntqq/alemon/conversation.js +7 -8
- package/lib/ntqq/alemon/{group/direct.js → direct.js} +40 -59
- package/lib/ntqq/alemon/{group/message → message}/C2C_MESSAGE_CREATE.js +8 -21
- package/lib/ntqq/alemon/{group/message → message}/GROUP_AT_MESSAGE_CREATE.js +9 -22
- package/lib/ntqq/alemon/{group/reply.js → reply.js} +11 -18
- package/lib/ntqq/alemon/{group/segment.js → segment.js} +1 -1
- package/lib/ntqq/index.js +15 -21
- package/lib/ntqq/sdk/api.js +155 -0
- package/lib/ntqq/sdk/config.js +3 -21
- package/lib/ntqq/sdk/index.js +1 -1
- package/lib/ntqq/sdk/intents.js +1 -76
- package/lib/ntqq/sdk/log.js +4 -4
- package/lib/ntqq/sdk/wss.js +187 -169
- package/lib/qq/alemon/bot.js +3 -8
- package/lib/qq/alemon/controller.js +35 -104
- package/lib/qq/alemon/conversation.js +53 -139
- package/lib/qq/alemon/direct.js +29 -53
- package/lib/qq/alemon/message/AT_MESSAGE_CREATE.js +117 -0
- package/lib/qq/alemon/message/CHANNEL_CREATE.js +71 -0
- package/lib/qq/alemon/message/CHANNEL_DELETE.js +71 -0
- package/lib/qq/alemon/message/CHANNEL_UPDATE.js +71 -0
- package/lib/qq/alemon/message/DIRECT_MESSAGE_CREATE.js +57 -0
- package/lib/qq/alemon/message/DIRECT_MESSAGE_DELETE.js +57 -0
- package/lib/qq/alemon/message/GUILD_CREATE.js +71 -0
- package/lib/qq/alemon/message/GUILD_DELETE.js +71 -0
- package/lib/qq/alemon/message/GUILD_MEMBER_ADD.js +76 -0
- package/lib/qq/alemon/message/GUILD_MEMBER_REMOVE.js +76 -0
- package/lib/qq/alemon/message/GUILD_MEMBER_UPDATE.js +76 -0
- package/lib/qq/alemon/message/GUILD_UPDATE.js +71 -0
- package/lib/qq/alemon/message/{INTERACTION.js → INTERACTION_CREATE.js} +16 -40
- package/lib/qq/alemon/message/MESSAGE_CREATE.js +128 -0
- package/lib/qq/alemon/message/{GUILD_MESSAGES.js → MESSAGE_DELETE.js} +33 -57
- package/lib/qq/alemon/message/MESSAGE_REACTION_ADD.js +75 -0
- package/lib/qq/alemon/message/MESSAGE_REACTION_REMOVE.js +75 -0
- package/lib/qq/alemon/message/PUBLIC_MESSAGE_DELETE.js +69 -0
- package/lib/qq/alemon/reply.js +11 -20
- package/lib/qq/index.js +14 -43
- package/lib/qq/sdk/api.js +514 -73
- package/lib/qq/sdk/config.js +5 -21
- package/lib/qq/sdk/index.js +1 -1
- package/lib/qq/sdk/intents.js +1 -42
- package/lib/qq/sdk/log.js +4 -4
- package/lib/qq/sdk/typings.js +1 -1
- package/lib/qq/sdk/wss.js +135 -127
- package/lib/villa/alemon/controller.js +82 -199
- package/lib/villa/alemon/conversation.js +2 -0
- package/lib/villa/alemon/message/GUILD_BOT.js +5 -22
- package/lib/villa/alemon/message/GUILD_MEMBERS.js +5 -22
- package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +5 -22
- package/lib/villa/alemon/message/MESSAGES.js +5 -25
- package/lib/villa/alemon/message/MESSAGE_AUDIT.js +5 -22
- package/lib/villa/alemon/message/MESSAGE_BUTTON.js +5 -25
- package/lib/villa/alemon/reply.js +8 -15
- package/lib/villa/index.js +18 -20
- package/lib/villa/sdk/api.js +1119 -608
- package/lib/villa/sdk/config.js +3 -20
- package/lib/villa/sdk/index.js +1 -1
- package/lib/villa/sdk/log.js +4 -4
- package/lib/villa/sdk/wss.js +198 -159
- package/package.json +8 -13
- package/resources/index.html +28 -31
- package/types/api/index.d.ts +8 -17
- package/types/config/login.d.ts +17 -20
- package/types/config/types.d.ts +6 -6
- package/types/core/index.d.ts +5 -7
- package/types/core/main.d.ts +9 -5
- package/types/core/{dev → processor}/alemon.d.ts +44 -12
- package/types/core/{dev → processor}/application.d.ts +5 -5
- package/types/core/processor/configs.d.ts +76 -0
- package/types/core/processor/help.d.ts +16 -0
- package/types/core/{dev → processor}/listdouble.d.ts +1 -3
- package/types/core/processor/log.d.ts +7 -0
- package/types/core/{dev → processor}/plugin.d.ts +21 -5
- package/types/core/{dev → processor}/subscribe.d.ts +6 -13
- package/types/core/{plugin → processor}/types.d.ts +39 -2
- package/types/core/types.d.ts +162 -0
- package/types/core/typings.d.ts +5 -151
- package/types/core/utils/buffer.d.ts +0 -36
- package/types/{villa/sdk → core/utils}/counter.d.ts +3 -1
- package/types/core/utils/index.d.ts +1 -1
- package/types/core/utils/ip.d.ts +1 -9
- package/types/core/utils/puppeteer.d.ts +0 -8
- package/types/core/utils/utils.d.ts +1 -13
- package/types/default/types.d.ts +5 -5
- package/types/define/main.d.ts +0 -6
- package/types/define/types.d.ts +3 -15
- package/types/discord/alemon/bot.d.ts +3 -3
- package/types/discord/alemon/controller.d.ts +6 -93
- package/types/discord/index.d.ts +1 -1
- package/types/discord/sdk/api.d.ts +167 -25
- package/types/discord/sdk/config.d.ts +4 -12
- package/types/discord/sdk/index.d.ts +1 -1
- package/types/discord/sdk/wss.d.ts +39 -16
- package/types/index.d.ts +7 -7
- package/types/koa/config.d.ts +2 -10
- package/types/koa/file.d.ts +27 -23
- package/types/koa/index.d.ts +1 -1
- package/types/kook/alemon/bot.d.ts +3 -3
- package/types/kook/alemon/controller.d.ts +79 -64
- package/types/kook/alemon/direct.d.ts +106 -70
- package/types/kook/alemon/message/DIRECT_MESSAGE.d.ts +2 -1
- package/types/kook/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +2 -2
- package/types/kook/alemon/reply.d.ts +7 -1
- package/types/kook/index.d.ts +1 -1
- package/types/kook/sdk/api.d.ts +253 -247
- package/types/kook/sdk/config.d.ts +2 -12
- package/types/kook/sdk/index.d.ts +1 -1
- package/types/kook/sdk/log.d.ts +2 -0
- package/types/kook/sdk/ws.d.ts +28 -10
- package/types/{login.d.ts → login/index.d.ts} +2 -2
- package/types/ntqq/alemon/bot.d.ts +8 -0
- package/types/ntqq/alemon/controller.d.ts +45 -0
- package/types/ntqq/alemon/direct.d.ts +72 -0
- package/types/ntqq/alemon/{group/reply.d.ts → reply.d.ts} +4 -1
- package/types/ntqq/index.d.ts +1 -1
- package/types/ntqq/sdk/api.d.ts +120 -0
- package/types/ntqq/sdk/config.d.ts +2 -12
- package/types/ntqq/sdk/index.d.ts +1 -1
- package/types/ntqq/sdk/intents.d.ts +1 -8
- package/types/ntqq/sdk/wss.d.ts +54 -17
- package/types/qq/alemon/bot.d.ts +3 -3
- package/types/qq/alemon/controller.d.ts +13 -100
- package/types/qq/alemon/conversation.d.ts +1 -1
- package/types/qq/alemon/direct.d.ts +62 -71
- package/types/qq/alemon/message/AT_MESSAGE_CREATE.d.ts +40 -0
- package/types/qq/alemon/message/CHANNEL_CREATE.d.ts +20 -0
- package/types/qq/alemon/message/CHANNEL_DELETE.d.ts +20 -0
- package/types/qq/alemon/message/CHANNEL_UPDATE.d.ts +20 -0
- package/types/qq/alemon/message/DIRECT_MESSAGE_CREATE.d.ts +34 -0
- package/types/qq/alemon/message/DIRECT_MESSAGE_DELETE.d.ts +22 -0
- package/types/qq/alemon/message/GUILD_CREATE.d.ts +20 -0
- package/types/qq/alemon/message/GUILD_DELETE.d.ts +20 -0
- package/types/qq/alemon/message/GUILD_MEMBER_ADD.d.ts +19 -0
- package/types/qq/alemon/message/GUILD_MEMBER_REMOVE.d.ts +19 -0
- package/types/qq/alemon/message/GUILD_MEMBER_UPDATE.d.ts +19 -0
- package/types/qq/alemon/message/GUILD_UPDATE.d.ts +20 -0
- package/types/qq/alemon/message/INTERACTION_CREATE.d.ts +6 -0
- package/types/qq/alemon/message/MESSAGE_CREATE.d.ts +9 -0
- package/types/qq/alemon/message/MESSAGE_DELETE.d.ts +9 -0
- package/types/qq/alemon/message/MESSAGE_REACTION_ADD.d.ts +13 -0
- package/types/qq/alemon/message/MESSAGE_REACTION_REMOVE.d.ts +13 -0
- package/types/qq/alemon/message/PUBLIC_MESSAGE_DELETE.d.ts +19 -0
- package/types/qq/index.d.ts +2 -6
- package/types/qq/sdk/api.d.ts +325 -29
- package/types/qq/sdk/config.d.ts +3 -12
- package/types/qq/sdk/index.d.ts +1 -1
- package/types/qq/sdk/typings.d.ts +3 -3
- package/types/qq/sdk/wss.d.ts +63 -18
- package/types/villa/alemon/controller.d.ts +46 -172
- package/types/villa/alemon/reply.d.ts +3 -1
- package/types/villa/index.d.ts +1 -1
- package/types/villa/sdk/api.d.ts +427 -375
- package/types/villa/sdk/config.d.ts +4 -14
- package/types/villa/sdk/index.d.ts +1 -1
- package/types/villa/sdk/wss.d.ts +50 -20
- package/lib/api/controller.js +0 -40
- package/lib/core/application.js +0 -256
- package/lib/core/apps.js +0 -261
- package/lib/core/cache/app.js +0 -20
- package/lib/core/cache/arg.js +0 -13
- package/lib/core/cache/event.js +0 -13
- package/lib/core/cache/index.js +0 -6
- package/lib/core/cache/message.js +0 -13
- package/lib/core/cache/priority.js +0 -13
- package/lib/core/cache/slicing.js +0 -26
- package/lib/core/call.js +0 -33
- package/lib/core/configs.js +0 -36
- package/lib/core/conversation/index.js +0 -89
- package/lib/core/dealmsg.js +0 -222
- package/lib/core/help.js +0 -51
- package/lib/core/plugin/index.js +0 -151
- package/lib/core/utils/screenshot.js +0 -67
- package/lib/discord/discord.js +0 -30
- package/lib/discord/login.js +0 -20
- package/lib/discord/sdk/base.js +0 -30
- package/lib/discord/sdk/cdn.js +0 -38
- package/lib/kook/kook.js +0 -4
- package/lib/kook/login.js +0 -20
- package/lib/log/event.js +0 -20
- package/lib/log/user.js +0 -20
- package/lib/ntqq/alemon/group/bot.js +0 -11
- package/lib/ntqq/alemon/group/types.js +0 -1
- package/lib/ntqq/alemon/guild/controller.js +0 -1
- package/lib/ntqq/login.js +0 -19
- package/lib/ntqq/ntqq.js +0 -11
- package/lib/ntqq/sdk/api/auth.js +0 -15
- package/lib/ntqq/sdk/api/config.js +0 -3
- package/lib/ntqq/sdk/api/group.js +0 -124
- package/lib/ntqq/sdk/api/guild.js +0 -80
- package/lib/ntqq/sdk/api/index.js +0 -4
- package/lib/ntqq/sdk/counter.js +0 -15
- package/lib/qq/alemon/doc.js +0 -93
- package/lib/qq/alemon/message/AUDIO_ACTION.js +0 -108
- package/lib/qq/alemon/message/CHANNEL.js +0 -102
- package/lib/qq/alemon/message/DIRECT_MESSAGE.js +0 -87
- package/lib/qq/alemon/message/FORUMS_EVENT.js +0 -106
- package/lib/qq/alemon/message/GUILDS.js +0 -102
- package/lib/qq/alemon/message/GUILD_MEMBERS.js +0 -97
- package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +0 -101
- package/lib/qq/alemon/message/MESSAGE_AUDIT.js +0 -96
- package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +0 -125
- package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +0 -153
- package/lib/qq/alemon/permissions.js +0 -41
- package/lib/qq/alemon/types.js +0 -21
- package/lib/qq/login.js +0 -18
- package/lib/qq/qq.js +0 -15
- package/lib/villa/login.js +0 -21
- package/lib/villa/sdk/all.js +0 -4
- package/lib/villa/sdk/counter.js +0 -9
- package/lib/villa/sdk/mechanism.js +0 -254
- package/lib/villa/sdk/reply.js +0 -62
- package/lib/villa/sdk/utils.js +0 -83
- package/lib/villa/villa.js +0 -7
- package/types/api/controller.d.ts +0 -32
- package/types/core/application.d.ts +0 -65
- package/types/core/apps.d.ts +0 -291
- package/types/core/cache/app.d.ts +0 -11
- package/types/core/cache/arg.d.ts +0 -10
- package/types/core/cache/event.d.ts +0 -10
- package/types/core/cache/index.d.ts +0 -6
- package/types/core/cache/message.d.ts +0 -10
- package/types/core/cache/priority.d.ts +0 -10
- package/types/core/cache/slicing.d.ts +0 -20
- package/types/core/call.d.ts +0 -70
- package/types/core/configs.d.ts +0 -82
- package/types/core/conversation/index.d.ts +0 -76
- package/types/core/dealmsg.d.ts +0 -14
- package/types/core/dev/types.d.ts +0 -37
- package/types/core/help.d.ts +0 -11
- package/types/core/plugin/index.d.ts +0 -95
- package/types/core/utils/screenshot.d.ts +0 -28
- package/types/discord/discord.d.ts +0 -28
- package/types/discord/login.d.ts +0 -7
- package/types/discord/sdk/base.d.ts +0 -14
- package/types/discord/sdk/cdn.d.ts +0 -16
- package/types/kook/kook.d.ts +0 -19
- package/types/kook/login.d.ts +0 -7
- package/types/log/event.d.ts +0 -15
- package/types/log/index.d.ts +0 -10
- package/types/log/user.d.ts +0 -15
- package/types/ntqq/alemon/group/bot.d.ts +0 -8
- package/types/ntqq/alemon/group/controller.d.ts +0 -77
- package/types/ntqq/alemon/group/direct.d.ts +0 -81
- package/types/ntqq/alemon/guild/controller.d.ts +0 -1
- package/types/ntqq/login.d.ts +0 -6
- package/types/ntqq/ntqq.d.ts +0 -55
- package/types/ntqq/sdk/api/auth.d.ts +0 -8
- package/types/ntqq/sdk/api/config.d.ts +0 -3
- package/types/ntqq/sdk/api/group.d.ts +0 -99
- package/types/ntqq/sdk/api/guild.d.ts +0 -35
- package/types/ntqq/sdk/api/index.d.ts +0 -4
- package/types/ntqq/sdk/counter.d.ts +0 -7
- package/types/qq/alemon/doc.d.ts +0 -93
- package/types/qq/alemon/message/AUDIO_ACTION.d.ts +0 -15
- package/types/qq/alemon/message/CHANNEL.d.ts +0 -36
- package/types/qq/alemon/message/DIRECT_MESSAGE.d.ts +0 -49
- package/types/qq/alemon/message/FORUMS_EVENT.d.ts +0 -38
- package/types/qq/alemon/message/GUILDS.d.ts +0 -39
- package/types/qq/alemon/message/GUILD_MEMBERS.d.ts +0 -26
- package/types/qq/alemon/message/GUILD_MESSAGES.d.ts +0 -12
- package/types/qq/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +0 -24
- package/types/qq/alemon/message/INTERACTION.d.ts +0 -8
- package/types/qq/alemon/message/MESSAGE_AUDIT.d.ts +0 -9
- package/types/qq/alemon/message/OPEN_FORUMS_EVENT.d.ts +0 -42
- package/types/qq/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +0 -51
- package/types/qq/alemon/permissions.d.ts +0 -29
- package/types/qq/alemon/types.d.ts +0 -20
- package/types/qq/login.d.ts +0 -6
- package/types/qq/qq.d.ts +0 -50
- package/types/villa/login.d.ts +0 -7
- package/types/villa/sdk/all.d.ts +0 -4
- package/types/villa/sdk/mechanism.d.ts +0 -11
- package/types/villa/sdk/reply.d.ts +0 -26
- package/types/villa/sdk/utils.d.ts +0 -11
- package/types/villa/villa.d.ts +0 -34
- package/lib/core/{dev → processor}/data.js +0 -0
- package/lib/core/{dev → processor}/path.js +12 -12
- package/lib/core/{dev → processor}/types.js +0 -0
- package/lib/{core/plugin → ntqq/alemon}/types.js +0 -0
- package/types/core/{dev → processor}/data.d.ts +0 -0
- package/types/core/{dev → processor}/path.d.ts +9 -9
- /package/types/ntqq/alemon/{group/message → message}/C2C_MESSAGE_CREATE.d.ts +0 -0
- /package/types/ntqq/alemon/{group/message → message}/GROUP_AT_MESSAGE_CREATE.d.ts +0 -0
- /package/types/ntqq/alemon/{group/segment.d.ts → segment.d.ts} +0 -0
- /package/types/ntqq/alemon/{group/types.d.ts → types.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -167,6 +167,20 @@ npm run build
|
|
|
167
167
|
|
|
168
168
|
该程序可放置于`plugins/your plugin name`文件夹下
|
|
169
169
|
|
|
170
|
+
# Unknown file ".ts"
|
|
171
|
+
|
|
172
|
+
node >= 20.0.0
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
npx ts-node alemon.config.ts
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
更改为
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
node --no-warnings=ExperimentalWarning --loader ts-node/esm alemon.config.ts
|
|
182
|
+
```
|
|
183
|
+
|
|
170
184
|
### Dependencies
|
|
171
185
|
|
|
172
186
|
```json
|
package/lib/api/index.js
CHANGED
|
@@ -4,27 +4,18 @@
|
|
|
4
4
|
* ***********
|
|
5
5
|
*/
|
|
6
6
|
export { ClientQQ } from '../qq/index.js';
|
|
7
|
-
/**
|
|
8
|
-
* villa客户端
|
|
9
|
-
*/
|
|
10
7
|
export { ClientVILLA } from '../villa/index.js';
|
|
11
|
-
/**
|
|
12
|
-
* ntqq客户端
|
|
13
|
-
*/
|
|
14
8
|
export { ClientNTQQ } from '../ntqq/index.js';
|
|
15
|
-
/**
|
|
16
|
-
* server客户端
|
|
17
|
-
*/
|
|
18
9
|
export { ClientKOA } from '../koa/index.js';
|
|
19
|
-
/**
|
|
20
|
-
* kook客户端
|
|
21
|
-
*/
|
|
22
10
|
export { ClientKOOK } from '../kook/index.js';
|
|
23
|
-
/**
|
|
24
|
-
* discord
|
|
25
|
-
*/
|
|
26
11
|
export { ClientDISOCRD } from '../discord/index.js';
|
|
27
12
|
/**
|
|
28
|
-
*
|
|
13
|
+
* ************
|
|
14
|
+
* Controllers
|
|
15
|
+
* ************
|
|
29
16
|
*/
|
|
30
|
-
export
|
|
17
|
+
export { Controllers as ControllerVILLA } from '../villa/alemon/controller.js';
|
|
18
|
+
export { Controllers as ControllerQQ } from '../qq/alemon/controller.js';
|
|
19
|
+
export { Controllers as ControllerDISCORD } from '../discord/alemon/controller.js';
|
|
20
|
+
export { Controllers as ControllerNTQQ } from '../ntqq/alemon/controller.js';
|
|
21
|
+
export { Controllers as ControllerKOOK } from '../kook/alemon/controller.js';
|
package/lib/config/login.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { DefaultConfig } from '../default/index.js';
|
|
2
|
-
import { defineKOOK as kook } from '../kook/
|
|
3
|
-
import { defineVILLA as villa } from '../villa/
|
|
4
|
-
import { defineQQ as qq } from '../qq/
|
|
5
|
-
import { defineNtqq as ntqq } from '../ntqq/
|
|
6
|
-
import { defineDISCORD as discord } from '../discord/
|
|
2
|
+
import { defineKOOK as kook } from '../kook/sdk/ws.js';
|
|
3
|
+
import { defineVILLA as villa } from '../villa/sdk/wss.js';
|
|
4
|
+
import { defineQQ as qq } from '../qq/sdk/wss.js';
|
|
5
|
+
import { defineNtqq as ntqq } from '../ntqq/sdk/wss.js';
|
|
6
|
+
import { defineDISCORD as discord } from '../discord/sdk/wss.js';
|
|
7
7
|
import { Screenshot } from '../core/index.js';
|
|
8
|
-
class
|
|
9
|
-
data =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
class BaseConfig {
|
|
9
|
+
#data = null;
|
|
10
|
+
constructor(val) {
|
|
11
|
+
this.#data = val;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 设置配置
|
|
15
|
+
* @param key
|
|
16
|
+
* @param val
|
|
17
|
+
*/
|
|
18
18
|
set(key, val) {
|
|
19
19
|
if (key == 'puppeteer') {
|
|
20
20
|
// pup 不用检查 直接覆盖
|
|
21
21
|
for (const item in val) {
|
|
22
|
-
this
|
|
22
|
+
this.#data[key][item] = val[item];
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
for (const item in val) {
|
|
27
27
|
// 当前仅当同属性名的时候才会覆盖默认配置
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(this
|
|
29
|
-
this
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(this.#data[key], item)) {
|
|
29
|
+
this.#data[key][item] = val[item];
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
// 不属于默认
|
|
33
33
|
try {
|
|
34
|
-
this
|
|
35
|
-
this
|
|
34
|
+
this.#data[key] = {};
|
|
35
|
+
this.#data[key] = val[item];
|
|
36
36
|
console.info('KEY secess');
|
|
37
37
|
}
|
|
38
38
|
catch {
|
|
@@ -42,25 +42,24 @@ class BotConfig {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* 读取配置
|
|
47
|
+
* @param key
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
45
50
|
get(key) {
|
|
46
|
-
return this
|
|
51
|
+
return this.#data[key];
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* 机器人配置
|
|
51
56
|
*/
|
|
52
|
-
export const BOTCONFIG = new
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* g得到机器人基础配置
|
|
62
|
-
* @param key 配置名
|
|
63
|
-
* @returns 得到配置值
|
|
64
|
-
* @deprecated 已废弃
|
|
65
|
-
*/
|
|
66
|
-
export const getBotConfigByKey = BOTCONFIG.get;
|
|
57
|
+
export const BOTCONFIG = new BaseConfig({
|
|
58
|
+
...DefaultConfig,
|
|
59
|
+
kook,
|
|
60
|
+
villa,
|
|
61
|
+
qq,
|
|
62
|
+
ntqq,
|
|
63
|
+
puppeteer: Screenshot.launch,
|
|
64
|
+
discord
|
|
65
|
+
});
|
package/lib/core/index.js
CHANGED
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
* private
|
|
4
4
|
* ********
|
|
5
5
|
*/
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './configs.js';
|
|
8
|
-
export * from './apps.js';
|
|
9
|
-
export * from './cache/index.js';
|
|
10
|
-
export * from './conversation/index.js';
|
|
11
|
-
export * from './dealmsg.js';
|
|
12
|
-
export * from './application.js';
|
|
6
|
+
export * from './processor/configs.js';
|
|
13
7
|
export * from './typings.js';
|
|
14
8
|
export * from './utils/index.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
export * from './processor/path.js';
|
|
11
|
+
export * from './processor/application.js';
|
|
12
|
+
export * from './processor/log.js';
|
package/lib/core/main.js
CHANGED
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
* public
|
|
4
4
|
* ********
|
|
5
5
|
*/
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './conversation/index.js';
|
|
10
|
-
export * from './plugin/index.js';
|
|
6
|
+
export * from './processor/configs.js';
|
|
7
|
+
export * from './processor/help.js';
|
|
8
|
+
export * from './index.js';
|
|
11
9
|
export * from './utils/index.js';
|
|
12
10
|
export * from './typings.js';
|
|
11
|
+
export * from './types.js';
|
|
12
|
+
export * from './processor/alemon.js';
|
|
13
|
+
export * from './processor/path.js';
|
|
14
|
+
export * from './processor/help.js';
|
|
15
|
+
export * from './processor/plugin.js';
|
|
16
|
+
export * from './processor/subscribe.js';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AppMap } from './data.js';
|
|
2
2
|
import { getAppName } from './path.js';
|
|
3
3
|
import { DoublyLinkedList } from './listdouble.js';
|
|
4
|
+
import memory from 'memory-cache';
|
|
5
|
+
import { Help } from './help.js';
|
|
6
|
+
import { APPCONFIG } from './configs.js';
|
|
4
7
|
/**
|
|
5
8
|
* 应用结构
|
|
6
9
|
*/
|
|
@@ -22,8 +25,10 @@ export class Alemon {
|
|
|
22
25
|
#regular = null;
|
|
23
26
|
// 消息链表
|
|
24
27
|
#list = new DoublyLinkedList();
|
|
28
|
+
#listArr = [];
|
|
25
29
|
// 事件链表
|
|
26
30
|
#elist = new DoublyLinkedList();
|
|
31
|
+
#elistArr = [];
|
|
27
32
|
/**
|
|
28
33
|
* 创建应用
|
|
29
34
|
* @param name 应用名
|
|
@@ -57,11 +62,13 @@ export class Alemon {
|
|
|
57
62
|
/**
|
|
58
63
|
* list查询
|
|
59
64
|
*/
|
|
60
|
-
find() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
find(acount, example, func) {
|
|
66
|
+
for (const node of this.#listArr) {
|
|
67
|
+
if (node.acount == acount &&
|
|
68
|
+
node.example == example &&
|
|
69
|
+
node.func == func) {
|
|
70
|
+
return node;
|
|
71
|
+
}
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
@@ -77,13 +84,17 @@ export class Alemon {
|
|
|
77
84
|
* @param node
|
|
78
85
|
*/
|
|
79
86
|
async responseNode(e, node) {
|
|
87
|
+
//
|
|
88
|
+
if (!e)
|
|
89
|
+
return;
|
|
90
|
+
const time = Date.now();
|
|
80
91
|
/**
|
|
81
92
|
* **********
|
|
82
93
|
* 构造配置
|
|
83
94
|
* **********
|
|
84
95
|
*/
|
|
85
96
|
const func = this.#dataMap.get('event');
|
|
86
|
-
if (func)
|
|
97
|
+
if (typeof func == 'function')
|
|
87
98
|
e = func(e);
|
|
88
99
|
for (const item of this.#strArr) {
|
|
89
100
|
e.msg = e.msg.replace(item.reg, item.str);
|
|
@@ -93,23 +104,19 @@ export class Alemon {
|
|
|
93
104
|
if (typeof argFunc == 'function') {
|
|
94
105
|
arr = await argFunc(e);
|
|
95
106
|
}
|
|
96
|
-
this.#data[node.acount][node.example]
|
|
97
|
-
const time = Date.now();
|
|
107
|
+
this.#data[node.acount][node.example]['e'] = e;
|
|
98
108
|
// 执行
|
|
99
|
-
|
|
109
|
+
this.#data[node.acount][node.example][node.func](e, ...arr)
|
|
100
110
|
.then(res => {
|
|
101
|
-
|
|
111
|
+
if (res && typeof res != 'boolean') {
|
|
112
|
+
e.reply(res);
|
|
113
|
+
}
|
|
114
|
+
console.info(this.#infoFunc(e, node.name, node.acount, node.example, node.func), true, Date.now() - time);
|
|
102
115
|
return res;
|
|
103
116
|
})
|
|
104
117
|
.catch(err => {
|
|
105
|
-
console.error(this
|
|
118
|
+
console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
|
|
106
119
|
});
|
|
107
|
-
// 重执行
|
|
108
|
-
if (res && typeof res != 'boolean') {
|
|
109
|
-
await e.reply(res).catch(err => {
|
|
110
|
-
console.error(this.err(e, node.func, time - Date.now()), err);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
120
|
}
|
|
114
121
|
/**
|
|
115
122
|
* 应用解析
|
|
@@ -117,17 +124,16 @@ export class Alemon {
|
|
|
117
124
|
*/
|
|
118
125
|
async responseMessage(e) {
|
|
119
126
|
// 空的
|
|
120
|
-
if (this.#list.isEmpty)
|
|
127
|
+
if (this.#list.isEmpty() || !e)
|
|
121
128
|
return;
|
|
122
|
-
|
|
123
|
-
const list = this.#list;
|
|
129
|
+
const time = Date.now();
|
|
124
130
|
/**
|
|
125
131
|
* **********
|
|
126
132
|
* 构造配置
|
|
127
133
|
* **********
|
|
128
134
|
*/
|
|
129
135
|
const func = this.#dataMap.get('event');
|
|
130
|
-
if (func)
|
|
136
|
+
if (typeof func == 'function')
|
|
131
137
|
e = func(e);
|
|
132
138
|
for (const item of this.#strArr) {
|
|
133
139
|
e.msg = e.msg.replace(item.reg, item.str);
|
|
@@ -137,39 +143,72 @@ export class Alemon {
|
|
|
137
143
|
if (typeof argFunc == 'function') {
|
|
138
144
|
arr = await argFunc(e);
|
|
139
145
|
}
|
|
146
|
+
const key = `${this.#name}:${e.msg}`;
|
|
147
|
+
// 自动延长过期周期
|
|
148
|
+
const CacheData = memory.get(key);
|
|
149
|
+
if (CacheData) {
|
|
150
|
+
for (const node of CacheData) {
|
|
151
|
+
this.#data[node.acount][node.example]['e'] = e;
|
|
152
|
+
const time = Date.now();
|
|
153
|
+
// 执行
|
|
154
|
+
const res = await this.#data[node.acount][node.example][node.func](e, ...arr)
|
|
155
|
+
.then(res => {
|
|
156
|
+
if (res && typeof res != 'boolean') {
|
|
157
|
+
e.reply(res);
|
|
158
|
+
}
|
|
159
|
+
console.info(this.#infoFunc(e, node.name, node.acount, node.example, node.func), true, Date.now() - time);
|
|
160
|
+
return res;
|
|
161
|
+
})
|
|
162
|
+
.catch(err => {
|
|
163
|
+
console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
|
|
164
|
+
});
|
|
165
|
+
// 不是 false ,也就是不放行
|
|
166
|
+
if (res != false)
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// 结点缓存
|
|
172
|
+
const cache = [];
|
|
140
173
|
/**
|
|
141
174
|
* *******
|
|
142
175
|
* 走表
|
|
143
176
|
* **********
|
|
144
177
|
*/
|
|
145
|
-
for (
|
|
146
|
-
// 不断的取出索引
|
|
147
|
-
const node = list.shift();
|
|
178
|
+
for (const node of this.#listArr) {
|
|
148
179
|
// 索引匹配
|
|
149
180
|
if (node.reg.test(e.msg)) {
|
|
150
|
-
this.#data[node.acount][node.example]
|
|
151
|
-
const time = Date.now();
|
|
181
|
+
this.#data[node.acount][node.example]['e'] = e;
|
|
152
182
|
// 执行
|
|
153
183
|
const res = await this.#data[node.acount][node.example][node.func](e, ...arr)
|
|
154
184
|
.then(res => {
|
|
155
|
-
|
|
185
|
+
if (res && typeof res != 'boolean') {
|
|
186
|
+
e.reply(res);
|
|
187
|
+
}
|
|
188
|
+
console.info(this.#infoFunc(e, node.name, node.acount, node.example, node.func), true, Date.now() - time);
|
|
156
189
|
return res;
|
|
157
190
|
})
|
|
158
191
|
.catch(err => {
|
|
159
|
-
console.error(this
|
|
192
|
+
console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
|
|
160
193
|
// 错误了就强制中断
|
|
161
194
|
});
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
await e.reply(res).catch(err => {
|
|
165
|
-
console.error(this.err(e, node.func, time - Date.now()), err);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
195
|
+
// 推送缓存
|
|
196
|
+
cache.push(node);
|
|
168
197
|
// 不是 false ,也就是不放行
|
|
169
198
|
if (res != false)
|
|
170
199
|
break;
|
|
171
200
|
}
|
|
172
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* ********
|
|
204
|
+
* 记录缓存
|
|
205
|
+
* ********
|
|
206
|
+
*/
|
|
207
|
+
if (cache.length != 0) {
|
|
208
|
+
// 5分钟的缓存
|
|
209
|
+
memory.put(e.msg, cache, 5 * 60 * 1000);
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
173
212
|
}
|
|
174
213
|
/**
|
|
175
214
|
* 响应消息类型
|
|
@@ -177,15 +216,15 @@ export class Alemon {
|
|
|
177
216
|
*/
|
|
178
217
|
async responseEventType(e) {
|
|
179
218
|
// 空的
|
|
180
|
-
if (this.#elist.isEmpty)
|
|
219
|
+
if (this.#elist.isEmpty() || !e)
|
|
181
220
|
return;
|
|
182
|
-
const
|
|
221
|
+
const time = Date.now();
|
|
183
222
|
/**
|
|
184
223
|
* *****
|
|
185
224
|
* ******
|
|
186
225
|
*/
|
|
187
226
|
const func = this.#dataMap.get('event');
|
|
188
|
-
if (func)
|
|
227
|
+
if (typeof func == 'function')
|
|
189
228
|
e = func(e);
|
|
190
229
|
for (const item of this.#strArr) {
|
|
191
230
|
e.msg = e.msg.replace(item.reg, item.str);
|
|
@@ -195,35 +234,68 @@ export class Alemon {
|
|
|
195
234
|
if (typeof argFunc == 'function') {
|
|
196
235
|
arr = await argFunc(e);
|
|
197
236
|
}
|
|
237
|
+
const key = `${this.#name}:${e.event}:${e.typing}`;
|
|
238
|
+
// 自动延长过期周期
|
|
239
|
+
const CacheData = memory.get(key);
|
|
240
|
+
if (CacheData) {
|
|
241
|
+
for (const node of CacheData) {
|
|
242
|
+
this.#data[node.acount][node.example]['e'] = e;
|
|
243
|
+
const time = Date.now();
|
|
244
|
+
const res = await this.#data[node.acount][node.example][node.func](e, ...arr)
|
|
245
|
+
.then(res => {
|
|
246
|
+
console.info(this.#infoFunc(e, node.name, node.acount, node.example, node.func), true, Date.now() - time);
|
|
247
|
+
if (res && typeof res != 'boolean') {
|
|
248
|
+
e.reply(res);
|
|
249
|
+
}
|
|
250
|
+
return res;
|
|
251
|
+
})
|
|
252
|
+
.catch(err => {
|
|
253
|
+
console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
|
|
254
|
+
});
|
|
255
|
+
// 不是 false ,也就是不放行
|
|
256
|
+
if (res != false)
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const cache = [];
|
|
198
262
|
/**
|
|
199
263
|
* ******
|
|
200
264
|
* *****
|
|
201
265
|
*/
|
|
202
|
-
for (
|
|
203
|
-
const node = list.shift();
|
|
266
|
+
for (const node of this.#elistArr) {
|
|
204
267
|
// 类型不符
|
|
205
268
|
if (node.event !== e.event || node.typing !== e.typing)
|
|
206
269
|
continue;
|
|
207
270
|
//
|
|
208
|
-
this.#data[node.acount][node.example]
|
|
209
|
-
const time = Date.now();
|
|
271
|
+
this.#data[node.acount][node.example]['e'] = e;
|
|
210
272
|
const res = await this.#data[node.acount][node.example][node.func](e, ...arr)
|
|
211
273
|
.then(res => {
|
|
212
|
-
|
|
274
|
+
if (res && typeof res != 'boolean') {
|
|
275
|
+
e.reply(res);
|
|
276
|
+
}
|
|
277
|
+
console.info(this.#infoFunc(e, node.name, node.acount, node.example, node.func), true, Date.now() - time);
|
|
213
278
|
return res;
|
|
214
279
|
})
|
|
215
280
|
.catch(err => {
|
|
216
|
-
console.error(this
|
|
281
|
+
console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
|
|
217
282
|
});
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
console.error(this.err(e, node.func, time - Date.now()), err);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
283
|
+
// 推送缓存
|
|
284
|
+
cache.push(node);
|
|
223
285
|
// 不是 false ,也就是不放行
|
|
224
286
|
if (res != false)
|
|
225
287
|
break;
|
|
226
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* ********
|
|
291
|
+
* 记录缓存
|
|
292
|
+
* ********
|
|
293
|
+
*/
|
|
294
|
+
if (cache.length != 0) {
|
|
295
|
+
// 15分钟的缓存
|
|
296
|
+
memory.put(key, cache, 60 * 15);
|
|
297
|
+
}
|
|
298
|
+
return;
|
|
227
299
|
}
|
|
228
300
|
/**
|
|
229
301
|
* 扩展参数
|
|
@@ -234,6 +306,16 @@ export class Alemon {
|
|
|
234
306
|
this.#dataMap.set('arg', fnc);
|
|
235
307
|
return this;
|
|
236
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
*
|
|
311
|
+
* 扩展参数
|
|
312
|
+
* @param fnc
|
|
313
|
+
* @returns
|
|
314
|
+
* @deprecated 已废弃
|
|
315
|
+
*/
|
|
316
|
+
setArg(fnc) {
|
|
317
|
+
return this.arg(fnc);
|
|
318
|
+
}
|
|
237
319
|
/**
|
|
238
320
|
* 重定义ecent
|
|
239
321
|
* @param fnc
|
|
@@ -243,6 +325,15 @@ export class Alemon {
|
|
|
243
325
|
this.#dataMap.set('event', fnc);
|
|
244
326
|
return this;
|
|
245
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* 重定义ecent
|
|
330
|
+
* @param fnc
|
|
331
|
+
* @returns
|
|
332
|
+
* @deprecated 已废弃
|
|
333
|
+
*/
|
|
334
|
+
setMessage(fnc) {
|
|
335
|
+
return this.event(fnc);
|
|
336
|
+
}
|
|
246
337
|
/**
|
|
247
338
|
* 字符串切割
|
|
248
339
|
* @param reg
|
|
@@ -256,6 +347,16 @@ export class Alemon {
|
|
|
256
347
|
});
|
|
257
348
|
return this;
|
|
258
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* 字符串切割
|
|
352
|
+
* @param reg
|
|
353
|
+
* @param str
|
|
354
|
+
* @returns
|
|
355
|
+
* @deprecated 已废弃
|
|
356
|
+
*/
|
|
357
|
+
setCharacter(val) {
|
|
358
|
+
return this.replace(/^(\/|#)/, val);
|
|
359
|
+
}
|
|
259
360
|
/**
|
|
260
361
|
* 集合
|
|
261
362
|
* @param AplguinMap
|
|
@@ -267,9 +368,17 @@ export class Alemon {
|
|
|
267
368
|
// 收集
|
|
268
369
|
for (const example in AplguinMap) {
|
|
269
370
|
const keys = new AplguinMap[example]();
|
|
270
|
-
//
|
|
371
|
+
// 过滤事件
|
|
372
|
+
const event = APPCONFIG.get('event');
|
|
373
|
+
if (keys.event && event.includes(keys.event)) {
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
// name
|
|
271
377
|
keys.name = this.#name;
|
|
378
|
+
// 层级
|
|
272
379
|
keys.acount = this.#acount;
|
|
380
|
+
// 实例名
|
|
381
|
+
keys.example = example;
|
|
273
382
|
// 记录
|
|
274
383
|
this.#data[this.#acount][example] = keys;
|
|
275
384
|
// 忽视非法key
|
|
@@ -353,41 +462,64 @@ export class Alemon {
|
|
|
353
462
|
this.#acount++;
|
|
354
463
|
return this;
|
|
355
464
|
}
|
|
465
|
+
/**
|
|
466
|
+
* 加载
|
|
467
|
+
* @param AplguinMap
|
|
468
|
+
* @returns
|
|
469
|
+
* @deprecated 已废弃
|
|
470
|
+
*/
|
|
471
|
+
component(AplguinMap = {}) {
|
|
472
|
+
return this.use(AplguinMap);
|
|
473
|
+
}
|
|
356
474
|
/**
|
|
357
475
|
* 挂载
|
|
358
476
|
*/
|
|
359
477
|
mount() {
|
|
360
478
|
// 构造大正则
|
|
361
479
|
this.#regular = new RegExp(this.#mergedRegexArr.map(regex => regex.source).join('|'));
|
|
362
|
-
|
|
480
|
+
// 数组化
|
|
481
|
+
this.#elistArr = this.#elist.toArray();
|
|
482
|
+
this.#listArr = this.#list.toArray();
|
|
483
|
+
// 设置
|
|
363
484
|
AppMap.set(this.#name, this);
|
|
485
|
+
// 生成json
|
|
486
|
+
new Help(this.#name).create(this.#listArr);
|
|
364
487
|
}
|
|
488
|
+
#infoFunc = (e, name, acount, example, funcName) => {
|
|
489
|
+
return `[${e.event}] [${e.typing}] [${name}] [${acount}] [${example}] [${funcName}]`;
|
|
490
|
+
};
|
|
365
491
|
/**
|
|
366
|
-
*
|
|
492
|
+
* 自定义
|
|
367
493
|
* @param data
|
|
368
494
|
* @param funcName
|
|
369
495
|
* @returns
|
|
370
496
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
497
|
+
info(func) {
|
|
498
|
+
this.#infoFunc = func;
|
|
499
|
+
return this;
|
|
373
500
|
}
|
|
501
|
+
#errorFunc = (e, name, acount, example, funcName) => {
|
|
502
|
+
return `[${e.event}] [${e.typing}] [${name}] [${acount}] [${example}] [${funcName}]`;
|
|
503
|
+
};
|
|
374
504
|
/**
|
|
375
|
-
*
|
|
505
|
+
* 错误打印
|
|
376
506
|
* @param data
|
|
377
507
|
* @param funcName
|
|
378
508
|
* @returns
|
|
379
509
|
*/
|
|
380
|
-
|
|
381
|
-
|
|
510
|
+
error(func) {
|
|
511
|
+
this.#errorFunc = func;
|
|
512
|
+
return this;
|
|
382
513
|
}
|
|
383
514
|
/**
|
|
384
515
|
* 响应消息类型
|
|
385
516
|
* @param e
|
|
386
517
|
*/
|
|
387
518
|
async response(e, event) {
|
|
519
|
+
const time = Date.now();
|
|
388
520
|
if (this.#CallData[event]) {
|
|
389
521
|
const func = this.#dataMap.get('event');
|
|
390
|
-
if (func)
|
|
522
|
+
if (typeof func == 'function')
|
|
391
523
|
e = func(e);
|
|
392
524
|
for (const item of this.#strArr) {
|
|
393
525
|
e.msg = e.msg.replace(item.reg, item.str);
|
|
@@ -398,14 +530,16 @@ export class Alemon {
|
|
|
398
530
|
arr = await argFunc(e);
|
|
399
531
|
}
|
|
400
532
|
const FuncName = String(this.#CallData[event]['fnc']).match(/:\s*(\w+)\]/)[1];
|
|
401
|
-
const time = Date.now();
|
|
402
533
|
this.#CallData[event](e, ...arr)
|
|
403
534
|
.then(res => {
|
|
404
|
-
|
|
535
|
+
if (res && typeof res != 'boolean') {
|
|
536
|
+
e.reply(res);
|
|
537
|
+
}
|
|
538
|
+
console.info(this.#infoFunc(e, this.#name, 0, 'on', FuncName), true, Date.now() - time);
|
|
405
539
|
return res;
|
|
406
540
|
})
|
|
407
541
|
.catch(err => {
|
|
408
|
-
console.error(this
|
|
542
|
+
console.error(this.#infoFunc(e, this.#name, 0, 'on', FuncName), false, Date.now() - time, err);
|
|
409
543
|
});
|
|
410
544
|
}
|
|
411
545
|
return false;
|