trompot 1.0.0

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 (357) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +560 -0
  3. package/lib/bot/BotBase.d.ts +82 -0
  4. package/lib/bot/BotBase.js +144 -0
  5. package/lib/bot/BotBase.js.map +1 -0
  6. package/lib/bot/BotEvents.d.ts +87 -0
  7. package/lib/bot/BotEvents.js +51 -0
  8. package/lib/bot/BotEvents.js.map +1 -0
  9. package/lib/bot/BotServer.d.ts +34 -0
  10. package/lib/bot/BotServer.js +118 -0
  11. package/lib/bot/BotServer.js.map +1 -0
  12. package/lib/bot/BotStatus.d.ts +4 -0
  13. package/lib/bot/BotStatus.js +9 -0
  14. package/lib/bot/BotStatus.js.map +1 -0
  15. package/lib/bot/IBot.d.ts +292 -0
  16. package/lib/bot/IBot.js +3 -0
  17. package/lib/bot/IBot.js.map +1 -0
  18. package/lib/bot/index.d.ts +5 -0
  19. package/lib/bot/index.js +13 -0
  20. package/lib/bot/index.js.map +1 -0
  21. package/lib/client/Client.d.ts +120 -0
  22. package/lib/client/Client.js +687 -0
  23. package/lib/client/Client.js.map +1 -0
  24. package/lib/client/ClientEvents.d.ts +147 -0
  25. package/lib/client/ClientEvents.js +93 -0
  26. package/lib/client/ClientEvents.js.map +1 -0
  27. package/lib/client/ClientFunctionHandler.d.ts +15 -0
  28. package/lib/client/ClientFunctionHandler.js +70 -0
  29. package/lib/client/ClientFunctionHandler.js.map +1 -0
  30. package/lib/client/ConnectionType.d.ts +4 -0
  31. package/lib/client/ConnectionType.js +3 -0
  32. package/lib/client/ConnectionType.js.map +1 -0
  33. package/lib/client/IAuth.d.ts +9 -0
  34. package/lib/client/IAuth.js +3 -0
  35. package/lib/client/IAuth.js.map +1 -0
  36. package/lib/client/IClient.d.ts +358 -0
  37. package/lib/client/IClient.js +3 -0
  38. package/lib/client/IClient.js.map +1 -0
  39. package/lib/client/index.d.ts +7 -0
  40. package/lib/client/index.js +13 -0
  41. package/lib/client/index.js.map +1 -0
  42. package/lib/cluster/ClientCluster.d.ts +428 -0
  43. package/lib/cluster/ClientCluster.js +1746 -0
  44. package/lib/cluster/ClientCluster.js.map +1 -0
  45. package/lib/cluster/WorkerMessage.d.ts +99 -0
  46. package/lib/cluster/WorkerMessage.js +84 -0
  47. package/lib/cluster/WorkerMessage.js.map +1 -0
  48. package/lib/cluster/index.d.ts +5 -0
  49. package/lib/cluster/index.js +27 -0
  50. package/lib/cluster/index.js.map +1 -0
  51. package/lib/configs/ConnectionConfig.d.ts +22 -0
  52. package/lib/configs/ConnectionConfig.js +3 -0
  53. package/lib/configs/ConnectionConfig.js.map +1 -0
  54. package/lib/configs/Defaults.d.ts +2 -0
  55. package/lib/configs/Defaults.js +16 -0
  56. package/lib/configs/Defaults.js.map +1 -0
  57. package/lib/configs/WAConfigs.d.ts +1 -0
  58. package/lib/configs/WAConfigs.js +5 -0
  59. package/lib/configs/WAConfigs.js.map +1 -0
  60. package/lib/configs/index.d.ts +3 -0
  61. package/lib/configs/index.js +18 -0
  62. package/lib/configs/index.js.map +1 -0
  63. package/lib/errors/ChatNotDefinedError.d.ts +4 -0
  64. package/lib/errors/ChatNotDefinedError.js +9 -0
  65. package/lib/errors/ChatNotDefinedError.js.map +1 -0
  66. package/lib/errors/ClientNotDefinedError.d.ts +4 -0
  67. package/lib/errors/ClientNotDefinedError.js +9 -0
  68. package/lib/errors/ClientNotDefinedError.js.map +1 -0
  69. package/lib/errors/UserNotDefinedError.d.ts +4 -0
  70. package/lib/errors/UserNotDefinedError.js +9 -0
  71. package/lib/errors/UserNotDefinedError.js.map +1 -0
  72. package/lib/index.d.ts +17 -0
  73. package/lib/index.js +60 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/messages/AudioMessage.d.ts +42 -0
  76. package/lib/messages/AudioMessage.js +66 -0
  77. package/lib/messages/AudioMessage.js.map +1 -0
  78. package/lib/messages/ButtonMessage.d.ts +88 -0
  79. package/lib/messages/ButtonMessage.js +137 -0
  80. package/lib/messages/ButtonMessage.js.map +1 -0
  81. package/lib/messages/ContactMessage.d.ts +37 -0
  82. package/lib/messages/ContactMessage.js +93 -0
  83. package/lib/messages/ContactMessage.js.map +1 -0
  84. package/lib/messages/CustomMessage.d.ts +35 -0
  85. package/lib/messages/CustomMessage.js +88 -0
  86. package/lib/messages/CustomMessage.js.map +1 -0
  87. package/lib/messages/EmptyMessage.d.ts +25 -0
  88. package/lib/messages/EmptyMessage.js +78 -0
  89. package/lib/messages/EmptyMessage.js.map +1 -0
  90. package/lib/messages/ErrorMessage.d.ts +35 -0
  91. package/lib/messages/ErrorMessage.js +86 -0
  92. package/lib/messages/ErrorMessage.js.map +1 -0
  93. package/lib/messages/FileMessage.d.ts +36 -0
  94. package/lib/messages/FileMessage.js +60 -0
  95. package/lib/messages/FileMessage.js.map +1 -0
  96. package/lib/messages/ImageMessage.d.ts +41 -0
  97. package/lib/messages/ImageMessage.js +65 -0
  98. package/lib/messages/ImageMessage.js.map +1 -0
  99. package/lib/messages/ListMessage.d.ts +91 -0
  100. package/lib/messages/ListMessage.js +126 -0
  101. package/lib/messages/ListMessage.js.map +1 -0
  102. package/lib/messages/LocationMessage.d.ts +48 -0
  103. package/lib/messages/LocationMessage.js +107 -0
  104. package/lib/messages/LocationMessage.js.map +1 -0
  105. package/lib/messages/MediaMessage.d.ts +54 -0
  106. package/lib/messages/MediaMessage.js +113 -0
  107. package/lib/messages/MediaMessage.js.map +1 -0
  108. package/lib/messages/Message.d.ts +144 -0
  109. package/lib/messages/Message.js +223 -0
  110. package/lib/messages/Message.js.map +1 -0
  111. package/lib/messages/PollMessage.d.ts +87 -0
  112. package/lib/messages/PollMessage.js +145 -0
  113. package/lib/messages/PollMessage.js.map +1 -0
  114. package/lib/messages/PollUpdateMessage.d.ts +40 -0
  115. package/lib/messages/PollUpdateMessage.js +98 -0
  116. package/lib/messages/PollUpdateMessage.js.map +1 -0
  117. package/lib/messages/ReactionMessage.d.ts +36 -0
  118. package/lib/messages/ReactionMessage.js +91 -0
  119. package/lib/messages/ReactionMessage.js.map +1 -0
  120. package/lib/messages/StickerMessage.d.ts +49 -0
  121. package/lib/messages/StickerMessage.js +73 -0
  122. package/lib/messages/StickerMessage.js.map +1 -0
  123. package/lib/messages/TextMessage.d.ts +33 -0
  124. package/lib/messages/TextMessage.js +84 -0
  125. package/lib/messages/TextMessage.js.map +1 -0
  126. package/lib/messages/VideoMessage.d.ts +42 -0
  127. package/lib/messages/VideoMessage.js +66 -0
  128. package/lib/messages/VideoMessage.js.map +1 -0
  129. package/lib/messages/index.d.ts +19 -0
  130. package/lib/messages/index.js +81 -0
  131. package/lib/messages/index.js.map +1 -0
  132. package/lib/models/Address.d.ts +11 -0
  133. package/lib/models/Address.js +18 -0
  134. package/lib/models/Address.js.map +1 -0
  135. package/lib/models/Call.d.ts +68 -0
  136. package/lib/models/Call.js +127 -0
  137. package/lib/models/Call.js.map +1 -0
  138. package/lib/modules/chat/Chat.d.ts +142 -0
  139. package/lib/modules/chat/Chat.js +246 -0
  140. package/lib/modules/chat/Chat.js.map +1 -0
  141. package/lib/modules/chat/ChatAction.d.ts +3 -0
  142. package/lib/modules/chat/ChatAction.js +3 -0
  143. package/lib/modules/chat/ChatAction.js.map +1 -0
  144. package/lib/modules/chat/ChatStatus.d.ts +9 -0
  145. package/lib/modules/chat/ChatStatus.js +13 -0
  146. package/lib/modules/chat/ChatStatus.js.map +1 -0
  147. package/lib/modules/chat/ChatType.d.ts +7 -0
  148. package/lib/modules/chat/ChatType.js +11 -0
  149. package/lib/modules/chat/ChatType.js.map +1 -0
  150. package/lib/modules/chat/index.d.ts +5 -0
  151. package/lib/modules/chat/index.js +13 -0
  152. package/lib/modules/chat/index.js.map +1 -0
  153. package/lib/modules/command/Command.d.ts +67 -0
  154. package/lib/modules/command/Command.js +139 -0
  155. package/lib/modules/command/Command.js.map +1 -0
  156. package/lib/modules/command/CommandController.d.ts +50 -0
  157. package/lib/modules/command/CommandController.js +119 -0
  158. package/lib/modules/command/CommandController.js.map +1 -0
  159. package/lib/modules/command/CommandControllerEvent.d.ts +9 -0
  160. package/lib/modules/command/CommandControllerEvent.js +25 -0
  161. package/lib/modules/command/CommandControllerEvent.js.map +1 -0
  162. package/lib/modules/command/CommandEnums.d.ts +14 -0
  163. package/lib/modules/command/CommandEnums.js +20 -0
  164. package/lib/modules/command/CommandEnums.js.map +1 -0
  165. package/lib/modules/command/CommandKey.d.ts +17 -0
  166. package/lib/modules/command/CommandKey.js +67 -0
  167. package/lib/modules/command/CommandKey.js.map +1 -0
  168. package/lib/modules/command/CommandPermission.d.ts +9 -0
  169. package/lib/modules/command/CommandPermission.js +35 -0
  170. package/lib/modules/command/CommandPermission.js.map +1 -0
  171. package/lib/modules/command/ICommandControllerConfig.d.ts +7 -0
  172. package/lib/modules/command/ICommandControllerConfig.js +3 -0
  173. package/lib/modules/command/ICommandControllerConfig.js.map +1 -0
  174. package/lib/modules/command/advanced/AdvancedCommand.d.ts +23 -0
  175. package/lib/modules/command/advanced/AdvancedCommand.js +131 -0
  176. package/lib/modules/command/advanced/AdvancedCommand.js.map +1 -0
  177. package/lib/modules/command/advanced/AdvancedCommandContext.d.ts +10 -0
  178. package/lib/modules/command/advanced/AdvancedCommandContext.js +3 -0
  179. package/lib/modules/command/advanced/AdvancedCommandContext.js.map +1 -0
  180. package/lib/modules/command/advanced/AdvancedCommandController.d.ts +29 -0
  181. package/lib/modules/command/advanced/AdvancedCommandController.js +118 -0
  182. package/lib/modules/command/advanced/AdvancedCommandController.js.map +1 -0
  183. package/lib/modules/command/advanced/AdvancedCommandData.d.ts +6 -0
  184. package/lib/modules/command/advanced/AdvancedCommandData.js +3 -0
  185. package/lib/modules/command/advanced/AdvancedCommandData.js.map +1 -0
  186. package/lib/modules/command/advanced/AdvancedCommandJob.d.ts +12 -0
  187. package/lib/modules/command/advanced/AdvancedCommandJob.js +3 -0
  188. package/lib/modules/command/advanced/AdvancedCommandJob.js.map +1 -0
  189. package/lib/modules/command/advanced/AdvancedCommandNext.d.ts +4 -0
  190. package/lib/modules/command/advanced/AdvancedCommandNext.js +3 -0
  191. package/lib/modules/command/advanced/AdvancedCommandNext.js.map +1 -0
  192. package/lib/modules/command/advanced/AdvancedCommandOptions.d.ts +8 -0
  193. package/lib/modules/command/advanced/AdvancedCommandOptions.js +3 -0
  194. package/lib/modules/command/advanced/AdvancedCommandOptions.js.map +1 -0
  195. package/lib/modules/command/advanced/AdvancedCommandStart.d.ts +11 -0
  196. package/lib/modules/command/advanced/AdvancedCommandStart.js +3 -0
  197. package/lib/modules/command/advanced/AdvancedCommandStart.js.map +1 -0
  198. package/lib/modules/command/advanced/AdvancedCommandStop.d.ts +3 -0
  199. package/lib/modules/command/advanced/AdvancedCommandStop.js +3 -0
  200. package/lib/modules/command/advanced/AdvancedCommandStop.js.map +1 -0
  201. package/lib/modules/command/advanced/AdvancedCommandTask.d.ts +2 -0
  202. package/lib/modules/command/advanced/AdvancedCommandTask.js +3 -0
  203. package/lib/modules/command/advanced/AdvancedCommandTask.js.map +1 -0
  204. package/lib/modules/command/defaults.d.ts +2 -0
  205. package/lib/modules/command/defaults.js +8 -0
  206. package/lib/modules/command/defaults.js.map +1 -0
  207. package/lib/modules/command/index.d.ts +12 -0
  208. package/lib/modules/command/index.js +36 -0
  209. package/lib/modules/command/index.js.map +1 -0
  210. package/lib/modules/command/keys.d.ts +9 -0
  211. package/lib/modules/command/keys.js +27 -0
  212. package/lib/modules/command/keys.js.map +1 -0
  213. package/lib/modules/command/perms.d.ts +2 -0
  214. package/lib/modules/command/perms.js +11 -0
  215. package/lib/modules/command/perms.js.map +1 -0
  216. package/lib/modules/quickResponse/QuickResponse.d.ts +49 -0
  217. package/lib/modules/quickResponse/QuickResponse.js +64 -0
  218. package/lib/modules/quickResponse/QuickResponse.js.map +1 -0
  219. package/lib/modules/quickResponse/QuickResponseController.d.ts +55 -0
  220. package/lib/modules/quickResponse/QuickResponseController.js +125 -0
  221. package/lib/modules/quickResponse/QuickResponseController.js.map +1 -0
  222. package/lib/modules/quickResponse/QuickResponseOptions.d.ts +56 -0
  223. package/lib/modules/quickResponse/QuickResponseOptions.js +76 -0
  224. package/lib/modules/quickResponse/QuickResponseOptions.js.map +1 -0
  225. package/lib/modules/quickResponse/QuickResponsePattern.d.ts +28 -0
  226. package/lib/modules/quickResponse/QuickResponsePattern.js +3 -0
  227. package/lib/modules/quickResponse/QuickResponsePattern.js.map +1 -0
  228. package/lib/modules/quickResponse/QuickResponseReply.d.ts +6 -0
  229. package/lib/modules/quickResponse/QuickResponseReply.js +3 -0
  230. package/lib/modules/quickResponse/QuickResponseReply.js.map +1 -0
  231. package/lib/modules/quickResponse/index.d.ts +6 -0
  232. package/lib/modules/quickResponse/index.js +13 -0
  233. package/lib/modules/quickResponse/index.js.map +1 -0
  234. package/lib/modules/user/User.d.ts +91 -0
  235. package/lib/modules/user/User.js +173 -0
  236. package/lib/modules/user/User.js.map +1 -0
  237. package/lib/modules/user/UserAction.d.ts +4 -0
  238. package/lib/modules/user/UserAction.js +3 -0
  239. package/lib/modules/user/UserAction.js.map +1 -0
  240. package/lib/modules/user/UserEvent.d.ts +3 -0
  241. package/lib/modules/user/UserEvent.js +3 -0
  242. package/lib/modules/user/UserEvent.js.map +1 -0
  243. package/lib/modules/user/index.d.ts +4 -0
  244. package/lib/modules/user/index.js +9 -0
  245. package/lib/modules/user/index.js.map +1 -0
  246. package/lib/routes/botServer/api/v1/emitEvent.d.ts +3 -0
  247. package/lib/routes/botServer/api/v1/emitEvent.js +17 -0
  248. package/lib/routes/botServer/api/v1/emitEvent.js.map +1 -0
  249. package/lib/routes/botServer/api/v1/function.d.ts +3 -0
  250. package/lib/routes/botServer/api/v1/function.js +22 -0
  251. package/lib/routes/botServer/api/v1/function.js.map +1 -0
  252. package/lib/routes/botServer/api/v1/ping.d.ts +3 -0
  253. package/lib/routes/botServer/api/v1/ping.js +12 -0
  254. package/lib/routes/botServer/api/v1/ping.js.map +1 -0
  255. package/lib/routes/botServer/api/v1/register.d.ts +3 -0
  256. package/lib/routes/botServer/api/v1/register.js +23 -0
  257. package/lib/routes/botServer/api/v1/register.js.map +1 -0
  258. package/lib/routes/botServer/api/v1/setValue.d.ts +3 -0
  259. package/lib/routes/botServer/api/v1/setValue.js +18 -0
  260. package/lib/routes/botServer/api/v1/setValue.js.map +1 -0
  261. package/lib/routes/botServer/api/v1/unregister.d.ts +3 -0
  262. package/lib/routes/botServer/api/v1/unregister.js +22 -0
  263. package/lib/routes/botServer/api/v1/unregister.js.map +1 -0
  264. package/lib/routes/botServer/middlewares/setBotServer.d.ts +4 -0
  265. package/lib/routes/botServer/middlewares/setBotServer.js +16 -0
  266. package/lib/routes/botServer/middlewares/setBotServer.js.map +1 -0
  267. package/lib/routes/botServer/routes.d.ts +8 -0
  268. package/lib/routes/botServer/routes.js +33 -0
  269. package/lib/routes/botServer/routes.js.map +1 -0
  270. package/lib/services/AddressService.d.ts +12 -0
  271. package/lib/services/AddressService.js +51 -0
  272. package/lib/services/AddressService.js.map +1 -0
  273. package/lib/services/BaseService.d.ts +5 -0
  274. package/lib/services/BaseService.js +19 -0
  275. package/lib/services/BaseService.js.map +1 -0
  276. package/lib/services/index.d.ts +3 -0
  277. package/lib/services/index.js +11 -0
  278. package/lib/services/index.js.map +1 -0
  279. package/lib/telegram/TelegramAuth.d.ts +17 -0
  280. package/lib/telegram/TelegramAuth.js +96 -0
  281. package/lib/telegram/TelegramAuth.js.map +1 -0
  282. package/lib/telegram/TelegramBot.d.ts +88 -0
  283. package/lib/telegram/TelegramBot.js +345 -0
  284. package/lib/telegram/TelegramBot.js.map +1 -0
  285. package/lib/telegram/TelegramEvents.d.ts +13 -0
  286. package/lib/telegram/TelegramEvents.js +131 -0
  287. package/lib/telegram/TelegramEvents.js.map +1 -0
  288. package/lib/telegram/TelegramSendingController.d.ts +36 -0
  289. package/lib/telegram/TelegramSendingController.js +213 -0
  290. package/lib/telegram/TelegramSendingController.js.map +1 -0
  291. package/lib/telegram/TelegramToRompotConverter.d.ts +22 -0
  292. package/lib/telegram/TelegramToRompotConverter.js +226 -0
  293. package/lib/telegram/TelegramToRompotConverter.js.map +1 -0
  294. package/lib/telegram/TelegramUtils.d.ts +14 -0
  295. package/lib/telegram/TelegramUtils.js +98 -0
  296. package/lib/telegram/TelegramUtils.js.map +1 -0
  297. package/lib/telegram/index.d.ts +7 -0
  298. package/lib/telegram/index.js +19 -0
  299. package/lib/telegram/index.js.map +1 -0
  300. package/lib/utils/ClientUtils.d.ts +27 -0
  301. package/lib/utils/ClientUtils.js +62 -0
  302. package/lib/utils/ClientUtils.js.map +1 -0
  303. package/lib/utils/Generic.d.ts +47 -0
  304. package/lib/utils/Generic.js +173 -0
  305. package/lib/utils/Generic.js.map +1 -0
  306. package/lib/utils/Libs.d.ts +10 -0
  307. package/lib/utils/Libs.js +55 -0
  308. package/lib/utils/Libs.js.map +1 -0
  309. package/lib/utils/MessageHandler.d.ts +54 -0
  310. package/lib/utils/MessageHandler.js +81 -0
  311. package/lib/utils/MessageHandler.js.map +1 -0
  312. package/lib/utils/MessageUtils.d.ts +3 -0
  313. package/lib/utils/MessageUtils.js +114 -0
  314. package/lib/utils/MessageUtils.js.map +1 -0
  315. package/lib/utils/index.d.ts +6 -0
  316. package/lib/utils/index.js +27 -0
  317. package/lib/utils/index.js.map +1 -0
  318. package/lib/utils/nonce.d.ts +1 -0
  319. package/lib/utils/nonce.js +16 -0
  320. package/lib/utils/nonce.js.map +1 -0
  321. package/lib/utils/server.d.ts +33 -0
  322. package/lib/utils/server.js +75 -0
  323. package/lib/utils/server.js.map +1 -0
  324. package/lib/wa/Auth.d.ts +19 -0
  325. package/lib/wa/Auth.js +123 -0
  326. package/lib/wa/Auth.js.map +1 -0
  327. package/lib/wa/ConfigWAEvents.d.ts +22 -0
  328. package/lib/wa/ConfigWAEvents.js +526 -0
  329. package/lib/wa/ConfigWAEvents.js.map +1 -0
  330. package/lib/wa/ConvertToWAMessage.d.ts +67 -0
  331. package/lib/wa/ConvertToWAMessage.js +403 -0
  332. package/lib/wa/ConvertToWAMessage.js.map +1 -0
  333. package/lib/wa/ConvertWAMessage.d.ts +108 -0
  334. package/lib/wa/ConvertWAMessage.js +527 -0
  335. package/lib/wa/ConvertWAMessage.js.map +1 -0
  336. package/lib/wa/ID.d.ts +4 -0
  337. package/lib/wa/ID.js +19 -0
  338. package/lib/wa/ID.js.map +1 -0
  339. package/lib/wa/WAMessage.d.ts +3 -0
  340. package/lib/wa/WAMessage.js +8 -0
  341. package/lib/wa/WAMessage.js.map +1 -0
  342. package/lib/wa/WAModule.d.ts +3 -0
  343. package/lib/wa/WAModule.js +3 -0
  344. package/lib/wa/WAModule.js.map +1 -0
  345. package/lib/wa/WAStatus.d.ts +3 -0
  346. package/lib/wa/WAStatus.js +15 -0
  347. package/lib/wa/WAStatus.js.map +1 -0
  348. package/lib/wa/WhatsAppBot.d.ts +188 -0
  349. package/lib/wa/WhatsAppBot.js +980 -0
  350. package/lib/wa/WhatsAppBot.js.map +1 -0
  351. package/lib/wa/index.d.ts +12 -0
  352. package/lib/wa/index.js +37 -0
  353. package/lib/wa/index.js.map +1 -0
  354. package/lib/wa/makeInMemoryStore.d.ts +43 -0
  355. package/lib/wa/makeInMemoryStore.js +430 -0
  356. package/lib/wa/makeInMemoryStore.js.map +1 -0
  357. package/package.json +79 -0
@@ -0,0 +1,23 @@
1
+ import type { AdvancedCommandNextOptions } from './AdvancedCommandNext';
2
+ import type { AdvancedCommandStopOptions } from './AdvancedCommandStop';
3
+ import type { PartialAdvancedCommandStartOptions } from './AdvancedCommandStart';
4
+ import type { AdvancedCommandData } from './AdvancedCommandData';
5
+ import type { AdvancedCommandTask } from './AdvancedCommandTask';
6
+ import type { AdvancedCommandOptions } from './AdvancedCommandOptions';
7
+ import type { AdvancedCommandContext } from './AdvancedCommandContext';
8
+ import type AdvancedCommandController from './AdvancedCommandController';
9
+ export default class AdvancedCommand<T extends object = object> {
10
+ id: string;
11
+ clientId: string;
12
+ controller: AdvancedCommandController;
13
+ initialContext: AdvancedCommandContext<T>;
14
+ tasks: Record<string, AdvancedCommandTask<T>>;
15
+ options: Partial<AdvancedCommandOptions>;
16
+ constructor(data: AdvancedCommandData<T>);
17
+ injectContext(data: Partial<AdvancedCommandData<T>>): void;
18
+ saveContext(nowContext: AdvancedCommandContext<T>, data?: T): Promise<void>;
19
+ addTask(id: string, task: AdvancedCommandTask<T>): void;
20
+ start(options: PartialAdvancedCommandStartOptions<T>): Promise<void>;
21
+ next(nowContext: AdvancedCommandContext<T>, options?: Partial<AdvancedCommandNextOptions<T>>): Promise<void>;
22
+ stop(nowContext: AdvancedCommandContext<T>, options?: Partial<AdvancedCommandStopOptions>): Promise<void>;
23
+ }
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const MessageUtils_1 = require("../../../utils/MessageUtils");
7
+ const nonce_1 = __importDefault(require("../../../utils/nonce"));
8
+ class AdvancedCommand {
9
+ constructor(data) {
10
+ this.id = (0, nonce_1.default)();
11
+ this.initialContext = {};
12
+ this.tasks = {};
13
+ this.options = {};
14
+ if (data === null || data === void 0 ? void 0 : data.context) {
15
+ Object.assign(this.initialContext, data.context);
16
+ }
17
+ this.injectContext(data);
18
+ }
19
+ injectContext(data) {
20
+ if (!data || typeof data !== 'object') {
21
+ throw new Error('Data must be an object');
22
+ }
23
+ if (data.controller) {
24
+ this.controller = data.controller;
25
+ }
26
+ if (data.options) {
27
+ this.options = { ...this.options, ...data.options };
28
+ }
29
+ if (data.initialContext) {
30
+ this.initialContext = { ...this.initialContext, ...data.initialContext };
31
+ }
32
+ if (data.tasks) {
33
+ this.tasks = { ...this.tasks, ...data.tasks };
34
+ }
35
+ if (data.id) {
36
+ this.id = data.id;
37
+ }
38
+ this.clientId = this.controller.clientId;
39
+ this.initialContext.clientId = this.clientId;
40
+ this.initialContext.commandId = this.id;
41
+ if (this.initialContext.message) {
42
+ this.initialContext.message = (0, MessageUtils_1.getMessageFromJSON)(this.initialContext.message);
43
+ this.initialContext.message.clientId = this.clientId;
44
+ }
45
+ }
46
+ async saveContext(nowContext, data) {
47
+ const context = { ...nowContext, ...data };
48
+ await this.controller.saveContext(this, context);
49
+ }
50
+ addTask(id, task) {
51
+ this.tasks[id] = task;
52
+ }
53
+ async start(options) {
54
+ var _a;
55
+ const taskId = options.taskId ||
56
+ ((_a = options.context) === null || _a === void 0 ? void 0 : _a.taskId) ||
57
+ Object.keys(this.tasks).shift() ||
58
+ '';
59
+ const context = (await this.controller.getContext(this, options.chatId)) ||
60
+ this.initialContext;
61
+ if (options.context && typeof options.context === 'object') {
62
+ Object.assign(context, options.context);
63
+ }
64
+ if (taskId) {
65
+ context.taskId = taskId;
66
+ }
67
+ context.isRun = true;
68
+ context.commandId = this.id;
69
+ context.chatId = options.chatId;
70
+ context.clientId = this.clientId;
71
+ const task = this.tasks[taskId];
72
+ if (!task) {
73
+ throw new Error('Task not found');
74
+ }
75
+ await this.saveContext(context);
76
+ const saveTaskContext = async (data) => {
77
+ await this.saveContext(context, data);
78
+ };
79
+ const nextTask = async (options) => {
80
+ if ((options === null || options === void 0 ? void 0 : options.context) && typeof options.context === 'object') {
81
+ Object.assign(context, options.context);
82
+ }
83
+ if (options === null || options === void 0 ? void 0 : options.taskId) {
84
+ context.taskId = options.taskId;
85
+ }
86
+ await this.next(context, options);
87
+ };
88
+ const stopTask = async (options) => {
89
+ await this.stop(context, options);
90
+ };
91
+ const job = {
92
+ context,
93
+ saveTaskContext,
94
+ nextTask,
95
+ stopTask,
96
+ };
97
+ task(job);
98
+ }
99
+ async next(nowContext, options) {
100
+ let taskId = options === null || options === void 0 ? void 0 : options.taskId;
101
+ if (!taskId) {
102
+ const nowTaskIndex = Object.keys(this.tasks).findIndex((t) => t === nowContext.taskId);
103
+ if (nowTaskIndex === -1) {
104
+ throw new Error('Task not found');
105
+ }
106
+ const newTaskId = Object.keys(this.tasks)[nowTaskIndex + 1];
107
+ // Stop command, no many tasks
108
+ if (!newTaskId)
109
+ return;
110
+ taskId = newTaskId;
111
+ }
112
+ const context = { ...nowContext };
113
+ if ((options === null || options === void 0 ? void 0 : options.context) && typeof options.context === 'object') {
114
+ Object.assign(context, options.context);
115
+ }
116
+ const chatId = context.chatId;
117
+ const startOptions = {
118
+ chatId,
119
+ taskId,
120
+ context,
121
+ };
122
+ await this.controller.execCommand(this.id, nowContext.message, startOptions);
123
+ }
124
+ async stop(nowContext, options) {
125
+ if ((options === null || options === void 0 ? void 0 : options.noRemove) === true)
126
+ return;
127
+ await this.controller.clearContext(this, nowContext.chatId);
128
+ }
129
+ }
130
+ exports.default = AdvancedCommand;
131
+ //# sourceMappingURL=AdvancedCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommand.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommand.ts"],"names":[],"mappings":";;;;;AAmBA,8DAAiE;AACjE,iEAAyC;AAEzC,MAAqB,eAAe;IAQlC,YAAY,IAA4B;QACtC,IAAI,CAAC,EAAE,GAAG,IAAA,eAAK,GAAE,CAAC;QAClB,IAAI,CAAC,cAAc,GAAG,EAA+B,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEM,aAAa,CAAC,IAAqC;QACxD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAA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ientId: string;
4
+ commandId: string;
5
+ taskId: string;
6
+ isRun: boolean;
7
+ attemptsMade: number;
8
+ message: Message;
9
+ chatId: string;
10
+ } & D;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandContext.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { AdvancedCommandData } from './AdvancedCommandData';
2
+ import type { AdvancedCommandContext } from './AdvancedCommandContext';
3
+ import type { AdvancedCommandStartOptions } from './AdvancedCommandStart';
4
+ import type { Message } from '../../../messages';
5
+ import NodeCache from 'node-cache';
6
+ import AdvancedCommand from './AdvancedCommand';
7
+ export default class AdvancedCommandController {
8
+ clientId: string;
9
+ cache: NodeCache;
10
+ commands: Record<string, AdvancedCommand>;
11
+ constructor(clientId: string);
12
+ prepareCommand<T extends object>(command: AdvancedCommand<T>): AdvancedCommand<T>;
13
+ createCommand<T extends object>(commandData: Partial<AdvancedCommandData<T>> & {
14
+ context: T;
15
+ }): AdvancedCommand<T>;
16
+ setCommands(...commands: AdvancedCommand[]): void;
17
+ addCommand<T extends object = object>(command: AdvancedCommand<T>): void;
18
+ addCommands(...commands: AdvancedCommand[]): void;
19
+ removeCommand(command: AdvancedCommand | string): boolean;
20
+ removeCommands(...commands: AdvancedCommand[]): void;
21
+ getCommand<T extends object = object>(id: string): AdvancedCommand<T> | undefined;
22
+ getCommands(): AdvancedCommand[];
23
+ hasCommand(id: string): boolean;
24
+ execCommand<T extends object = object>(commandId: string, message: Message, options?: Partial<AdvancedCommandStartOptions<T>>): Promise<void>;
25
+ saveContext<T extends object>(command: AdvancedCommand<T>, context: AdvancedCommandContext<T>): Promise<void> | void;
26
+ clearContext<T extends object>(command: AdvancedCommand<T>, chatId: string): Promise<void> | void;
27
+ getContext<T extends object>(command: AdvancedCommand, chatId: string): Promise<AdvancedCommandContext<T> | undefined> | (AdvancedCommandContext<T> | undefined);
28
+ getCacheKey(commandId: string, chatId: string): string;
29
+ }
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_cache_1 = __importDefault(require("node-cache"));
7
+ const AdvancedCommand_1 = __importDefault(require("./AdvancedCommand"));
8
+ class AdvancedCommandController {
9
+ constructor(clientId) {
10
+ this.commands = {};
11
+ this.clientId = clientId;
12
+ this.cache = new node_cache_1.default({
13
+ useClones: false,
14
+ stdTTL: 3600,
15
+ checkperiod: 3600,
16
+ });
17
+ }
18
+ prepareCommand(command) {
19
+ command.clientId = this.clientId;
20
+ command.controller = this;
21
+ command.initialContext.commandId = command.id;
22
+ if (command.initialContext.message) {
23
+ command.initialContext.message.clientId = this.clientId;
24
+ }
25
+ return command;
26
+ }
27
+ createCommand(commandData) {
28
+ const command = new AdvancedCommand_1.default({
29
+ ...commandData,
30
+ controller: this,
31
+ });
32
+ this.addCommand(command);
33
+ return command;
34
+ }
35
+ setCommands(...commands) {
36
+ this.commands = {};
37
+ for (const command of commands) {
38
+ this.addCommand(command);
39
+ }
40
+ }
41
+ addCommand(command) {
42
+ if (!command)
43
+ throw new Error('Command is required');
44
+ if (!command.id)
45
+ throw new Error('Command id is required');
46
+ this.commands[command.id] = this.prepareCommand(command);
47
+ }
48
+ addCommands(...commands) {
49
+ for (const command of commands) {
50
+ this.addCommand(command);
51
+ }
52
+ }
53
+ removeCommand(command) {
54
+ const id = typeof command === 'string' ? command : command === null || command === void 0 ? void 0 : command.id;
55
+ if (!id)
56
+ throw new Error('Command id is required');
57
+ if (!this.commands[id])
58
+ return false;
59
+ delete this.commands[id];
60
+ return true;
61
+ }
62
+ removeCommands(...commands) {
63
+ for (const command of commands) {
64
+ this.removeCommand(command);
65
+ }
66
+ }
67
+ getCommand(id) {
68
+ if (!this.commands[id])
69
+ return undefined;
70
+ return this.prepareCommand(this.commands[id]);
71
+ }
72
+ getCommands() {
73
+ return Object.values(this.commands);
74
+ }
75
+ hasCommand(id) {
76
+ return !!this.commands[id];
77
+ }
78
+ async execCommand(commandId, message, options = {}) {
79
+ const command = this.getCommand(commandId);
80
+ if (!command)
81
+ throw new Error('Command not found');
82
+ const chatId = message.chat.id;
83
+ const data = await this.getContext(command, chatId);
84
+ const startOptions = {
85
+ chatId,
86
+ context: { ...command.initialContext, chatId },
87
+ taskId: command.initialContext.taskId ||
88
+ Object.keys(command.tasks).shift() ||
89
+ '',
90
+ };
91
+ if (data) {
92
+ Object.assign(startOptions.context, data);
93
+ }
94
+ if (options.context) {
95
+ Object.assign(startOptions.context, options.context);
96
+ }
97
+ startOptions.context.message = message;
98
+ if (options.taskId) {
99
+ startOptions.taskId = options.taskId;
100
+ startOptions.context.taskId = options.taskId;
101
+ }
102
+ await command.start(startOptions);
103
+ }
104
+ saveContext(command, context) {
105
+ this.cache.set(this.getCacheKey(command.id, context.chatId), context);
106
+ }
107
+ clearContext(command, chatId) {
108
+ this.cache.del(this.getCacheKey(command.id, chatId));
109
+ }
110
+ getContext(command, chatId) {
111
+ return this.cache.get(this.getCacheKey(command.id, chatId));
112
+ }
113
+ getCacheKey(commandId, chatId) {
114
+ return `bot-${this.clientId}-advanced-command-${commandId}-in-${chatId}`;
115
+ }
116
+ }
117
+ exports.default = AdvancedCommandController;
118
+ //# sourceMappingURL=AdvancedCommandController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandController.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandController.ts"],"names":[],"mappings":";;;;;AAMA,4DAAmC;AAEnC,wEAAgD;AAEhD,MAAqB,yBAAyB;IAK5C,YAAY,QAAgB;QAFrB,aAAQ,GAAoC,EAAE,CAAC;QAGpD,IAAI,CAAC,QAAQ,GAA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AE,OAAO,CAAC,CAAC;IACxE,CAAC;IAEM,YAAY,CACjB,OAA2B,EAC3B,MAAc;QAEd,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAEM,UAAU,CACf,OAAwB,EACxB,MAAc;QAId,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CACnB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CACrC,CAAC;IACJ,CAAC;IAEM,WAAW,CAAC,SAAiB,EAAE,MAAc;QAClD,OAAO,OAAO,IAAI,CAAC,QAAQ,qBAAqB,SAAS,OAAO,MAAM,EAAE,CAAC;IAC3E,CAAC;CACF;AAvKD,4CAuKC"}
@@ -0,0 +1,6 @@
1
+ import type AdvancedCommand from "./AdvancedCommand";
2
+ import type AdvancedCommandController from "./AdvancedCommandController";
3
+ export type AdvancedCommandData<T extends object> = {
4
+ context: T;
5
+ controller: AdvancedCommandController;
6
+ } & Partial<AdvancedCommand<T>>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandData.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandData.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { AdvancedCommandContext } from "./AdvancedCommandContext";
2
+ import type { AdvancedCommandNextOptions } from "./AdvancedCommandNext";
3
+ import type { AdvancedCommandStopOptions } from "./AdvancedCommandStop";
4
+ export type AdvancedCommandJob<T extends object> = {
5
+ context: AdvancedCommandContext<T>;
6
+ saveTaskContext: AdvancedCommandSaveJob<T>;
7
+ nextTask: AdvancedCommandNextJob<T>;
8
+ stopTask: AdvancedCommandStopJob;
9
+ };
10
+ export type AdvancedCommandSaveJob<T extends object> = (data: T) => Promise<void> | void;
11
+ export type AdvancedCommandNextJob<T extends object> = (options?: Partial<AdvancedCommandNextOptions<T>>) => Promise<void> | void;
12
+ export type AdvancedCommandStopJob = (options?: Partial<AdvancedCommandStopOptions>) => Promise<void> | void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandJob.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandJob.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export type AdvancedCommandNextOptions<T extends object> = {
2
+ context: T;
3
+ taskId: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandNext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandNext.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandNext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export type AdvancedCommandOptions = {
2
+ removeOnStop: boolean | {
3
+ age: number;
4
+ };
5
+ attempts: number;
6
+ timeout: number;
7
+ delay: number;
8
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandOptions.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { AdvancedCommandContext } from "./AdvancedCommandContext";
2
+ export type AdvancedCommandStartOptions<T extends object> = {
3
+ chatId: string;
4
+ context: AdvancedCommandContext<T>;
5
+ taskId: string;
6
+ };
7
+ export type PartialAdvancedCommandStartOptions<T extends object> = {
8
+ chatId: string;
9
+ context?: Partial<AdvancedCommandContext<T>>;
10
+ taskId?: string;
11
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandStart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandStart.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandStart.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type AdvancedCommandStopOptions = {
2
+ noRemove: boolean;
3
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandStop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandStop.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandStop.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import type { AdvancedCommandJob } from "./AdvancedCommandJob";
2
+ export type AdvancedCommandTask<T extends object> = (job: AdvancedCommandJob<T>) => Promise<void> | void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=AdvancedCommandTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedCommandTask.js","sourceRoot":"","sources":["../../../../src/modules/command/advanced/AdvancedCommandTask.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import ICommandControllerConfig from "./ICommandControllerConfig";
2
+ export declare const DEFAULT_COMMAND_CONTROLLER_CONFIG: ICommandControllerConfig;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_COMMAND_CONTROLLER_CONFIG = void 0;
4
+ exports.DEFAULT_COMMAND_CONTROLLER_CONFIG = {
5
+ prefix: "",
6
+ lowerCase: false,
7
+ };
8
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/modules/command/defaults.ts"],"names":[],"mappings":";;;AAEa,QAAA,iCAAiC,GAA6B;IACzE,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,KAAK;CACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import ICommandControllerConfig from "./ICommandControllerConfig";
2
+ import CommandControllerEvent from "./CommandControllerEvent";
3
+ import CommandController from "./CommandController";
4
+ import CommandPermission from "./CommandPermission";
5
+ import CommandKey from "./CommandKey";
6
+ import Command from "./Command";
7
+ export * from "./Command";
8
+ export * from "./defaults";
9
+ export * from "./perms";
10
+ export * from "./CommandEnums";
11
+ export * from "./keys";
12
+ export { ICommandControllerConfig, CommandController, CommandControllerEvent, CommandPermission, CommandKey, Command };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Command = exports.CommandKey = exports.CommandPermission = exports.CommandControllerEvent = exports.CommandController = void 0;
21
+ const CommandControllerEvent_1 = __importDefault(require("./CommandControllerEvent"));
22
+ exports.CommandControllerEvent = CommandControllerEvent_1.default;
23
+ const CommandController_1 = __importDefault(require("./CommandController"));
24
+ exports.CommandController = CommandController_1.default;
25
+ const CommandPermission_1 = __importDefault(require("./CommandPermission"));
26
+ exports.CommandPermission = CommandPermission_1.default;
27
+ const CommandKey_1 = __importDefault(require("./CommandKey"));
28
+ exports.CommandKey = CommandKey_1.default;
29
+ const Command_1 = __importDefault(require("./Command"));
30
+ exports.Command = Command_1.default;
31
+ __exportStar(require("./Command"), exports);
32
+ __exportStar(require("./defaults"), exports);
33
+ __exportStar(require("./perms"), exports);
34
+ __exportStar(require("./CommandEnums"), exports);
35
+ __exportStar(require("./keys"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/command/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,sFAA8D;AAYR,iCAZ/C,gCAAsB,CAY+C;AAX5E,4EAAoD;AAWjB,4BAX5B,2BAAiB,CAW4B;AAVpD,4EAAoD;AAU0B,4BAVvE,2BAAiB,CAUuE;AAT/F,8DAAsC;AAS2D,qBAT1F,oBAAU,CAS0F;AAR3G,wDAAgC;AAQ6E,kBARtG,iBAAO,CAQsG;AANpH,4CAA0B;AAC1B,6CAA2B;AAC3B,0CAAwB;AACxB,iDAA+B;AAC/B,yCAAuB"}
@@ -0,0 +1,9 @@
1
+ import CommandKey from "./CommandKey";
2
+ /** Chave do comando exata */
3
+ export declare class CommandKeyExact extends CommandKey {
4
+ type: string;
5
+ }
6
+ /** Chave do comando */
7
+ export declare function CMDKey(...values: string[]): CommandKey;
8
+ /** Chave exata do comando */
9
+ export declare function CMDKeyExact(...values: string[]): CommandKeyExact;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CommandKeyExact = void 0;
7
+ exports.CMDKey = CMDKey;
8
+ exports.CMDKeyExact = CMDKeyExact;
9
+ const CommandEnums_1 = require("./CommandEnums");
10
+ const CommandKey_1 = __importDefault(require("./CommandKey"));
11
+ /** Chave do comando exata */
12
+ class CommandKeyExact extends CommandKey_1.default {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.type = CommandEnums_1.CMDKeyType.Exact;
16
+ }
17
+ }
18
+ exports.CommandKeyExact = CommandKeyExact;
19
+ /** Chave do comando */
20
+ function CMDKey(...values) {
21
+ return new CommandKey_1.default(...values);
22
+ }
23
+ /** Chave exata do comando */
24
+ function CMDKeyExact(...values) {
25
+ return new CommandKeyExact(...values);
26
+ }
27
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/modules/command/keys.ts"],"names":[],"mappings":";;;;;;AASA,wBAEC;AAGD,kCAEC;AAhBD,iDAA4C;AAC5C,8DAAsC;AAEtC,6BAA6B;AAC7B,MAAa,eAAgB,SAAQ,oBAAU;IAA/C;;QACS,SAAI,GAAW,yBAAU,CAAC,KAAK,CAAC;IACzC,CAAC;CAAA;AAFD,0CAEC;AAED,uBAAuB;AACvB,SAAgB,MAAM,CAAC,GAAG,MAAgB;IACxC,OAAO,IAAI,oBAAU,CAAC,GAAG,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,6BAA6B;AAC7B,SAAgB,WAAW,CAAC,GAAG,MAAgB;IAC7C,OAAO,IAAI,eAAe,CAAC,GAAG,MAAM,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import CommandPermission from "./CommandPermission";
2
+ export declare function CMDPerm(id: string, isPermited?: boolean): CommandPermission;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CMDPerm = CMDPerm;
7
+ const CommandPermission_1 = __importDefault(require("./CommandPermission"));
8
+ function CMDPerm(id, isPermited) {
9
+ return new CommandPermission_1.default(id, isPermited);
10
+ }
11
+ //# sourceMappingURL=perms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perms.js","sourceRoot":"","sources":["../../../src/modules/command/perms.ts"],"names":[],"mappings":";;;;;AAEA,0BAEC;AAJD,4EAAoD;AAEpD,SAAgB,OAAO,CAAC,EAAU,EAAE,UAAoB;IACtD,OAAO,IAAI,2BAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC"}