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,49 @@
1
+ import type { QuickResponsePattern } from "./QuickResponsePattern";
2
+ import type { QuickResponseReply } from "./QuickResponseReply";
3
+ import QuickResponseOptions from "./QuickResponseOptions";
4
+ import Message from "../../messages/Message";
5
+ /**
6
+ * Mensagem rápida.
7
+ * @example
8
+ * const quickResponse1 = new QuickResponse(["comprar", "pedido", "quero"], "Vamos fazer um pedido?");
9
+ *
10
+ * const quickResponse2 = new QuickResponse(/vendem(.*?)\?/, "Vou estar conferindo...", { priority: 1 });
11
+ *
12
+ * const quickResponse3 = new QuickResponse({ patterns: ["hello", "hi", /ola(.*?)\!/], reply: "Hello There!", priority: 2 });
13
+ *
14
+ * const quickResponse4 = new QuickResponse(
15
+ * async (text, message) => {
16
+ * await message.addReaction("👋");
17
+ *
18
+ * return message.chat.type !== ChatType.Group && text.includes("hi");
19
+ * },
20
+ * (message) => {
21
+ * message.reply(`Hello ${message.chat.name}!`);
22
+ * },
23
+ * { priority: 1 }
24
+ * );
25
+ */
26
+ export default class QuickResponse extends QuickResponseOptions {
27
+ /**
28
+ * @param pattern - O padrão da resposta rápida.
29
+ * @param reply - A resposta da resposta rápida.
30
+ * @param options - As opções da resposta rápida.
31
+ */
32
+ constructor(pattern: QuickResponsePattern, reply: QuickResponseReply, options?: Partial<QuickResponseOptions>);
33
+ /**
34
+ * @param patterns - Lista de padrões da resposta rápida.
35
+ * @param reply - A resposta da resposta rápida.
36
+ * @param options - As opções da resposta rápida.
37
+ */
38
+ constructor(patterns: QuickResponsePattern[], reply: QuickResponseReply, options?: Partial<QuickResponseOptions>);
39
+ /**
40
+ * @param options - As opções da resposta rápida.
41
+ */
42
+ constructor(options: Partial<QuickResponseOptions>);
43
+ /**
44
+ * Executa a resposta.
45
+ * @param message - A mensagem de origem.
46
+ * @param pattern - O padrão da mensagem.
47
+ */
48
+ execute(message: Message, pattern: QuickResponsePattern): Promise<Message | any>;
49
+ }
@@ -0,0 +1,64 @@
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 QuickResponseOptions_1 = __importDefault(require("./QuickResponseOptions"));
7
+ /**
8
+ * Mensagem rápida.
9
+ * @example
10
+ * const quickResponse1 = new QuickResponse(["comprar", "pedido", "quero"], "Vamos fazer um pedido?");
11
+ *
12
+ * const quickResponse2 = new QuickResponse(/vendem(.*?)\?/, "Vou estar conferindo...", { priority: 1 });
13
+ *
14
+ * const quickResponse3 = new QuickResponse({ patterns: ["hello", "hi", /ola(.*?)\!/], reply: "Hello There!", priority: 2 });
15
+ *
16
+ * const quickResponse4 = new QuickResponse(
17
+ * async (text, message) => {
18
+ * await message.addReaction("👋");
19
+ *
20
+ * return message.chat.type !== ChatType.Group && text.includes("hi");
21
+ * },
22
+ * (message) => {
23
+ * message.reply(`Hello ${message.chat.name}!`);
24
+ * },
25
+ * { priority: 1 }
26
+ * );
27
+ */
28
+ class QuickResponse extends QuickResponseOptions_1.default {
29
+ /**
30
+ * @param content - O conteúdo da resposta rápida.
31
+ * @param reply - A resposta da resposta rápida.
32
+ * @param options - As opções da mensagem apósida.
33
+ */
34
+ constructor(content, reply, options) {
35
+ super(options);
36
+ if (QuickResponseOptions_1.default.isValid(content)) {
37
+ this.inject(content);
38
+ }
39
+ else {
40
+ if (Array.isArray(content)) {
41
+ this.patterns = content;
42
+ }
43
+ else {
44
+ this.patterns = [content];
45
+ }
46
+ if (reply) {
47
+ this.reply = reply;
48
+ }
49
+ }
50
+ }
51
+ /**
52
+ * Executa a resposta.
53
+ * @param message - A mensagem de origem.
54
+ * @param pattern - O padrão da mensagem.
55
+ */
56
+ async execute(message, pattern) {
57
+ if (typeof this.reply === "function") {
58
+ return await this.reply(message, pattern);
59
+ }
60
+ return await message.reply(this.reply);
61
+ }
62
+ }
63
+ exports.default = QuickResponse;
64
+ //# sourceMappingURL=QuickResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickResponse.js","sourceRoot":"","sources":["../../../src/modules/quickResponse/QuickResponse.ts"],"names":[],"mappings":";;;;;AAGA,kFAA0D;AAG1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAqB,aAAc,SAAQ,8BAAoB;IAoB7D;;;;OAIG;IACH,YAAY,OAAsF,EAAE,KAA0B,EAAE,OAAuC;QACrK,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,8BAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,GAAG,CAAC,OAAO,CAAC,CAAC;YAC5B,CAAC;YAED,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAC,OAAgB,EAAE,OAA6B;QAClE,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YACrC,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAvDD,gCAuDC"}
@@ -0,0 +1,55 @@
1
+ import type { QuickResponsePattern } from "./QuickResponsePattern";
2
+ import type QuickResponse from "./QuickResponse";
3
+ import type Message from "../../messages/Message";
4
+ /** Controlador das respostas rápidas */
5
+ export default class QuickResponseController {
6
+ /** Lista de respostas rápidas separadas por prioridade */
7
+ quickResponseByPriority: Record<number, QuickResponse[]>;
8
+ /** Usar letras minúsculas na busca */
9
+ useLowerCase: boolean;
10
+ /**
11
+ * @param quickResponses - As respostas rápidas.
12
+ * @param options - As opções do controlador.
13
+ */
14
+ constructor(quickResponses: QuickResponse[], options?: Partial<QuickResponseController>);
15
+ /**
16
+ * @param options - As opções do controlador.
17
+ * @param quickResponses - As mensagens mínpidas.
18
+ */
19
+ constructor(options?: Partial<QuickResponseController>, quickResponses?: QuickResponse[]);
20
+ /**
21
+ * Injeta os dados no controlador.
22
+ * @param options - Dados a serem injetados.
23
+ */
24
+ inject(options: Partial<QuickResponseController>): void;
25
+ /**
26
+ * Adiciona uma ou mais respostas rápidas.
27
+ * @param quickResponses - As respostas rápidas.
28
+ */
29
+ add(...quickResponses: QuickResponse[]): void;
30
+ /**
31
+ * Remove uma ou mais mensagens específicas.
32
+ * @param quickResponses - As respostas rápidas a serem removidas.
33
+ */
34
+ remove(...quickResponses: Array<QuickResponse | string>): void;
35
+ /**
36
+ * @returns As respostas rápidas.
37
+ */
38
+ getAll(): QuickResponse[];
39
+ searchAndExecute(message: Message): Promise<Message | null | unknown>;
40
+ /**
41
+ * Pesquisa por uma resposta rápida.
42
+ * @param message - A mensagem de referencia.
43
+ */
44
+ search(message: Message): Promise<{
45
+ quickResponse: QuickResponse;
46
+ pattern: QuickResponsePattern;
47
+ } | null>;
48
+ /**
49
+ * Pesquisa por um padrão na mensagem.
50
+ * @param text - O texto a ser pesquisado.
51
+ * @param message - A mensagem de referencia.
52
+ * @param patterns - Os padrões da resposta rápida.
53
+ */
54
+ searchInPatterns(text: string, message: Message, ...patterns: QuickResponsePattern[]): Promise<QuickResponsePattern | null>;
55
+ }
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("util/types");
4
+ /** Controlador das respostas rápidas */
5
+ class QuickResponseController {
6
+ constructor(arg1, arg2) {
7
+ /** Lista de respostas rápidas separadas por prioridade */
8
+ this.quickResponseByPriority = {};
9
+ /** Usar letras minúsculas na busca */
10
+ this.useLowerCase = true;
11
+ if (arg1) {
12
+ if (!Array.isArray(arg1))
13
+ this.inject(arg1);
14
+ else
15
+ this.add(...arg1);
16
+ }
17
+ if (arg2) {
18
+ if (!Array.isArray(arg2))
19
+ this.inject(arg2);
20
+ else
21
+ this.add(...arg2);
22
+ }
23
+ }
24
+ /**
25
+ * Injeta os dados no controlador.
26
+ * @param options - Dados a serem injetados.
27
+ */
28
+ inject(options) {
29
+ var _a;
30
+ this.useLowerCase = (_a = options === null || options === void 0 ? void 0 : options.useLowerCase) !== null && _a !== void 0 ? _a : this.useLowerCase;
31
+ }
32
+ /**
33
+ * Adiciona uma ou mais respostas rápidas.
34
+ * @param quickResponses - As respostas rápidas.
35
+ */
36
+ add(...quickResponses) {
37
+ for (const quickResponse of quickResponses) {
38
+ if (!this.quickResponseByPriority[quickResponse.priority]) {
39
+ this.quickResponseByPriority[quickResponse.priority] = [quickResponse];
40
+ }
41
+ else {
42
+ this.quickResponseByPriority[quickResponse.priority].push(quickResponse);
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * Remove uma ou mais mensagens específicas.
48
+ * @param quickResponses - As respostas rápidas a serem removidas.
49
+ */
50
+ remove(...quickResponses) {
51
+ for (const quickResponse of quickResponses) {
52
+ if (typeof quickResponse === "string") {
53
+ for (const priority of Object.keys(this.quickResponseByPriority)) {
54
+ this.quickResponseByPriority[priority] = this.quickResponseByPriority[priority].filter((q) => q.id !== quickResponse);
55
+ }
56
+ }
57
+ else {
58
+ this.quickResponseByPriority[quickResponse.priority] = this.quickResponseByPriority[quickResponse.priority].filter((q) => q.id === quickResponse.id);
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * @returns As respostas rápidas.
64
+ */
65
+ getAll() {
66
+ return Object.values(this.quickResponseByPriority).flat();
67
+ }
68
+ async searchAndExecute(message) {
69
+ const res = await this.search(message);
70
+ if (!res)
71
+ return null;
72
+ return await res.quickResponse.execute(message, res.pattern);
73
+ }
74
+ /**
75
+ * Pesquisa por uma resposta rápida.
76
+ * @param message - A mensagem de referencia.
77
+ */
78
+ async search(message) {
79
+ const text = this.useLowerCase ? message.text.toLowerCase() : message.text;
80
+ const priorities = Object.keys(this.quickResponseByPriority).sort((a, b) => +a - +b);
81
+ for (const priority of priorities) {
82
+ for (const quickResponse of this.quickResponseByPriority[priority]) {
83
+ const pattern = await this.searchInPatterns(text, message, ...quickResponse.patterns);
84
+ if (pattern !== null) {
85
+ return { quickResponse, pattern };
86
+ }
87
+ }
88
+ }
89
+ return null;
90
+ }
91
+ /**
92
+ * Pesquisa por um padrão na mensagem.
93
+ * @param text - O texto a ser pesquisado.
94
+ * @param message - A mensagem de referencia.
95
+ * @param patterns - Os padrões da resposta rápida.
96
+ */
97
+ async searchInPatterns(text, message, ...patterns) {
98
+ const resultInPromsie = [];
99
+ for (const pattern of patterns) {
100
+ if (typeof pattern === "string") {
101
+ if (text.includes(this.useLowerCase ? pattern.toLowerCase() : pattern))
102
+ return pattern;
103
+ }
104
+ else if ((0, types_1.isRegExp)(pattern)) {
105
+ if (pattern.test(text))
106
+ return pattern;
107
+ }
108
+ else if (typeof pattern === "function") {
109
+ const result = pattern(text, message, this);
110
+ if (!result)
111
+ continue;
112
+ if (typeof result === "boolean")
113
+ return pattern;
114
+ resultInPromsie.push({ pattern, result });
115
+ }
116
+ }
117
+ for (const { pattern, result } of resultInPromsie) {
118
+ if (await result)
119
+ return pattern;
120
+ }
121
+ return null;
122
+ }
123
+ }
124
+ exports.default = QuickResponseController;
125
+ //# sourceMappingURL=QuickResponseController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickResponseController.js","sourceRoot":"","sources":["../../../src/modules/quickResponse/QuickResponseController.ts"],"names":[],"mappings":";;AAIA,sCAAsC;AAEtC,wCAAwC;AACxC,MAAqB,uBAAuB;IAmB1C,YAAY,IAAyD,EAAE,IAAyD;QAlBhI,0DAA0D;QACnD,4BAAuB,GAAoC,EAAE,CAAC;QAErE,sCAAsC;QAC/B,iBAAY,GAAY,IAAI,CAAC;QAelC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;gBACvC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;QACzB,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;gBACvC,IAAI,CA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C,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,gBAAgB,CAAC,IAAY,EAAE,OAAgB,EAAE,GAAG,QAAgC;QAC/F,MAAM,eAAe,GAAuE,EAAE,CAAC;QAE/F,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;oBAAE,OAAO,OAAO,CAAC;YACzF,CAAC;iBAAM,IAAI,IAAA,gBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;oBAAE,OAAO,OAAO,CAAC;YACzC,CAAC;iBAAM,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;gBACzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBAE5C,IAAI,CAAC,MAAM;oBAAE,SAAS;gBAEtB,IAAI,OAAO,MAAM,KAAK,SAAS;oBAAE,OAAO,OAAO,CAAC;gBAEhD,eAAe,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QAED,KAAK,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC;YAClD,IAAI,MAAM,MAAM;gBAAE,OAAO,OAAO,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzID,0CAyIC"}
@@ -0,0 +1,56 @@
1
+ import type { QuickResponsePattern } from "./QuickResponsePattern";
2
+ import type { QuickResponseReply } from "./QuickResponseReply";
3
+ /** Opções da resposta rápida */
4
+ export default class QuickResponseOptions {
5
+ id: string;
6
+ /**
7
+ * * Lista de padrões da mensagem.
8
+ *
9
+ * @example
10
+ *
11
+ * // Normal pattern
12
+ * "buy"
13
+ *
14
+ * // Others pattern
15
+ * ["buy", "get", "search", /\D/g, "hello"]
16
+ *
17
+ * // Regex pattern
18
+ * /search (.?*)?/
19
+ *
20
+ * // Custom pattern
21
+ * (message: Message) => message.text.includes("search")
22
+ *
23
+ * */
24
+ patterns: QuickResponsePattern[];
25
+ /**
26
+ * * Prioridade da resposta rápida.
27
+ *
28
+ * A prioriddade é definida do maior ao menos (1 = maior, 2 = menor que 1, 3 = menor que 2, ...).
29
+ */
30
+ priority: number;
31
+ /**
32
+ * * Resposta da resposta rápida.
33
+ *
34
+ * @example
35
+ *
36
+ * // Normal response
37
+ * "Hello World!"
38
+ *
39
+ * // Custom response
40
+ * (message: Message) => {
41
+ * return `Hello ${message.user.name}!`;
42
+ * }
43
+ * */
44
+ reply: QuickResponseReply;
45
+ constructor(options?: Partial<QuickResponseOptions>);
46
+ /**
47
+ * Injeta as opções da resposta rápida.
48
+ * @param options - As opções da resposta rápida.
49
+ */
50
+ inject(options?: Partial<QuickResponseOptions>): void;
51
+ /**
52
+ * Valida se o conteúdo da resposta está correto.
53
+ * @param options - As opções da resposta rápida.
54
+ */
55
+ static isValid(options: unknown): options is Partial<QuickResponseOptions>;
56
+ }
@@ -0,0 +1,76 @@
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 types_1 = require("util/types");
7
+ const nonce_1 = __importDefault(require("../../utils/nonce"));
8
+ /** Opções da resposta rápida */
9
+ class QuickResponseOptions {
10
+ constructor(options) {
11
+ this.id = "";
12
+ /**
13
+ * * Lista de padrões da mensagem.
14
+ *
15
+ * @example
16
+ *
17
+ * // Normal pattern
18
+ * "buy"
19
+ *
20
+ * // Others pattern
21
+ * ["buy", "get", "search", /\D/g, "hello"]
22
+ *
23
+ * // Regex pattern
24
+ * /search (.?*)?/
25
+ *
26
+ * // Custom pattern
27
+ * (message: Message) => message.text.includes("search")
28
+ *
29
+ * */
30
+ this.patterns = [];
31
+ /**
32
+ * * Prioridade da resposta rápida.
33
+ *
34
+ * A prioriddade é definida do maior ao menos (1 = maior, 2 = menor que 1, 3 = menor que 2, ...).
35
+ */
36
+ this.priority = 1;
37
+ /**
38
+ * * Resposta da resposta rápida.
39
+ *
40
+ * @example
41
+ *
42
+ * // Normal response
43
+ * "Hello World!"
44
+ *
45
+ * // Custom response
46
+ * (message: Message) => {
47
+ * return `Hello ${message.user.name}!`;
48
+ * }
49
+ * */
50
+ this.reply = "";
51
+ if (!(options === null || options === void 0 ? void 0 : options.id)) {
52
+ this.id = (0, nonce_1.default)();
53
+ }
54
+ this.inject(options);
55
+ }
56
+ /**
57
+ * Injeta as opções da resposta rápida.
58
+ * @param options - As opções da resposta rápida.
59
+ */
60
+ inject(options) {
61
+ var _a, _b, _c, _d;
62
+ this.id = (_a = options === null || options === void 0 ? void 0 : options.id) !== null && _a !== void 0 ? _a : this.id;
63
+ this.patterns = (_b = options === null || options === void 0 ? void 0 : options.patterns) !== null && _b !== void 0 ? _b : this.patterns;
64
+ this.priority = (_c = options === null || options === void 0 ? void 0 : options.priority) !== null && _c !== void 0 ? _c : this.priority;
65
+ this.reply = (_d = options === null || options === void 0 ? void 0 : options.reply) !== null && _d !== void 0 ? _d : this.reply;
66
+ }
67
+ /**
68
+ * Valida se o conteúdo da resposta está correto.
69
+ * @param options - As opções da resposta rápida.
70
+ */
71
+ static isValid(options) {
72
+ return !!options && typeof options === "object" && !Array.isArray(options) && !(0, types_1.isRegExp)(options);
73
+ }
74
+ }
75
+ exports.default = QuickResponseOptions;
76
+ //# sourceMappingURL=QuickResponseOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickResponseOptions.js","sourceRoot":"","sources":["../../../src/modules/qu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AC,OAAO,CAAC,CAAC;IACnG,CAAC;CACF;AAvED,uCAuEC"}
@@ -0,0 +1,28 @@
1
+ import type QuickResponseController from "./QuickResponseController";
2
+ import type Message from "../../messages/Message";
3
+ /**
4
+ * Padrões da resposta rápida.
5
+ *
6
+ * @example
7
+ *
8
+ * // Normal pattern
9
+ * "buy"
10
+ *
11
+ * // Regex pattern
12
+ * /search (.?*)\?/
13
+ *
14
+ * // Custom pattern
15
+ * (message: Message) => message.text.includes("search")
16
+ */
17
+ export type QuickResponsePattern = string | RegExp | CustomQuickResponsePattern;
18
+ /**
19
+ * Padrão customizada da resposta rápida.
20
+ *
21
+ * @example
22
+ *
23
+ * // Custom pattern
24
+ * (text: string, message: Message, quickResponseController: QuickResponseController) => {
25
+ * return text.includes("search");
26
+ * }
27
+ */
28
+ export type CustomQuickResponsePattern = (text: string, message: Message, quickResponseController: QuickResponseController) => Promise<boolean> | boolean;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=QuickResponsePattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickResponsePattern.js","sourceRoot":"","sources":["../../../src/modules/quickResponse/QuickResponsePattern.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { QuickResponsePattern } from "./QuickResponsePattern";
2
+ import type Message from "../../messages/Message";
3
+ /** Resposta da resposta rápida */
4
+ export type QuickResponseReply = string | Message | CustomQuickResponseReply;
5
+ /** Resposta customizada da resposta rápida */
6
+ export type CustomQuickResponseReply = (message: Message, pattern: QuickResponsePattern) => any;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=QuickResponseReply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QuickResponseReply.js","sourceRoot":"","sources":["../../../src/modules/quickResponse/QuickResponseReply.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { QuickResponsePattern } from "./QuickResponsePattern";
2
+ import type { QuickResponseReply } from "./QuickResponseReply";
3
+ import QuickResponseController from "./QuickResponseController";
4
+ import QuickResponseOptions from "./QuickResponseOptions";
5
+ import QuickResponse from "./QuickResponse";
6
+ export { QuickResponse, QuickResponseOptions, QuickResponsePattern, QuickResponseReply, QuickResponseController };
@@ -0,0 +1,13 @@
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.QuickResponseController = exports.QuickResponseOptions = exports.QuickResponse = void 0;
7
+ const QuickResponseController_1 = __importDefault(require("./QuickResponseController"));
8
+ exports.QuickResponseController = QuickResponseController_1.default;
9
+ const QuickResponseOptions_1 = __importDefault(require("./QuickResponseOptions"));
10
+ exports.QuickResponseOptions = QuickResponseOptions_1.default;
11
+ const QuickResponse_1 = __importDefault(require("./QuickResponse"));
12
+ exports.QuickResponse = QuickResponse_1.default;
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/quickResponse/index.ts"],"names":[],"mappings":";;;;;;AAGA,wFAAgE;AAIwB,kCAJjF,iCAAuB,CAIiF;AAH/G,kFAA0D;AAGlC,+BAHjB,8BAAoB,CAGiB;AAF5C,oEAA4C;AAEnC,wBAFF,uBAAa,CAEE"}
@@ -0,0 +1,91 @@
1
+ import type Chat from '../chat/Chat';
2
+ export default class User {
3
+ /** ID do bot associado a este usuário */
4
+ botId?: string;
5
+ /** ID do cliente associado a este usuário */
6
+ clientId?: string;
7
+ /** ID do usuário */
8
+ id: string;
9
+ /** Nome do usuário */
10
+ name?: string;
11
+ /** Nome salvado do usuário */
12
+ savedName?: string;
13
+ /** Número de telefone */
14
+ phoneNumber?: string;
15
+ /** Descrição do usuário */
16
+ description?: string;
17
+ /** URL da imagem de perfil do usuário */
18
+ profileUrl?: string;
19
+ /** [Telegram] Apelido do usuário */
20
+ nickname?: string;
21
+ /** Obter o cliente do chat */
22
+ private get client();
23
+ /**
24
+ * Cria uma instância de User.
25
+ * @param id - O ID do usuário.
26
+ * @param name - O nome do usuário (opcional, padrão é uma string vazia).
27
+ */
28
+ constructor(id: string, name?: string);
29
+ /** Bloqueia o usuário. */
30
+ blockUser(): Promise<void>;
31
+ /** Desbloqueia o usuário. */
32
+ unblockUser(): Promise<void>;
33
+ /** Retorna o nome do usuário. */
34
+ getName(): Promise<string | undefined>;
35
+ /**
36
+ * Define o nome do usuário.
37
+ * @param name - O novo nome para definir.
38
+ */
39
+ setName(name: string): Promise<void>;
40
+ /** Retorna a descrição do usuário. */
41
+ getDescription(): Promise<string | undefined>;
42
+ /**
43
+ * Define a descrição do usuário.
44
+ * @param description - A nova descrição para definir.
45
+ */
46
+ setDescription(description: string): Promise<void>;
47
+ /** Retorna o perfil do usuário. */
48
+ getProfile(): Promise<Buffer | undefined>;
49
+ /**
50
+ * Define o perfil do usuário.
51
+ * @param image - O novo perfil para definir como um Buffer.
52
+ */
53
+ setProfile(image: Buffer): Promise<void>;
54
+ /**
55
+ * Verifica se o usuário é um administrador de um chat.
56
+ * @param chat - O chat ou ID do chat a ser verificado.
57
+ */
58
+ isAdmin(chat: Chat | string): Promise<boolean>;
59
+ /**
60
+ * Verifica se o usuário é o líder de um chat.
61
+ * @param chat - O chat ou ID do chat a ser verificado.
62
+ */
63
+ isLeader(chat: Chat | string): Promise<boolean>;
64
+ /**
65
+ * Converte o objeto atual para uma representação em formato JSON.
66
+ * @returns Um objeto JSON que representa o estado atual do objeto.
67
+ */
68
+ toJSON(): any;
69
+ /**
70
+ * Cria uma instância de User a partir de uma representação em formato JSON.
71
+ * @param data - Os dados JSON a serem usados para criar a instância.
72
+ */
73
+ static fromJSON(data: any): User;
74
+ /**
75
+ * Retorna uma instância de User com base em um ID e/ou dados passados.
76
+ * @param user - O ID do usuário ou uma instância existente de User.
77
+ * @param data - Dados que serão aplicados no usuário.
78
+ */
79
+ static apply(user: User | string, data?: Partial<User>): User;
80
+ /**
81
+ * Retorna o ID de um usuário.
82
+ * @param user - O usuário ou ID do usuário de onde obter o ID.
83
+ * @returns O ID do usuário como uma string, ou uma string vazia se o usuário for inválido.
84
+ */
85
+ static getId(user: User | string): string | undefined;
86
+ /**
87
+ * Verifica se um objeto é uma instância válida de User.
88
+ * @param user - O objeto a ser verificado.
89
+ */
90
+ static isValid(user: any): user is User;
91
+ }