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.
- package/LICENSE +21 -0
- package/README.md +560 -0
- package/lib/bot/BotBase.d.ts +82 -0
- package/lib/bot/BotBase.js +144 -0
- package/lib/bot/BotBase.js.map +1 -0
- package/lib/bot/BotEvents.d.ts +87 -0
- package/lib/bot/BotEvents.js +51 -0
- package/lib/bot/BotEvents.js.map +1 -0
- package/lib/bot/BotServer.d.ts +34 -0
- package/lib/bot/BotServer.js +118 -0
- package/lib/bot/BotServer.js.map +1 -0
- package/lib/bot/BotStatus.d.ts +4 -0
- package/lib/bot/BotStatus.js +9 -0
- package/lib/bot/BotStatus.js.map +1 -0
- package/lib/bot/IBot.d.ts +292 -0
- package/lib/bot/IBot.js +3 -0
- package/lib/bot/IBot.js.map +1 -0
- package/lib/bot/index.d.ts +5 -0
- package/lib/bot/index.js +13 -0
- package/lib/bot/index.js.map +1 -0
- package/lib/client/Client.d.ts +120 -0
- package/lib/client/Client.js +687 -0
- package/lib/client/Client.js.map +1 -0
- package/lib/client/ClientEvents.d.ts +147 -0
- package/lib/client/ClientEvents.js +93 -0
- package/lib/client/ClientEvents.js.map +1 -0
- package/lib/client/ClientFunctionHandler.d.ts +15 -0
- package/lib/client/ClientFunctionHandler.js +70 -0
- package/lib/client/ClientFunctionHandler.js.map +1 -0
- package/lib/client/ConnectionType.d.ts +4 -0
- package/lib/client/ConnectionType.js +3 -0
- package/lib/client/ConnectionType.js.map +1 -0
- package/lib/client/IAuth.d.ts +9 -0
- package/lib/client/IAuth.js +3 -0
- package/lib/client/IAuth.js.map +1 -0
- package/lib/client/IClient.d.ts +358 -0
- package/lib/client/IClient.js +3 -0
- package/lib/client/IClient.js.map +1 -0
- package/lib/client/index.d.ts +7 -0
- package/lib/client/index.js +13 -0
- package/lib/client/index.js.map +1 -0
- package/lib/cluster/ClientCluster.d.ts +428 -0
- package/lib/cluster/ClientCluster.js +1746 -0
- package/lib/cluster/ClientCluster.js.map +1 -0
- package/lib/cluster/WorkerMessage.d.ts +99 -0
- package/lib/cluster/WorkerMessage.js +84 -0
- package/lib/cluster/WorkerMessage.js.map +1 -0
- package/lib/cluster/index.d.ts +5 -0
- package/lib/cluster/index.js +27 -0
- package/lib/cluster/index.js.map +1 -0
- package/lib/configs/ConnectionConfig.d.ts +22 -0
- package/lib/configs/ConnectionConfig.js +3 -0
- package/lib/configs/ConnectionConfig.js.map +1 -0
- package/lib/configs/Defaults.d.ts +2 -0
- package/lib/configs/Defaults.js +16 -0
- package/lib/configs/Defaults.js.map +1 -0
- package/lib/configs/WAConfigs.d.ts +1 -0
- package/lib/configs/WAConfigs.js +5 -0
- package/lib/configs/WAConfigs.js.map +1 -0
- package/lib/configs/index.d.ts +3 -0
- package/lib/configs/index.js +18 -0
- package/lib/configs/index.js.map +1 -0
- package/lib/errors/ChatNotDefinedError.d.ts +4 -0
- package/lib/errors/ChatNotDefinedError.js +9 -0
- package/lib/errors/ChatNotDefinedError.js.map +1 -0
- package/lib/errors/ClientNotDefinedError.d.ts +4 -0
- package/lib/errors/ClientNotDefinedError.js +9 -0
- package/lib/errors/ClientNotDefinedError.js.map +1 -0
- package/lib/errors/UserNotDefinedError.d.ts +4 -0
- package/lib/errors/UserNotDefinedError.js +9 -0
- package/lib/errors/UserNotDefinedError.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +60 -0
- package/lib/index.js.map +1 -0
- package/lib/messages/AudioMessage.d.ts +42 -0
- package/lib/messages/AudioMessage.js +66 -0
- package/lib/messages/AudioMessage.js.map +1 -0
- package/lib/messages/ButtonMessage.d.ts +88 -0
- package/lib/messages/ButtonMessage.js +137 -0
- package/lib/messages/ButtonMessage.js.map +1 -0
- package/lib/messages/ContactMessage.d.ts +37 -0
- package/lib/messages/ContactMessage.js +93 -0
- package/lib/messages/ContactMessage.js.map +1 -0
- package/lib/messages/CustomMessage.d.ts +35 -0
- package/lib/messages/CustomMessage.js +88 -0
- package/lib/messages/CustomMessage.js.map +1 -0
- package/lib/messages/EmptyMessage.d.ts +25 -0
- package/lib/messages/EmptyMessage.js +78 -0
- package/lib/messages/EmptyMessage.js.map +1 -0
- package/lib/messages/ErrorMessage.d.ts +35 -0
- package/lib/messages/ErrorMessage.js +86 -0
- package/lib/messages/ErrorMessage.js.map +1 -0
- package/lib/messages/FileMessage.d.ts +36 -0
- package/lib/messages/FileMessage.js +60 -0
- package/lib/messages/FileMessage.js.map +1 -0
- package/lib/messages/ImageMessage.d.ts +41 -0
- package/lib/messages/ImageMessage.js +65 -0
- package/lib/messages/ImageMessage.js.map +1 -0
- package/lib/messages/ListMessage.d.ts +91 -0
- package/lib/messages/ListMessage.js +126 -0
- package/lib/messages/ListMessage.js.map +1 -0
- package/lib/messages/LocationMessage.d.ts +48 -0
- package/lib/messages/LocationMessage.js +107 -0
- package/lib/messages/LocationMessage.js.map +1 -0
- package/lib/messages/MediaMessage.d.ts +54 -0
- package/lib/messages/MediaMessage.js +113 -0
- package/lib/messages/MediaMessage.js.map +1 -0
- package/lib/messages/Message.d.ts +144 -0
- package/lib/messages/Message.js +223 -0
- package/lib/messages/Message.js.map +1 -0
- package/lib/messages/PollMessage.d.ts +87 -0
- package/lib/messages/PollMessage.js +145 -0
- package/lib/messages/PollMessage.js.map +1 -0
- package/lib/messages/PollUpdateMessage.d.ts +40 -0
- package/lib/messages/PollUpdateMessage.js +98 -0
- package/lib/messages/PollUpdateMessage.js.map +1 -0
- package/lib/messages/ReactionMessage.d.ts +36 -0
- package/lib/messages/ReactionMessage.js +91 -0
- package/lib/messages/ReactionMessage.js.map +1 -0
- package/lib/messages/StickerMessage.d.ts +49 -0
- package/lib/messages/StickerMessage.js +73 -0
- package/lib/messages/StickerMessage.js.map +1 -0
- package/lib/messages/TextMessage.d.ts +33 -0
- package/lib/messages/TextMessage.js +84 -0
- package/lib/messages/TextMessage.js.map +1 -0
- package/lib/messages/VideoMessage.d.ts +42 -0
- package/lib/messages/VideoMessage.js +66 -0
- package/lib/messages/VideoMessage.js.map +1 -0
- package/lib/messages/index.d.ts +19 -0
- package/lib/messages/index.js +81 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/models/Address.d.ts +11 -0
- package/lib/models/Address.js +18 -0
- package/lib/models/Address.js.map +1 -0
- package/lib/models/Call.d.ts +68 -0
- package/lib/models/Call.js +127 -0
- package/lib/models/Call.js.map +1 -0
- package/lib/modules/chat/Chat.d.ts +142 -0
- package/lib/modules/chat/Chat.js +246 -0
- package/lib/modules/chat/Chat.js.map +1 -0
- package/lib/modules/chat/ChatAction.d.ts +3 -0
- package/lib/modules/chat/ChatAction.js +3 -0
- package/lib/modules/chat/ChatAction.js.map +1 -0
- package/lib/modules/chat/ChatStatus.d.ts +9 -0
- package/lib/modules/chat/ChatStatus.js +13 -0
- package/lib/modules/chat/ChatStatus.js.map +1 -0
- package/lib/modules/chat/ChatType.d.ts +7 -0
- package/lib/modules/chat/ChatType.js +11 -0
- package/lib/modules/chat/ChatType.js.map +1 -0
- package/lib/modules/chat/index.d.ts +5 -0
- package/lib/modules/chat/index.js +13 -0
- package/lib/modules/chat/index.js.map +1 -0
- package/lib/modules/command/Command.d.ts +67 -0
- package/lib/modules/command/Command.js +139 -0
- package/lib/modules/command/Command.js.map +1 -0
- package/lib/modules/command/CommandController.d.ts +50 -0
- package/lib/modules/command/CommandController.js +119 -0
- package/lib/modules/command/CommandController.js.map +1 -0
- package/lib/modules/command/CommandControllerEvent.d.ts +9 -0
- package/lib/modules/command/CommandControllerEvent.js +25 -0
- package/lib/modules/command/CommandControllerEvent.js.map +1 -0
- package/lib/modules/command/CommandEnums.d.ts +14 -0
- package/lib/modules/command/CommandEnums.js +20 -0
- package/lib/modules/command/CommandEnums.js.map +1 -0
- package/lib/modules/command/CommandKey.d.ts +17 -0
- package/lib/modules/command/CommandKey.js +67 -0
- package/lib/modules/command/CommandKey.js.map +1 -0
- package/lib/modules/command/CommandPermission.d.ts +9 -0
- package/lib/modules/command/CommandPermission.js +35 -0
- package/lib/modules/command/CommandPermission.js.map +1 -0
- package/lib/modules/command/ICommandControllerConfig.d.ts +7 -0
- package/lib/modules/command/ICommandControllerConfig.js +3 -0
- package/lib/modules/command/ICommandControllerConfig.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommand.d.ts +23 -0
- package/lib/modules/command/advanced/AdvancedCommand.js +131 -0
- package/lib/modules/command/advanced/AdvancedCommand.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandContext.d.ts +10 -0
- package/lib/modules/command/advanced/AdvancedCommandContext.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandContext.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandController.d.ts +29 -0
- package/lib/modules/command/advanced/AdvancedCommandController.js +118 -0
- package/lib/modules/command/advanced/AdvancedCommandController.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandData.d.ts +6 -0
- package/lib/modules/command/advanced/AdvancedCommandData.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandData.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandJob.d.ts +12 -0
- package/lib/modules/command/advanced/AdvancedCommandJob.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandJob.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandNext.d.ts +4 -0
- package/lib/modules/command/advanced/AdvancedCommandNext.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandNext.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandOptions.d.ts +8 -0
- package/lib/modules/command/advanced/AdvancedCommandOptions.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandOptions.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandStart.d.ts +11 -0
- package/lib/modules/command/advanced/AdvancedCommandStart.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandStart.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandStop.d.ts +3 -0
- package/lib/modules/command/advanced/AdvancedCommandStop.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandStop.js.map +1 -0
- package/lib/modules/command/advanced/AdvancedCommandTask.d.ts +2 -0
- package/lib/modules/command/advanced/AdvancedCommandTask.js +3 -0
- package/lib/modules/command/advanced/AdvancedCommandTask.js.map +1 -0
- package/lib/modules/command/defaults.d.ts +2 -0
- package/lib/modules/command/defaults.js +8 -0
- package/lib/modules/command/defaults.js.map +1 -0
- package/lib/modules/command/index.d.ts +12 -0
- package/lib/modules/command/index.js +36 -0
- package/lib/modules/command/index.js.map +1 -0
- package/lib/modules/command/keys.d.ts +9 -0
- package/lib/modules/command/keys.js +27 -0
- package/lib/modules/command/keys.js.map +1 -0
- package/lib/modules/command/perms.d.ts +2 -0
- package/lib/modules/command/perms.js +11 -0
- package/lib/modules/command/perms.js.map +1 -0
- package/lib/modules/quickResponse/QuickResponse.d.ts +49 -0
- package/lib/modules/quickResponse/QuickResponse.js +64 -0
- package/lib/modules/quickResponse/QuickResponse.js.map +1 -0
- package/lib/modules/quickResponse/QuickResponseController.d.ts +55 -0
- package/lib/modules/quickResponse/QuickResponseController.js +125 -0
- package/lib/modules/quickResponse/QuickResponseController.js.map +1 -0
- package/lib/modules/quickResponse/QuickResponseOptions.d.ts +56 -0
- package/lib/modules/quickResponse/QuickResponseOptions.js +76 -0
- package/lib/modules/quickResponse/QuickResponseOptions.js.map +1 -0
- package/lib/modules/quickResponse/QuickResponsePattern.d.ts +28 -0
- package/lib/modules/quickResponse/QuickResponsePattern.js +3 -0
- package/lib/modules/quickResponse/QuickResponsePattern.js.map +1 -0
- package/lib/modules/quickResponse/QuickResponseReply.d.ts +6 -0
- package/lib/modules/quickResponse/QuickResponseReply.js +3 -0
- package/lib/modules/quickResponse/QuickResponseReply.js.map +1 -0
- package/lib/modules/quickResponse/index.d.ts +6 -0
- package/lib/modules/quickResponse/index.js +13 -0
- package/lib/modules/quickResponse/index.js.map +1 -0
- package/lib/modules/user/User.d.ts +91 -0
- package/lib/modules/user/User.js +173 -0
- package/lib/modules/user/User.js.map +1 -0
- package/lib/modules/user/UserAction.d.ts +4 -0
- package/lib/modules/user/UserAction.js +3 -0
- package/lib/modules/user/UserAction.js.map +1 -0
- package/lib/modules/user/UserEvent.d.ts +3 -0
- package/lib/modules/user/UserEvent.js +3 -0
- package/lib/modules/user/UserEvent.js.map +1 -0
- package/lib/modules/user/index.d.ts +4 -0
- package/lib/modules/user/index.js +9 -0
- package/lib/modules/user/index.js.map +1 -0
- package/lib/routes/botServer/api/v1/emitEvent.d.ts +3 -0
- package/lib/routes/botServer/api/v1/emitEvent.js +17 -0
- package/lib/routes/botServer/api/v1/emitEvent.js.map +1 -0
- package/lib/routes/botServer/api/v1/function.d.ts +3 -0
- package/lib/routes/botServer/api/v1/function.js +22 -0
- package/lib/routes/botServer/api/v1/function.js.map +1 -0
- package/lib/routes/botServer/api/v1/ping.d.ts +3 -0
- package/lib/routes/botServer/api/v1/ping.js +12 -0
- package/lib/routes/botServer/api/v1/ping.js.map +1 -0
- package/lib/routes/botServer/api/v1/register.d.ts +3 -0
- package/lib/routes/botServer/api/v1/register.js +23 -0
- package/lib/routes/botServer/api/v1/register.js.map +1 -0
- package/lib/routes/botServer/api/v1/setValue.d.ts +3 -0
- package/lib/routes/botServer/api/v1/setValue.js +18 -0
- package/lib/routes/botServer/api/v1/setValue.js.map +1 -0
- package/lib/routes/botServer/api/v1/unregister.d.ts +3 -0
- package/lib/routes/botServer/api/v1/unregister.js +22 -0
- package/lib/routes/botServer/api/v1/unregister.js.map +1 -0
- package/lib/routes/botServer/middlewares/setBotServer.d.ts +4 -0
- package/lib/routes/botServer/middlewares/setBotServer.js +16 -0
- package/lib/routes/botServer/middlewares/setBotServer.js.map +1 -0
- package/lib/routes/botServer/routes.d.ts +8 -0
- package/lib/routes/botServer/routes.js +33 -0
- package/lib/routes/botServer/routes.js.map +1 -0
- package/lib/services/AddressService.d.ts +12 -0
- package/lib/services/AddressService.js +51 -0
- package/lib/services/AddressService.js.map +1 -0
- package/lib/services/BaseService.d.ts +5 -0
- package/lib/services/BaseService.js +19 -0
- package/lib/services/BaseService.js.map +1 -0
- package/lib/services/index.d.ts +3 -0
- package/lib/services/index.js +11 -0
- package/lib/services/index.js.map +1 -0
- package/lib/telegram/TelegramAuth.d.ts +17 -0
- package/lib/telegram/TelegramAuth.js +96 -0
- package/lib/telegram/TelegramAuth.js.map +1 -0
- package/lib/telegram/TelegramBot.d.ts +88 -0
- package/lib/telegram/TelegramBot.js +345 -0
- package/lib/telegram/TelegramBot.js.map +1 -0
- package/lib/telegram/TelegramEvents.d.ts +13 -0
- package/lib/telegram/TelegramEvents.js +131 -0
- package/lib/telegram/TelegramEvents.js.map +1 -0
- package/lib/telegram/TelegramSendingController.d.ts +36 -0
- package/lib/telegram/TelegramSendingController.js +213 -0
- package/lib/telegram/TelegramSendingController.js.map +1 -0
- package/lib/telegram/TelegramToRompotConverter.d.ts +22 -0
- package/lib/telegram/TelegramToRompotConverter.js +226 -0
- package/lib/telegram/TelegramToRompotConverter.js.map +1 -0
- package/lib/telegram/TelegramUtils.d.ts +14 -0
- package/lib/telegram/TelegramUtils.js +98 -0
- package/lib/telegram/TelegramUtils.js.map +1 -0
- package/lib/telegram/index.d.ts +7 -0
- package/lib/telegram/index.js +19 -0
- package/lib/telegram/index.js.map +1 -0
- package/lib/utils/ClientUtils.d.ts +27 -0
- package/lib/utils/ClientUtils.js +62 -0
- package/lib/utils/ClientUtils.js.map +1 -0
- package/lib/utils/Generic.d.ts +47 -0
- package/lib/utils/Generic.js +173 -0
- package/lib/utils/Generic.js.map +1 -0
- package/lib/utils/Libs.d.ts +10 -0
- package/lib/utils/Libs.js +55 -0
- package/lib/utils/Libs.js.map +1 -0
- package/lib/utils/MessageHandler.d.ts +54 -0
- package/lib/utils/MessageHandler.js +81 -0
- package/lib/utils/MessageHandler.js.map +1 -0
- package/lib/utils/MessageUtils.d.ts +3 -0
- package/lib/utils/MessageUtils.js +114 -0
- package/lib/utils/MessageUtils.js.map +1 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +27 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/nonce.d.ts +1 -0
- package/lib/utils/nonce.js +16 -0
- package/lib/utils/nonce.js.map +1 -0
- package/lib/utils/server.d.ts +33 -0
- package/lib/utils/server.js +75 -0
- package/lib/utils/server.js.map +1 -0
- package/lib/wa/Auth.d.ts +19 -0
- package/lib/wa/Auth.js +123 -0
- package/lib/wa/Auth.js.map +1 -0
- package/lib/wa/ConfigWAEvents.d.ts +22 -0
- package/lib/wa/ConfigWAEvents.js +526 -0
- package/lib/wa/ConfigWAEvents.js.map +1 -0
- package/lib/wa/ConvertToWAMessage.d.ts +67 -0
- package/lib/wa/ConvertToWAMessage.js +403 -0
- package/lib/wa/ConvertToWAMessage.js.map +1 -0
- package/lib/wa/ConvertWAMessage.d.ts +108 -0
- package/lib/wa/ConvertWAMessage.js +527 -0
- package/lib/wa/ConvertWAMessage.js.map +1 -0
- package/lib/wa/ID.d.ts +4 -0
- package/lib/wa/ID.js +19 -0
- package/lib/wa/ID.js.map +1 -0
- package/lib/wa/WAMessage.d.ts +3 -0
- package/lib/wa/WAMessage.js +8 -0
- package/lib/wa/WAMessage.js.map +1 -0
- package/lib/wa/WAModule.d.ts +3 -0
- package/lib/wa/WAModule.js +3 -0
- package/lib/wa/WAModule.js.map +1 -0
- package/lib/wa/WAStatus.d.ts +3 -0
- package/lib/wa/WAStatus.js +15 -0
- package/lib/wa/WAStatus.js.map +1 -0
- package/lib/wa/WhatsAppBot.d.ts +188 -0
- package/lib/wa/WhatsAppBot.js +980 -0
- package/lib/wa/WhatsAppBot.js.map +1 -0
- package/lib/wa/index.d.ts +12 -0
- package/lib/wa/index.js +37 -0
- package/lib/wa/index.js.map +1 -0
- package/lib/wa/makeInMemoryStore.d.ts +43 -0
- package/lib/wa/makeInMemoryStore.js +430 -0
- package/lib/wa/makeInMemoryStore.js.map +1 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Laxeder
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
|
|
2
|
+
# trompot
|
|
3
|
+
|
|
4
|
+
Uma biblioteca para desenvolvimento de ChatBot multi-plataforma em JavaScript/TypeScript
|
|
5
|
+
|
|
6
|
+
Fork do projeto Rompot. Este repositório é mantido por TelksBr: https://github.com/TelksBr/trompot
|
|
7
|
+
|
|
8
|
+
## 🛠 Recursos
|
|
9
|
+
|
|
10
|
+
- [x] Simples uso
|
|
11
|
+
- [x] Criação de comandos
|
|
12
|
+
- [x] Resposta rápida
|
|
13
|
+
- [x] Tratamento de solicitações
|
|
14
|
+
- [x] Tratamento de conexão
|
|
15
|
+
- [x] Alta personalização
|
|
16
|
+
- [x] Suporte a Cluster (Beta)
|
|
17
|
+
|
|
18
|
+
| Plataformas | Whatsapp | Telegram (Beta) |
|
|
19
|
+
| ----------------------- | -------- | --------------- |
|
|
20
|
+
| Recebimento de mensagem | ✅ | ✅ |
|
|
21
|
+
| Envio de texto | ✅ | ✅ |
|
|
22
|
+
| Envio de mídia | ✅ | ✅ |
|
|
23
|
+
| Envio de stickers | ✅ | ✅ |
|
|
24
|
+
| Envio de lista | ❌ | ❌ |
|
|
25
|
+
| Envio de botão | ❌ | ✅ |
|
|
26
|
+
| Envio de enquete | ✅ | ✅ |
|
|
27
|
+
| Criação de chats | ✅ | 🔧 |
|
|
28
|
+
| Histórico de mensagens | ✅ | ❌ |
|
|
29
|
+
|
|
30
|
+
### 🔧 Instalação
|
|
31
|
+
|
|
32
|
+
Instalando pacote
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm i trompot
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Importando pacote
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// TypeScript
|
|
42
|
+
import Client, { WhatsAppBot, TelegramBot } from "trompot";
|
|
43
|
+
|
|
44
|
+
// Javascript
|
|
45
|
+
const { Client, WhatsAppBot, TelegramBot } = require("trompot");
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## WhatsApp
|
|
49
|
+
|
|
50
|
+
Após iniciar o bot um QR Code será emprimido no terminal, escane-o com seu WhatsApp para gerar uma nova conexão entre seu número e o Client. Essa conexão será guardada em `./path-to-auth`, para gerar uma nova delete-o ou se conecte com um novo caminho de sessão.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const client = new Client(new WhatsAppBot());
|
|
54
|
+
client.connect("./path-to-auth");
|
|
55
|
+
|
|
56
|
+
client.on("qr", (qr) => {
|
|
57
|
+
console.log("Scan QR:", qr);
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Parear código
|
|
62
|
+
|
|
63
|
+
Necessita passar um método de autenticação personalizado incluindo o número do bot a ser conectado.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import Client, { WhatsAppBot, MultiFileAuthState } from "trompot";
|
|
67
|
+
|
|
68
|
+
const client = new Client(new WhatsAppBot());
|
|
69
|
+
|
|
70
|
+
client.on("code", (code) => {
|
|
71
|
+
console.info("Código de pareamento gerado:", code);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const botPhoneNumber = "5511991234567";
|
|
75
|
+
|
|
76
|
+
const auth = new MultiFileAuthState("./path-to-auth", botPhoneNumber));
|
|
77
|
+
|
|
78
|
+
await client.connect(auth);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Telegram (Beta)
|
|
82
|
+
|
|
83
|
+
Altere o valor `BOT_TOKEN` para o token do seu bot para se conectar a ele, acaso não tenha consulte a documentação do [Telegram](https://core.telegram.org/bots/api) para gerar um.
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const client = new Client(new TelegramBot());
|
|
87
|
+
client.connect("BOT_TOKEN");
|
|
88
|
+
|
|
89
|
+
client.on("open", () => {
|
|
90
|
+
console.log("Bot conectado!");
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Configurações
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
type ConnectionConfig = {
|
|
98
|
+
/** Desativa execução do comando automático */
|
|
99
|
+
disableAutoCommand: boolean;
|
|
100
|
+
/** Desativa os comandos para mensagem antiga */
|
|
101
|
+
disableAutoCommandForOldMessage: boolean;
|
|
102
|
+
/** Desativa a execução do comando automático para mensagens não oficiais */
|
|
103
|
+
disableAutoCommandForUnofficialMessage: boolean;
|
|
104
|
+
/** Desativa a digitação automatica */
|
|
105
|
+
disableAutoTyping: boolean;
|
|
106
|
+
/** Desativa a leitura automatica de uma mensagem */
|
|
107
|
+
disableAutoRead: boolean;
|
|
108
|
+
/** Máximo de reconexões possíveis */
|
|
109
|
+
maxReconnectTimes: number;
|
|
110
|
+
/** Tempo de aguarde para se reconectar */
|
|
111
|
+
reconnectTimeout: number;
|
|
112
|
+
/** Máximo de tentativas de solitação acaso a primeira falhe */
|
|
113
|
+
maxRequests: number;
|
|
114
|
+
/** Tempo necessário de aguardo para próxima tentativa de solicitação */
|
|
115
|
+
requestsDelay: number;
|
|
116
|
+
/** Tempo máximo de espera */
|
|
117
|
+
maxTimeout: number;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
client.config = config;
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## ⚙️ Criando comandos
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { CMDKey, Command, Message } from "trompot";
|
|
127
|
+
|
|
128
|
+
// Cria um comando com o nome hello
|
|
129
|
+
// Ao ser executado envia a mensagem "Hello World!"
|
|
130
|
+
class HelloCommand extends Command {
|
|
131
|
+
public onRead() {
|
|
132
|
+
this.keys = [CMDKey("hello")];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public async onExec(message: Message) {
|
|
136
|
+
await message.reply(`Hello World!`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Listando comandos
|
|
141
|
+
const commands = [new HelloCommand(), new DateCommand()];
|
|
142
|
+
|
|
143
|
+
client.setCommands(commands);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Eventos
|
|
147
|
+
|
|
148
|
+
### Conexão
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
client.on("open", (open) => {
|
|
152
|
+
console.log("Cliente conectado!");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
client.on("close", (update) => {
|
|
156
|
+
console.info(`Cliente desconectou! Motivo: ${update.reason}`);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
client.on("stop", (update) => {
|
|
160
|
+
if (update.isLogout) {
|
|
161
|
+
console.info(`Cliente desligado!`);
|
|
162
|
+
} else {
|
|
163
|
+
console.info(`Cliente parado!`);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
client.on("connecting", (conn) => {
|
|
168
|
+
console.log("Conectando cliente...");
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
client.on("reconnecting", (conn) => {
|
|
172
|
+
console.log("Reconectando cliente...");
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Mensagem
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
client.on("message", (message) => {
|
|
180
|
+
console.log(`Mensagem recebida de "${message.user.name}"`);
|
|
181
|
+
|
|
182
|
+
if (message.text == "Oi") {
|
|
183
|
+
message.reply("Olá");
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Usuários
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
client.on("user", async (update) => {
|
|
192
|
+
if (update.action == "join") {
|
|
193
|
+
await client.send(new Message(update.chat, `@${update.fromUser.id} entrou no grupo.`));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (update.action == "leave") {
|
|
197
|
+
await client.send(new Message(update.chat, `@${update.fromUser.id} saiu do grupo...`));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (update.action == "add") {
|
|
201
|
+
await client.send(new Message(update.chat, `Membro @${update.fromUser.id} adicionou o @${update.user.id} ao grupo!`));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (update.action == "remove") {
|
|
205
|
+
client.send(new Message(update.chat, `Membro @${update.fromUser.id} removeu o @${update.user.id} do grupo.`));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (update.action == "promote") {
|
|
209
|
+
client.send(new Message(update.chat, `Membro @${update.fromUser.id} promoveu o @${update.user.id} para admin!`));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (update.action == "demote") {
|
|
213
|
+
await client.send(new Message(update.chat, `Membro @${update.fromUser.id} removeu o admin do @${update.user.id}.`));
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Erro interno
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
client.on("error", (err) => {
|
|
222
|
+
console.error(`Um erro ocorreu: ${err}`);
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Mensagem
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import { Message } from "trompot";
|
|
230
|
+
|
|
231
|
+
// Chat
|
|
232
|
+
const chat = new Chat("id12345");
|
|
233
|
+
|
|
234
|
+
// Criar mensagem
|
|
235
|
+
const msg = new Message(chat, "texto");
|
|
236
|
+
|
|
237
|
+
// Enviar mensagem
|
|
238
|
+
const saveMsg = await client.send(msg);
|
|
239
|
+
|
|
240
|
+
// Edita uma mensagem enviada
|
|
241
|
+
await client.editMessage(saveMsg, "novo texto");
|
|
242
|
+
|
|
243
|
+
// Mencionar usuário
|
|
244
|
+
msg.mentions.push("userId");
|
|
245
|
+
|
|
246
|
+
// Marcar mensagem
|
|
247
|
+
msg.mention = message;
|
|
248
|
+
|
|
249
|
+
// Responder mensagem
|
|
250
|
+
msg.reply(message);
|
|
251
|
+
|
|
252
|
+
// Visualiza uma mensagem recebida
|
|
253
|
+
msg.read();
|
|
254
|
+
|
|
255
|
+
// Reage a mensagem
|
|
256
|
+
msg.addReaction("❤");
|
|
257
|
+
|
|
258
|
+
// Remove a reação de uma mensagem
|
|
259
|
+
msg.removeReaction();
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Mensagem de mídia
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { ImageMessage, VideoMessage, AudioMessage, FileMessage, StickerMessage } from "trompot";
|
|
266
|
+
|
|
267
|
+
// Criar mensagem de audio
|
|
268
|
+
const audioMessage = new AudioMessage(chat, Buffer.from(""));
|
|
269
|
+
|
|
270
|
+
// Criar mensagem com imagem
|
|
271
|
+
const imageMessage = new ImageMessage(chat, "texto", Buffer.from(""));
|
|
272
|
+
|
|
273
|
+
// Criar mensagem com video
|
|
274
|
+
const videoMessage = new VideoMessage(chat, "texto", Buffer.from(""));
|
|
275
|
+
|
|
276
|
+
// Criar mensagem de arquivo
|
|
277
|
+
const fileMessage = new FileMessage(chat, "texto", Buffer.from(""));
|
|
278
|
+
|
|
279
|
+
// Criar mensagem de sticker
|
|
280
|
+
const stickerMessage = new StickerMessage(chat, Buffer.from(""));
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Outros tipos de mensagem
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import { LocationMessage, ContactMessage, ButtonMessage, ListMessage, PollMessage } from "trompot";
|
|
287
|
+
|
|
288
|
+
// Criar mensagem de localiação
|
|
289
|
+
// Latitude, Longitude
|
|
290
|
+
const locationMessage = new LocationMessage(chat, 24.121231, 55.1121221);
|
|
291
|
+
|
|
292
|
+
// Obter dados do endereço da localização
|
|
293
|
+
const address = await locationMessage.getAddress();
|
|
294
|
+
|
|
295
|
+
// Criar mensagem com contatos
|
|
296
|
+
const contactMessage = new ContactMessage(chat, "nome", "userId");
|
|
297
|
+
|
|
298
|
+
// Criando botões
|
|
299
|
+
const btnMessage = new ButtonMessage(chat, "texto", "rodapé");
|
|
300
|
+
btnMessage.addCall("Call", "1234567890");
|
|
301
|
+
btnMessage.addUrl("Link", "https://example.com");
|
|
302
|
+
btnMessage.addReply("Texto", "button-id-123");
|
|
303
|
+
|
|
304
|
+
// Criar lista
|
|
305
|
+
const listMessage = new ListMessage(chat, "texto", "botão", "titulo", "rodapé");
|
|
306
|
+
const index1 = listMessage.addCategory("Categoria 1");
|
|
307
|
+
const index2 = listMessage.addCategory("Categoria 2");
|
|
308
|
+
|
|
309
|
+
listMessage.addItem(index1, "Item 1");
|
|
310
|
+
listMessage.addItem(index1, "Item 2");
|
|
311
|
+
|
|
312
|
+
listMessage.addItem(index2, "Abc 1");
|
|
313
|
+
listMessage.addItem(index2, "Abc 2");
|
|
314
|
+
|
|
315
|
+
// Criar enquete
|
|
316
|
+
const pollMessage = new PollMessage(chat, "Hello World!");
|
|
317
|
+
|
|
318
|
+
pollMessage.addOption("Hello", "id-hello-123");
|
|
319
|
+
pollMessage.addOption("Hey", "id-hey-123");
|
|
320
|
+
pollMessage.addOption("Hi", "id-hi-123");
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Mensagem personalizada
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import { CustomMessage } from "trompot";
|
|
327
|
+
|
|
328
|
+
// Ex: conteúdo para baileys
|
|
329
|
+
const content = { text: "texto" };
|
|
330
|
+
|
|
331
|
+
// O conteúdo inserido será enviado diretamente para a plataforma
|
|
332
|
+
const customMessage = new CustomMessage(chat, content);
|
|
333
|
+
|
|
334
|
+
// Adicionando opções adicionais
|
|
335
|
+
// Essas alterações serão tratadas pelo processamento da plataforma
|
|
336
|
+
|
|
337
|
+
//? Na baileys utiliza o relayMessage invés de sendMessage
|
|
338
|
+
customMessage.extra = { isRelay: true };
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Lendo resposas de ButtonMessage, ListMessage e PollMessage
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
import { Command, Message, CMDKey, CMDRunType, isPollMessage } from "trompot";
|
|
345
|
+
|
|
346
|
+
class ButtonCommand extends Command {
|
|
347
|
+
public onRead() {
|
|
348
|
+
this.keys = [CMDKey("cmd-button")];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Recebe uma resposta ao comando
|
|
352
|
+
public async onReply(message: Message) {
|
|
353
|
+
await message.reply(`Button Clicked!`);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
client.addCommand(new ButtonCommand());
|
|
358
|
+
|
|
359
|
+
client.on("message", async (message: Message) => {
|
|
360
|
+
if (isPollMessage(message)) {
|
|
361
|
+
// Não responde caso a votação da enquete for removida
|
|
362
|
+
if (message.action == "remove") return;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Verifica o ID passado na mensagem como opção
|
|
366
|
+
if (message.selected == "button-id-123") {
|
|
367
|
+
const cmd = client.getCommand("cmd-button");
|
|
368
|
+
|
|
369
|
+
// Manda a resposta ao comando
|
|
370
|
+
if (cmd) client.runCommand(cmd, message, CMDRunType.Reply);
|
|
371
|
+
}
|
|
372
|
+
}):
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Bot
|
|
376
|
+
|
|
377
|
+
- Definir foto de perfil
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
client.setBotProfile(Buffer.from(""));
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
- Obter foto de perfil do bot
|
|
384
|
+
|
|
385
|
+
```ts
|
|
386
|
+
client.getBotProfile();
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
- Definir nome do bot
|
|
390
|
+
|
|
391
|
+
```ts
|
|
392
|
+
client.setBotName("Name");
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
- Definir descrição do bot
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
client.setBotDescription("Description");
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
- Obter descrição do bot
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
client.getBotDescription();
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Grupo
|
|
408
|
+
|
|
409
|
+
Você pode obter o chat em `message.chat` ou `client.getChat("id")`, o ID pode ser encontrado em `message.chat.id`
|
|
410
|
+
|
|
411
|
+
- Criar grupo
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
client.createChat("name");
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
- Sair de um grupo
|
|
418
|
+
|
|
419
|
+
```ts
|
|
420
|
+
client.leaveChat(chat);
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
- Definir imagem do grupo
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
client.setChatProfile(chat, Buffer.from(""));
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
- Obter imagem do grupo
|
|
430
|
+
|
|
431
|
+
```ts
|
|
432
|
+
client.getChatProfile(chat);
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
- Definir nome do grupo
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
client.setChatName(chat, "Name chat");
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
- Obter nome do grupo
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
client.getChatName(chat);
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
- Definir a descrição do grupo
|
|
448
|
+
|
|
449
|
+
```ts
|
|
450
|
+
client.setChatDescription(chat, "Chat description");
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
- Obter descrição do grupo
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
client.getChatDescription(chat);
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
- Adicionar membro
|
|
460
|
+
- Você pode encontrar o user em `message.user`, o ID pode se encontrado em `message.user.id`
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
client.addUserInChat(chat, user);
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
- Remover membro
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
client.removeUserInChat(chat, user);
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
- Promover membro
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
client.promoteUserInChat(chat, user);
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
- Despromover membro
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
client.demoteUserInChat(chat, user);
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
- Rejeitar chamada
|
|
485
|
+
- Você pode receber a chamada pelo evento `new-call` ou `call`, porém o evento `call` também recebe atualização de chamadas invez de somente o pedido dela.
|
|
486
|
+
```ts
|
|
487
|
+
client.rejectCall(call);
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
## Utilitários de Estado do App e Recursos de Negócio (WhatsAppBot)
|
|
491
|
+
|
|
492
|
+
A partir da versão mais recente, o WhatsAppBot oferece métodos utilitários para manipular o estado dos chats e acessar recursos de negócio do WhatsApp Business. Veja exemplos abaixo:
|
|
493
|
+
|
|
494
|
+
### App State Updates
|
|
495
|
+
|
|
496
|
+
- **Arquivar um chat**
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
// Arquiva um chat
|
|
500
|
+
await client.bot.archiveChat(chat, true, lastMessages);
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
- **Silenciar um chat**
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
// Silencia um chat por 1 hora (em segundos)
|
|
507
|
+
await client.bot.muteChat(chat, 3600, lastMessages);
|
|
508
|
+
// Para remover o silêncio:
|
|
509
|
+
await client.bot.muteChat(chat, null, lastMessages);
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
- **Marcar chat como lido**
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
// Marca o chat como lido
|
|
516
|
+
await client.bot.markChatRead(chat, true, lastMessages);
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
- **Ativar mensagens temporárias**
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
// Define o chat para mensagens temporárias (em segundos)
|
|
523
|
+
await client.bot.setDisappearingMessages(chat, 86400); // 24 horas
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
> **Nota:** O parâmetro `lastMessages` é obrigatório e deve ser um array com as últimas mensagens do chat, conforme exigido pela API do Baileys.
|
|
527
|
+
|
|
528
|
+
### Business Features
|
|
529
|
+
|
|
530
|
+
- **Obter perfil de negócio**
|
|
531
|
+
|
|
532
|
+
```ts
|
|
533
|
+
// Busca o perfil de negócio de um usuário ou grupo
|
|
534
|
+
const profile = await client.bot.fetchBusinessProfile(chat.id);
|
|
535
|
+
console.log(profile);
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
> **Nota:** O método `fetchBusinessProducts` foi removido pois não está disponível na API pública do Baileys.
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
O envio de botões interativos é suportado no Telegram usando o tipo `ButtonMessage`. Veja um exemplo:
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
import { ButtonMessage } from "trompot";
|
|
545
|
+
|
|
546
|
+
const chat = new Chat("id_do_chat");
|
|
547
|
+
const btnMsg = new ButtonMessage(chat, "Escolha uma opção:", "Rodapé opcional");
|
|
548
|
+
|
|
549
|
+
btnMsg.addReply("Botão 1", "resposta_1");
|
|
550
|
+
btnMsg.addUrl("Site", "https://exemplo.com");
|
|
551
|
+
btnMsg.addCall("Ligar", "5511999999999");
|
|
552
|
+
|
|
553
|
+
await client.send(btnMsg);
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
- Botões do tipo `Reply` são enviados como botões de callback.
|
|
557
|
+
- Botões do tipo `Url` abrem um link.
|
|
558
|
+
- Botões do tipo `Call` abrem o discador do telefone (se suportado pelo Telegram).
|
|
559
|
+
|
|
560
|
+
O recebimento do clique em botões de callback pode ser tratado usando os eventos do Telegram.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import ReactionMessage from '../messages/ReactionMessage';
|
|
2
|
+
import { Media } from '../messages/MediaMessage';
|
|
3
|
+
import ChatStatus from '../modules/chat/ChatStatus';
|
|
4
|
+
import Message from '../messages/Message';
|
|
5
|
+
import { BotStatus } from './BotStatus';
|
|
6
|
+
import IAuth from '../client/IAuth';
|
|
7
|
+
import BotEvents from './BotEvents';
|
|
8
|
+
import Chat from '../modules/chat/Chat';
|
|
9
|
+
import User from '../modules/user/User';
|
|
10
|
+
import IBot from './IBot';
|
|
11
|
+
import Call from '../models/Call';
|
|
12
|
+
export default class BotBase extends BotEvents implements IBot {
|
|
13
|
+
id: string;
|
|
14
|
+
status: BotStatus;
|
|
15
|
+
phoneNumber: string;
|
|
16
|
+
name: string;
|
|
17
|
+
profileUrl: string;
|
|
18
|
+
connect(auth: IAuth): Promise<void>;
|
|
19
|
+
reconnect(alert?: boolean): Promise<void>;
|
|
20
|
+
stop(reason: any): Promise<void>;
|
|
21
|
+
logout(): Promise<void>;
|
|
22
|
+
send(message: Message): Promise<Message>;
|
|
23
|
+
sendMessage(chat: Chat | string, message: string | Message, mention?: Message): Promise<Message>;
|
|
24
|
+
editMessage(message: Message): Promise<void>;
|
|
25
|
+
addReaction(message: ReactionMessage): Promise<void>;
|
|
26
|
+
removeReaction(message: ReactionMessage): Promise<void>;
|
|
27
|
+
readMessage(message: Message): Promise<void>;
|
|
28
|
+
removeMessage(message: Message): Promise<void>;
|
|
29
|
+
deleteMessage(message: Message): Promise<void>;
|
|
30
|
+
downloadStreamMessage(media: Media): Promise<Buffer>;
|
|
31
|
+
getBotName(): Promise<string>;
|
|
32
|
+
setBotName(name: string): Promise<void>;
|
|
33
|
+
getBotDescription(): Promise<string>;
|
|
34
|
+
setBotDescription(description: string): Promise<void>;
|
|
35
|
+
getBotProfile(lowQuality?: boolean): Promise<Buffer>;
|
|
36
|
+
getBotProfileUrl(lowQuality?: boolean): Promise<string>;
|
|
37
|
+
setBotProfile(image: Buffer): Promise<void>;
|
|
38
|
+
getChats(): Promise<string[]>;
|
|
39
|
+
setChats(chats: Chat[]): Promise<void>;
|
|
40
|
+
getChat(chat: Chat): Promise<Chat | null>;
|
|
41
|
+
updateChat(chat: {
|
|
42
|
+
id: string;
|
|
43
|
+
} & Partial<Chat>): Promise<void>;
|
|
44
|
+
removeChat(chat: Chat): Promise<void>;
|
|
45
|
+
createChat(chat: Chat): Promise<void>;
|
|
46
|
+
leaveChat(chat: Chat): Promise<void>;
|
|
47
|
+
addUserInChat(chat: Chat, user: User): Promise<void>;
|
|
48
|
+
removeUserInChat(chat: Chat, user: User): Promise<void>;
|
|
49
|
+
promoteUserInChat(chat: Chat, user: User): Promise<void>;
|
|
50
|
+
demoteUserInChat(chat: Chat, user: User): Promise<void>;
|
|
51
|
+
changeChatStatus(chat: Chat, status: ChatStatus): Promise<void>;
|
|
52
|
+
getChatUsers(chat: Chat): Promise<string[]>;
|
|
53
|
+
getChatAdmins(chat: Chat): Promise<string[]>;
|
|
54
|
+
getChatLeader(chat: Chat): Promise<string>;
|
|
55
|
+
getChatName(chat: Chat): Promise<string>;
|
|
56
|
+
setChatName(chat: Chat, name: string): Promise<void>;
|
|
57
|
+
getChatDescription(chat: Chat): Promise<string>;
|
|
58
|
+
setChatDescription(chat: Chat, description: string): Promise<void>;
|
|
59
|
+
getChatProfile(chat: Chat, lowQuality?: boolean): Promise<Buffer>;
|
|
60
|
+
getChatProfileUrl(chat: Chat, lowQuality?: boolean): Promise<string>;
|
|
61
|
+
setChatProfile(chat: Chat, profile: Buffer): Promise<void>;
|
|
62
|
+
joinChat(code: string): Promise<void>;
|
|
63
|
+
getChatInvite(chat: Chat): Promise<string>;
|
|
64
|
+
revokeChatInvite(chat: Chat): Promise<string>;
|
|
65
|
+
rejectCall(call: Call): Promise<void>;
|
|
66
|
+
getUsers(): Promise<string[]>;
|
|
67
|
+
setUsers(users: User[]): Promise<void>;
|
|
68
|
+
getUser(user: User): Promise<User | null>;
|
|
69
|
+
updateUser(user: {
|
|
70
|
+
id: string;
|
|
71
|
+
} & Partial<User>): Promise<void>;
|
|
72
|
+
removeUser(user: User): Promise<void>;
|
|
73
|
+
unblockUser(user: User): Promise<void>;
|
|
74
|
+
blockUser(user: User): Promise<void>;
|
|
75
|
+
getUserName(user: User): Promise<string>;
|
|
76
|
+
setUserName(user: User, name: string): Promise<void>;
|
|
77
|
+
getUserDescription(user: User): Promise<string>;
|
|
78
|
+
setUserDescription(user: User, description: string): Promise<void>;
|
|
79
|
+
getUserProfile(user: User): Promise<Buffer>;
|
|
80
|
+
getUserProfileUrl(user: User, lowQuality?: boolean): Promise<string>;
|
|
81
|
+
setUserProfile(user: User, profile: Buffer): Promise<void>;
|
|
82
|
+
}
|