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.
Files changed (352) hide show
  1. package/README.md +14 -0
  2. package/lib/api/index.js +8 -17
  3. package/lib/config/login.js +35 -36
  4. package/lib/core/index.js +5 -7
  5. package/lib/core/main.js +9 -5
  6. package/lib/core/{dev → processor}/alemon.js +194 -60
  7. package/lib/core/{dev → processor}/application.js +29 -48
  8. package/lib/core/processor/configs.js +67 -0
  9. package/lib/core/processor/help.js +37 -0
  10. package/lib/core/{dev → processor}/listdouble.js +31 -31
  11. package/lib/{log/index.js → core/processor/log.js} +2 -8
  12. package/lib/core/{dev → processor}/plugin.js +44 -14
  13. package/lib/core/{dev → processor}/subscribe.js +7 -20
  14. package/lib/core/types.js +24 -0
  15. package/lib/core/utils/buffer.js +1 -37
  16. package/lib/core/utils/counter.js +17 -0
  17. package/lib/core/utils/index.js +1 -1
  18. package/lib/core/utils/ip.js +6 -14
  19. package/lib/core/utils/puppeteer.js +31 -26
  20. package/lib/core/utils/utils.js +1 -12
  21. package/lib/define/main.js +33 -106
  22. package/lib/discord/alemon/bot.js +3 -8
  23. package/lib/discord/alemon/controller.js +20 -41
  24. package/lib/discord/alemon/conversation.js +6 -12
  25. package/lib/discord/alemon/message/CHANNEL_TOPIC_UPDATE.js +1 -4
  26. package/lib/discord/alemon/message/CHANNEL_UPDATE.js +1 -4
  27. package/lib/discord/alemon/message/GUILD_MEMBER_ADD.js +1 -4
  28. package/lib/discord/alemon/message/GUILD_MEMBER_REMOVE.js +1 -4
  29. package/lib/discord/alemon/message/GUILD_MEMBER_UPDATE.js +1 -4
  30. package/lib/discord/alemon/message/MESSAGE_CREATE.js +10 -29
  31. package/lib/discord/alemon/message/MESSAGE_DELETE.js +1 -4
  32. package/lib/discord/alemon/message/MESSAGE_REACTION_ADD.js +1 -4
  33. package/lib/discord/alemon/message/MESSAGE_UPDATE.js +1 -4
  34. package/lib/discord/alemon/message/PRESENCE_UPDATE.js +1 -4
  35. package/lib/discord/alemon/message/TYPING_START.js +1 -4
  36. package/lib/discord/alemon/message/VOICE_CHANNEL_STATUS_UPDATE.js +1 -4
  37. package/lib/discord/alemon/message/VOICE_STATE_UPDATE.js +1 -4
  38. package/lib/discord/alemon/reply.js +7 -8
  39. package/lib/discord/index.js +12 -14
  40. package/lib/discord/sdk/api.js +240 -47
  41. package/lib/discord/sdk/config.js +6 -21
  42. package/lib/discord/sdk/index.js +1 -1
  43. package/lib/discord/sdk/log.js +4 -4
  44. package/lib/discord/sdk/wss.js +155 -111
  45. package/lib/index.js +9 -9
  46. package/lib/koa/back.js +2 -2
  47. package/lib/koa/client.js +7 -7
  48. package/lib/koa/config.js +3 -21
  49. package/lib/koa/file.js +78 -75
  50. package/lib/koa/index.js +1 -1
  51. package/lib/kook/alemon/bot.js +3 -8
  52. package/lib/kook/alemon/controller.js +35 -49
  53. package/lib/kook/alemon/conversation.js +2 -3
  54. package/lib/kook/alemon/direct.js +30 -39
  55. package/lib/kook/alemon/message/DIRECT_MESSAGE.js +9 -22
  56. package/lib/kook/alemon/message/GUILD_MESSAGE_REACTIONS.js +8 -25
  57. package/lib/kook/alemon/message/PUBLIC_GUILD_MESSAGES.js +9 -26
  58. package/lib/kook/alemon/reply.js +9 -10
  59. package/lib/kook/index.js +21 -30
  60. package/lib/kook/sdk/api.js +297 -249
  61. package/lib/kook/sdk/config.js +3 -20
  62. package/lib/kook/sdk/index.js +1 -1
  63. package/lib/kook/sdk/log.js +11 -0
  64. package/lib/kook/sdk/ws.js +107 -128
  65. package/lib/{login.js → login/index.js} +5 -1
  66. package/lib/ntqq/alemon/bot.js +6 -0
  67. package/lib/ntqq/alemon/{group/controller.js → controller.js} +27 -42
  68. package/lib/ntqq/alemon/conversation.js +7 -8
  69. package/lib/ntqq/alemon/{group/direct.js → direct.js} +40 -59
  70. package/lib/ntqq/alemon/{group/message → message}/C2C_MESSAGE_CREATE.js +8 -21
  71. package/lib/ntqq/alemon/{group/message → message}/GROUP_AT_MESSAGE_CREATE.js +9 -22
  72. package/lib/ntqq/alemon/{group/reply.js → reply.js} +11 -18
  73. package/lib/ntqq/alemon/{group/segment.js → segment.js} +1 -1
  74. package/lib/ntqq/index.js +15 -21
  75. package/lib/ntqq/sdk/api.js +155 -0
  76. package/lib/ntqq/sdk/config.js +3 -21
  77. package/lib/ntqq/sdk/index.js +1 -1
  78. package/lib/ntqq/sdk/intents.js +1 -76
  79. package/lib/ntqq/sdk/log.js +4 -4
  80. package/lib/ntqq/sdk/wss.js +187 -169
  81. package/lib/qq/alemon/bot.js +3 -8
  82. package/lib/qq/alemon/controller.js +35 -104
  83. package/lib/qq/alemon/conversation.js +53 -139
  84. package/lib/qq/alemon/direct.js +29 -53
  85. package/lib/qq/alemon/message/AT_MESSAGE_CREATE.js +117 -0
  86. package/lib/qq/alemon/message/CHANNEL_CREATE.js +71 -0
  87. package/lib/qq/alemon/message/CHANNEL_DELETE.js +71 -0
  88. package/lib/qq/alemon/message/CHANNEL_UPDATE.js +71 -0
  89. package/lib/qq/alemon/message/DIRECT_MESSAGE_CREATE.js +57 -0
  90. package/lib/qq/alemon/message/DIRECT_MESSAGE_DELETE.js +57 -0
  91. package/lib/qq/alemon/message/GUILD_CREATE.js +71 -0
  92. package/lib/qq/alemon/message/GUILD_DELETE.js +71 -0
  93. package/lib/qq/alemon/message/GUILD_MEMBER_ADD.js +76 -0
  94. package/lib/qq/alemon/message/GUILD_MEMBER_REMOVE.js +76 -0
  95. package/lib/qq/alemon/message/GUILD_MEMBER_UPDATE.js +76 -0
  96. package/lib/qq/alemon/message/GUILD_UPDATE.js +71 -0
  97. package/lib/qq/alemon/message/{INTERACTION.js → INTERACTION_CREATE.js} +16 -40
  98. package/lib/qq/alemon/message/MESSAGE_CREATE.js +128 -0
  99. package/lib/qq/alemon/message/{GUILD_MESSAGES.js → MESSAGE_DELETE.js} +33 -57
  100. package/lib/qq/alemon/message/MESSAGE_REACTION_ADD.js +75 -0
  101. package/lib/qq/alemon/message/MESSAGE_REACTION_REMOVE.js +75 -0
  102. package/lib/qq/alemon/message/PUBLIC_MESSAGE_DELETE.js +69 -0
  103. package/lib/qq/alemon/reply.js +11 -20
  104. package/lib/qq/index.js +14 -43
  105. package/lib/qq/sdk/api.js +514 -73
  106. package/lib/qq/sdk/config.js +5 -21
  107. package/lib/qq/sdk/index.js +1 -1
  108. package/lib/qq/sdk/intents.js +1 -42
  109. package/lib/qq/sdk/log.js +4 -4
  110. package/lib/qq/sdk/typings.js +1 -1
  111. package/lib/qq/sdk/wss.js +135 -127
  112. package/lib/villa/alemon/controller.js +82 -199
  113. package/lib/villa/alemon/conversation.js +2 -0
  114. package/lib/villa/alemon/message/GUILD_BOT.js +5 -22
  115. package/lib/villa/alemon/message/GUILD_MEMBERS.js +5 -22
  116. package/lib/villa/alemon/message/GUILD_MESSAGE_REACTIONS.js +5 -22
  117. package/lib/villa/alemon/message/MESSAGES.js +5 -25
  118. package/lib/villa/alemon/message/MESSAGE_AUDIT.js +5 -22
  119. package/lib/villa/alemon/message/MESSAGE_BUTTON.js +5 -25
  120. package/lib/villa/alemon/reply.js +8 -15
  121. package/lib/villa/index.js +18 -20
  122. package/lib/villa/sdk/api.js +1119 -608
  123. package/lib/villa/sdk/config.js +3 -20
  124. package/lib/villa/sdk/index.js +1 -1
  125. package/lib/villa/sdk/log.js +4 -4
  126. package/lib/villa/sdk/wss.js +198 -159
  127. package/package.json +8 -13
  128. package/resources/index.html +28 -31
  129. package/types/api/index.d.ts +8 -17
  130. package/types/config/login.d.ts +17 -20
  131. package/types/config/types.d.ts +6 -6
  132. package/types/core/index.d.ts +5 -7
  133. package/types/core/main.d.ts +9 -5
  134. package/types/core/{dev → processor}/alemon.d.ts +44 -12
  135. package/types/core/{dev → processor}/application.d.ts +5 -5
  136. package/types/core/processor/configs.d.ts +76 -0
  137. package/types/core/processor/help.d.ts +16 -0
  138. package/types/core/{dev → processor}/listdouble.d.ts +1 -3
  139. package/types/core/processor/log.d.ts +7 -0
  140. package/types/core/{dev → processor}/plugin.d.ts +21 -5
  141. package/types/core/{dev → processor}/subscribe.d.ts +6 -13
  142. package/types/core/{plugin → processor}/types.d.ts +39 -2
  143. package/types/core/types.d.ts +162 -0
  144. package/types/core/typings.d.ts +5 -151
  145. package/types/core/utils/buffer.d.ts +0 -36
  146. package/types/{villa/sdk → core/utils}/counter.d.ts +3 -1
  147. package/types/core/utils/index.d.ts +1 -1
  148. package/types/core/utils/ip.d.ts +1 -9
  149. package/types/core/utils/puppeteer.d.ts +0 -8
  150. package/types/core/utils/utils.d.ts +1 -13
  151. package/types/default/types.d.ts +5 -5
  152. package/types/define/main.d.ts +0 -6
  153. package/types/define/types.d.ts +3 -15
  154. package/types/discord/alemon/bot.d.ts +3 -3
  155. package/types/discord/alemon/controller.d.ts +6 -93
  156. package/types/discord/index.d.ts +1 -1
  157. package/types/discord/sdk/api.d.ts +167 -25
  158. package/types/discord/sdk/config.d.ts +4 -12
  159. package/types/discord/sdk/index.d.ts +1 -1
  160. package/types/discord/sdk/wss.d.ts +39 -16
  161. package/types/index.d.ts +7 -7
  162. package/types/koa/config.d.ts +2 -10
  163. package/types/koa/file.d.ts +27 -23
  164. package/types/koa/index.d.ts +1 -1
  165. package/types/kook/alemon/bot.d.ts +3 -3
  166. package/types/kook/alemon/controller.d.ts +79 -64
  167. package/types/kook/alemon/direct.d.ts +106 -70
  168. package/types/kook/alemon/message/DIRECT_MESSAGE.d.ts +2 -1
  169. package/types/kook/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +2 -2
  170. package/types/kook/alemon/reply.d.ts +7 -1
  171. package/types/kook/index.d.ts +1 -1
  172. package/types/kook/sdk/api.d.ts +253 -247
  173. package/types/kook/sdk/config.d.ts +2 -12
  174. package/types/kook/sdk/index.d.ts +1 -1
  175. package/types/kook/sdk/log.d.ts +2 -0
  176. package/types/kook/sdk/ws.d.ts +28 -10
  177. package/types/{login.d.ts → login/index.d.ts} +2 -2
  178. package/types/ntqq/alemon/bot.d.ts +8 -0
  179. package/types/ntqq/alemon/controller.d.ts +45 -0
  180. package/types/ntqq/alemon/direct.d.ts +72 -0
  181. package/types/ntqq/alemon/{group/reply.d.ts → reply.d.ts} +4 -1
  182. package/types/ntqq/index.d.ts +1 -1
  183. package/types/ntqq/sdk/api.d.ts +120 -0
  184. package/types/ntqq/sdk/config.d.ts +2 -12
  185. package/types/ntqq/sdk/index.d.ts +1 -1
  186. package/types/ntqq/sdk/intents.d.ts +1 -8
  187. package/types/ntqq/sdk/wss.d.ts +54 -17
  188. package/types/qq/alemon/bot.d.ts +3 -3
  189. package/types/qq/alemon/controller.d.ts +13 -100
  190. package/types/qq/alemon/conversation.d.ts +1 -1
  191. package/types/qq/alemon/direct.d.ts +62 -71
  192. package/types/qq/alemon/message/AT_MESSAGE_CREATE.d.ts +40 -0
  193. package/types/qq/alemon/message/CHANNEL_CREATE.d.ts +20 -0
  194. package/types/qq/alemon/message/CHANNEL_DELETE.d.ts +20 -0
  195. package/types/qq/alemon/message/CHANNEL_UPDATE.d.ts +20 -0
  196. package/types/qq/alemon/message/DIRECT_MESSAGE_CREATE.d.ts +34 -0
  197. package/types/qq/alemon/message/DIRECT_MESSAGE_DELETE.d.ts +22 -0
  198. package/types/qq/alemon/message/GUILD_CREATE.d.ts +20 -0
  199. package/types/qq/alemon/message/GUILD_DELETE.d.ts +20 -0
  200. package/types/qq/alemon/message/GUILD_MEMBER_ADD.d.ts +19 -0
  201. package/types/qq/alemon/message/GUILD_MEMBER_REMOVE.d.ts +19 -0
  202. package/types/qq/alemon/message/GUILD_MEMBER_UPDATE.d.ts +19 -0
  203. package/types/qq/alemon/message/GUILD_UPDATE.d.ts +20 -0
  204. package/types/qq/alemon/message/INTERACTION_CREATE.d.ts +6 -0
  205. package/types/qq/alemon/message/MESSAGE_CREATE.d.ts +9 -0
  206. package/types/qq/alemon/message/MESSAGE_DELETE.d.ts +9 -0
  207. package/types/qq/alemon/message/MESSAGE_REACTION_ADD.d.ts +13 -0
  208. package/types/qq/alemon/message/MESSAGE_REACTION_REMOVE.d.ts +13 -0
  209. package/types/qq/alemon/message/PUBLIC_MESSAGE_DELETE.d.ts +19 -0
  210. package/types/qq/index.d.ts +2 -6
  211. package/types/qq/sdk/api.d.ts +325 -29
  212. package/types/qq/sdk/config.d.ts +3 -12
  213. package/types/qq/sdk/index.d.ts +1 -1
  214. package/types/qq/sdk/typings.d.ts +3 -3
  215. package/types/qq/sdk/wss.d.ts +63 -18
  216. package/types/villa/alemon/controller.d.ts +46 -172
  217. package/types/villa/alemon/reply.d.ts +3 -1
  218. package/types/villa/index.d.ts +1 -1
  219. package/types/villa/sdk/api.d.ts +427 -375
  220. package/types/villa/sdk/config.d.ts +4 -14
  221. package/types/villa/sdk/index.d.ts +1 -1
  222. package/types/villa/sdk/wss.d.ts +50 -20
  223. package/lib/api/controller.js +0 -40
  224. package/lib/core/application.js +0 -256
  225. package/lib/core/apps.js +0 -261
  226. package/lib/core/cache/app.js +0 -20
  227. package/lib/core/cache/arg.js +0 -13
  228. package/lib/core/cache/event.js +0 -13
  229. package/lib/core/cache/index.js +0 -6
  230. package/lib/core/cache/message.js +0 -13
  231. package/lib/core/cache/priority.js +0 -13
  232. package/lib/core/cache/slicing.js +0 -26
  233. package/lib/core/call.js +0 -33
  234. package/lib/core/configs.js +0 -36
  235. package/lib/core/conversation/index.js +0 -89
  236. package/lib/core/dealmsg.js +0 -222
  237. package/lib/core/help.js +0 -51
  238. package/lib/core/plugin/index.js +0 -151
  239. package/lib/core/utils/screenshot.js +0 -67
  240. package/lib/discord/discord.js +0 -30
  241. package/lib/discord/login.js +0 -20
  242. package/lib/discord/sdk/base.js +0 -30
  243. package/lib/discord/sdk/cdn.js +0 -38
  244. package/lib/kook/kook.js +0 -4
  245. package/lib/kook/login.js +0 -20
  246. package/lib/log/event.js +0 -20
  247. package/lib/log/user.js +0 -20
  248. package/lib/ntqq/alemon/group/bot.js +0 -11
  249. package/lib/ntqq/alemon/group/types.js +0 -1
  250. package/lib/ntqq/alemon/guild/controller.js +0 -1
  251. package/lib/ntqq/login.js +0 -19
  252. package/lib/ntqq/ntqq.js +0 -11
  253. package/lib/ntqq/sdk/api/auth.js +0 -15
  254. package/lib/ntqq/sdk/api/config.js +0 -3
  255. package/lib/ntqq/sdk/api/group.js +0 -124
  256. package/lib/ntqq/sdk/api/guild.js +0 -80
  257. package/lib/ntqq/sdk/api/index.js +0 -4
  258. package/lib/ntqq/sdk/counter.js +0 -15
  259. package/lib/qq/alemon/doc.js +0 -93
  260. package/lib/qq/alemon/message/AUDIO_ACTION.js +0 -108
  261. package/lib/qq/alemon/message/CHANNEL.js +0 -102
  262. package/lib/qq/alemon/message/DIRECT_MESSAGE.js +0 -87
  263. package/lib/qq/alemon/message/FORUMS_EVENT.js +0 -106
  264. package/lib/qq/alemon/message/GUILDS.js +0 -102
  265. package/lib/qq/alemon/message/GUILD_MEMBERS.js +0 -97
  266. package/lib/qq/alemon/message/GUILD_MESSAGE_REACTIONS.js +0 -101
  267. package/lib/qq/alemon/message/MESSAGE_AUDIT.js +0 -96
  268. package/lib/qq/alemon/message/OPEN_FORUMS_EVENT.js +0 -125
  269. package/lib/qq/alemon/message/PUBLIC_GUILD_MESSAGES.js +0 -153
  270. package/lib/qq/alemon/permissions.js +0 -41
  271. package/lib/qq/alemon/types.js +0 -21
  272. package/lib/qq/login.js +0 -18
  273. package/lib/qq/qq.js +0 -15
  274. package/lib/villa/login.js +0 -21
  275. package/lib/villa/sdk/all.js +0 -4
  276. package/lib/villa/sdk/counter.js +0 -9
  277. package/lib/villa/sdk/mechanism.js +0 -254
  278. package/lib/villa/sdk/reply.js +0 -62
  279. package/lib/villa/sdk/utils.js +0 -83
  280. package/lib/villa/villa.js +0 -7
  281. package/types/api/controller.d.ts +0 -32
  282. package/types/core/application.d.ts +0 -65
  283. package/types/core/apps.d.ts +0 -291
  284. package/types/core/cache/app.d.ts +0 -11
  285. package/types/core/cache/arg.d.ts +0 -10
  286. package/types/core/cache/event.d.ts +0 -10
  287. package/types/core/cache/index.d.ts +0 -6
  288. package/types/core/cache/message.d.ts +0 -10
  289. package/types/core/cache/priority.d.ts +0 -10
  290. package/types/core/cache/slicing.d.ts +0 -20
  291. package/types/core/call.d.ts +0 -70
  292. package/types/core/configs.d.ts +0 -82
  293. package/types/core/conversation/index.d.ts +0 -76
  294. package/types/core/dealmsg.d.ts +0 -14
  295. package/types/core/dev/types.d.ts +0 -37
  296. package/types/core/help.d.ts +0 -11
  297. package/types/core/plugin/index.d.ts +0 -95
  298. package/types/core/utils/screenshot.d.ts +0 -28
  299. package/types/discord/discord.d.ts +0 -28
  300. package/types/discord/login.d.ts +0 -7
  301. package/types/discord/sdk/base.d.ts +0 -14
  302. package/types/discord/sdk/cdn.d.ts +0 -16
  303. package/types/kook/kook.d.ts +0 -19
  304. package/types/kook/login.d.ts +0 -7
  305. package/types/log/event.d.ts +0 -15
  306. package/types/log/index.d.ts +0 -10
  307. package/types/log/user.d.ts +0 -15
  308. package/types/ntqq/alemon/group/bot.d.ts +0 -8
  309. package/types/ntqq/alemon/group/controller.d.ts +0 -77
  310. package/types/ntqq/alemon/group/direct.d.ts +0 -81
  311. package/types/ntqq/alemon/guild/controller.d.ts +0 -1
  312. package/types/ntqq/login.d.ts +0 -6
  313. package/types/ntqq/ntqq.d.ts +0 -55
  314. package/types/ntqq/sdk/api/auth.d.ts +0 -8
  315. package/types/ntqq/sdk/api/config.d.ts +0 -3
  316. package/types/ntqq/sdk/api/group.d.ts +0 -99
  317. package/types/ntqq/sdk/api/guild.d.ts +0 -35
  318. package/types/ntqq/sdk/api/index.d.ts +0 -4
  319. package/types/ntqq/sdk/counter.d.ts +0 -7
  320. package/types/qq/alemon/doc.d.ts +0 -93
  321. package/types/qq/alemon/message/AUDIO_ACTION.d.ts +0 -15
  322. package/types/qq/alemon/message/CHANNEL.d.ts +0 -36
  323. package/types/qq/alemon/message/DIRECT_MESSAGE.d.ts +0 -49
  324. package/types/qq/alemon/message/FORUMS_EVENT.d.ts +0 -38
  325. package/types/qq/alemon/message/GUILDS.d.ts +0 -39
  326. package/types/qq/alemon/message/GUILD_MEMBERS.d.ts +0 -26
  327. package/types/qq/alemon/message/GUILD_MESSAGES.d.ts +0 -12
  328. package/types/qq/alemon/message/GUILD_MESSAGE_REACTIONS.d.ts +0 -24
  329. package/types/qq/alemon/message/INTERACTION.d.ts +0 -8
  330. package/types/qq/alemon/message/MESSAGE_AUDIT.d.ts +0 -9
  331. package/types/qq/alemon/message/OPEN_FORUMS_EVENT.d.ts +0 -42
  332. package/types/qq/alemon/message/PUBLIC_GUILD_MESSAGES.d.ts +0 -51
  333. package/types/qq/alemon/permissions.d.ts +0 -29
  334. package/types/qq/alemon/types.d.ts +0 -20
  335. package/types/qq/login.d.ts +0 -6
  336. package/types/qq/qq.d.ts +0 -50
  337. package/types/villa/login.d.ts +0 -7
  338. package/types/villa/sdk/all.d.ts +0 -4
  339. package/types/villa/sdk/mechanism.d.ts +0 -11
  340. package/types/villa/sdk/reply.d.ts +0 -26
  341. package/types/villa/sdk/utils.d.ts +0 -11
  342. package/types/villa/villa.d.ts +0 -34
  343. package/lib/core/{dev → processor}/data.js +0 -0
  344. package/lib/core/{dev → processor}/path.js +12 -12
  345. package/lib/core/{dev → processor}/types.js +0 -0
  346. package/lib/{core/plugin → ntqq/alemon}/types.js +0 -0
  347. package/types/core/{dev → processor}/data.d.ts +0 -0
  348. package/types/core/{dev → processor}/path.d.ts +9 -9
  349. /package/types/ntqq/alemon/{group/message → message}/C2C_MESSAGE_CREATE.d.ts +0 -0
  350. /package/types/ntqq/alemon/{group/message → message}/GROUP_AT_MESSAGE_CREATE.d.ts +0 -0
  351. /package/types/ntqq/alemon/{group/segment.d.ts → segment.d.ts} +0 -0
  352. /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
- * Controller
13
+ * ************
14
+ * Controllers
15
+ * ************
29
16
  */
30
- export * from './controller.js';
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';
@@ -1,38 +1,38 @@
1
1
  import { DefaultConfig } from '../default/index.js';
2
- import { defineKOOK as kook } from '../kook/kook.js';
3
- import { defineVILLA as villa } from '../villa/villa.js';
4
- import { defineQQ as qq } from '../qq/qq.js';
5
- import { defineNtqq as ntqq } from '../ntqq/ntqq.js';
6
- import { defineDISCORD as discord } from '../discord/discord.js';
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 BotConfig {
9
- data = {
10
- ...DefaultConfig,
11
- kook,
12
- villa,
13
- qq,
14
- ntqq,
15
- puppeteer: Screenshot.launch,
16
- discord
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.data[key][item] = val[item];
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.data[key], item)) {
29
- this.data[key][item] = val[item];
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.data[key] = {};
35
- this.data[key] = val[item];
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.data[key];
51
+ return this.#data[key];
47
52
  }
48
53
  }
49
54
  /**
50
55
  * 机器人配置
51
56
  */
52
- export const BOTCONFIG = new BotConfig();
53
- /**
54
- * 设置机器人基础配置
55
- * @param key 配置名
56
- * @param val 配置值
57
- * @deprecated 已废弃
58
- */
59
- export const setBotConfigByKey = BOTCONFIG.set;
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 './plugin/index.js';
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 './apps.js';
7
- export * from './configs.js';
8
- export * from './help.js';
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
- const list = this.#list;
63
- for (let i = 0; i < list.getSize(); i++) {
64
- const node = list.shift();
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].e = e;
97
- const time = Date.now();
107
+ this.#data[node.acount][node.example]['e'] = e;
98
108
  // 执行
99
- const res = await this.#data[node.acount][node.example][node.func](e, ...arr)
109
+ this.#data[node.acount][node.example][node.func](e, ...arr)
100
110
  .then(res => {
101
- console.info(this.info(e, node.func, time - Date.now()));
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.err(e, node.func, time - Date.now()), err);
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 (let i = 0; i < list.getSize(); i++) {
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].e = e;
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
- console.info(this.info(e, node.func, time - Date.now()));
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.err(e, node.func, time - Date.now()), err);
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
- if (res && typeof res != 'boolean') {
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 list = this.#elist;
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 (let i = 0; i < list.getSize(); i++) {
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].e = e;
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
- console.info(this.info(e, node.func, time - Date.now()));
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.err(e, node.func, time - Date.now()), err);
281
+ console.error(this.#errorFunc(e, node.name, node.acount, node.example, node.func), false, Date.now() - time, err);
217
282
  });
218
- if (res && typeof res != 'boolean') {
219
- await e.reply(res).catch(err => {
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
- // 标记name和层级
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
- console.log('list', this.#list);
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
- err(e, funcName, time) {
372
- return `[${e.event}] [${false}] [${funcName}] [${time}ms]`;
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
- info(e, funcName, time) {
381
- return `[${e.event}] [${true}] [${funcName}] [${time}ms]`;
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
- console.info(this.info(e, FuncName, time - Date.now()));
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.err(e, FuncName, time - Date.now()), err);
542
+ console.error(this.#infoFunc(e, this.#name, 0, 'on', FuncName), false, Date.now() - time, err);
409
543
  });
410
544
  }
411
545
  return false;