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
|
@@ -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.ChatStatus = exports.ChatType = exports.Chat = void 0;
|
|
7
|
+
const ChatStatus_1 = __importDefault(require("./ChatStatus"));
|
|
8
|
+
exports.ChatStatus = ChatStatus_1.default;
|
|
9
|
+
const ChatType_1 = __importDefault(require("./ChatType"));
|
|
10
|
+
exports.ChatType = ChatType_1.default;
|
|
11
|
+
const Chat_1 = __importDefault(require("./Chat"));
|
|
12
|
+
exports.Chat = Chat_1.default;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/chat/index.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAsC;AAID,qBAJ9B,oBAAU,CAI8B;AAH/C,0DAAkC;AAGnB,mBAHR,kBAAQ,CAGQ;AAFvB,kDAA0B;AAEjB,eAFF,cAAI,CAEE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import ICommandControllerConfig from './ICommandControllerConfig';
|
|
2
|
+
import CommandPermission from './CommandPermission';
|
|
3
|
+
import Message from '../../messages/Message';
|
|
4
|
+
import CommandKey from './CommandKey';
|
|
5
|
+
/** Permissões do comando */
|
|
6
|
+
export declare enum CMDPerms {
|
|
7
|
+
/** Permitido apenas ser executado no pv */
|
|
8
|
+
ChatPv = "chat-pv",
|
|
9
|
+
/** Permitido apenas ser executado em grupos */
|
|
10
|
+
ChatGroup = "chat-group",
|
|
11
|
+
/** Permitido apenas se o usuário for admin do chat */
|
|
12
|
+
UserChatAdmin = "chat-admin",
|
|
13
|
+
/** Permitido apenas se o usuário for líder do chat */
|
|
14
|
+
UserChatLeader = "chat-leader",
|
|
15
|
+
/** Permitido apenas se o bot for admin do chat */
|
|
16
|
+
BotChatAdmin = "bot-chat-admin",
|
|
17
|
+
/** Permitido apenas se o bot for líder do chat */
|
|
18
|
+
BotChatLeader = "bot-chat-leader"
|
|
19
|
+
}
|
|
20
|
+
export type CommandControllerEventsMap = {
|
|
21
|
+
/** Permissão negada */
|
|
22
|
+
['no-allowed']: {
|
|
23
|
+
message: Message;
|
|
24
|
+
command: Command;
|
|
25
|
+
permission: CommandPermission;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default class Command {
|
|
29
|
+
/** Chaves do comando */
|
|
30
|
+
keys: CommandKey[];
|
|
31
|
+
/** Permissões necessárias do comando */
|
|
32
|
+
permissions: string[];
|
|
33
|
+
/** ID do bot associado ao comando */
|
|
34
|
+
botId: string;
|
|
35
|
+
/** ID do client associado ao comando */
|
|
36
|
+
clientId: string;
|
|
37
|
+
/** Verifica se o comando pode ser executado
|
|
38
|
+
* @param message Mensagem que está executando o comando
|
|
39
|
+
*/
|
|
40
|
+
checkPerms(message: Message): Promise<CommandPermission | null>;
|
|
41
|
+
/** Quando o comando está sendo procurado
|
|
42
|
+
* @param text Texto que será verificado se incluí o comando
|
|
43
|
+
* @param config Configuração do controlador de comando
|
|
44
|
+
*/
|
|
45
|
+
onSearch(text: string, config: ICommandControllerConfig): CommandKey | null;
|
|
46
|
+
/** Quando o comando é lido */
|
|
47
|
+
onRead(): any;
|
|
48
|
+
/** Configuração do comando
|
|
49
|
+
* @param message Mensagem que está executando o comando
|
|
50
|
+
*/
|
|
51
|
+
onConfig(): any;
|
|
52
|
+
/** Execução do comando
|
|
53
|
+
* @param message Mensagem que está executando o comando
|
|
54
|
+
*/
|
|
55
|
+
onExec(message: Message): any;
|
|
56
|
+
/** Respota ao comando
|
|
57
|
+
* @param message Mensagem que está executando o comando
|
|
58
|
+
*/
|
|
59
|
+
onReply(message: Message): any;
|
|
60
|
+
static readCommands(dir: string): Promise<Command[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Verifica se um objeto é uma instância válida de Command.
|
|
63
|
+
* @param message - O objeto a ser verificado.
|
|
64
|
+
* @returns Verdadeiro se o objeto for uma instância válida de Command, caso contrário, falso.
|
|
65
|
+
*/
|
|
66
|
+
static isValid(command: any): command is Command;
|
|
67
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const Generic_1 = require("../../utils/Generic");
|
|
40
|
+
const CommandPermission_1 = __importDefault(require("./CommandPermission"));
|
|
41
|
+
const CommandKey_1 = __importDefault(require("./CommandKey"));
|
|
42
|
+
const perms_1 = require("./perms");
|
|
43
|
+
class Command {
|
|
44
|
+
constructor() {
|
|
45
|
+
/** Chaves do comando */
|
|
46
|
+
this.keys = [];
|
|
47
|
+
/** Permissões necessárias do comando */
|
|
48
|
+
this.permissions = [];
|
|
49
|
+
/** ID do bot associado ao comando */
|
|
50
|
+
this.botId = '';
|
|
51
|
+
/** ID do client associado ao comando */
|
|
52
|
+
this.clientId = '';
|
|
53
|
+
}
|
|
54
|
+
/** Verifica se o comando pode ser executado
|
|
55
|
+
* @param message Mensagem que está executando o comando
|
|
56
|
+
*/
|
|
57
|
+
async checkPerms(message) {
|
|
58
|
+
const permissions = [];
|
|
59
|
+
await Promise.all(this.permissions.map(async (permission) => {
|
|
60
|
+
const perm = (0, perms_1.CMDPerm)(permission);
|
|
61
|
+
if (!(await CommandPermission_1.default.check(message, perm))) {
|
|
62
|
+
perm.isPermited = false;
|
|
63
|
+
permissions.push(perm);
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
if (permissions.length > 0)
|
|
67
|
+
return permissions[0];
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
/** Quando o comando está sendo procurado
|
|
71
|
+
* @param text Texto que será verificado se incluí o comando
|
|
72
|
+
* @param config Configuração do controlador de comando
|
|
73
|
+
*/
|
|
74
|
+
onSearch(text, config) {
|
|
75
|
+
return CommandKey_1.default.search(text, config, ...this.keys);
|
|
76
|
+
}
|
|
77
|
+
/** Quando o comando é lido */
|
|
78
|
+
onRead() { }
|
|
79
|
+
/** Configuração do comando
|
|
80
|
+
* @param message Mensagem que está executando o comando
|
|
81
|
+
*/
|
|
82
|
+
onConfig() { }
|
|
83
|
+
/** Execução do comando
|
|
84
|
+
* @param message Mensagem que está executando o comando
|
|
85
|
+
*/
|
|
86
|
+
onExec(message) { }
|
|
87
|
+
/** Respota ao comando
|
|
88
|
+
* @param message Mensagem que está executando o comando
|
|
89
|
+
*/
|
|
90
|
+
onReply(message) { }
|
|
91
|
+
static async readCommands(dir) {
|
|
92
|
+
const commands = [];
|
|
93
|
+
await (0, Generic_1.readRecursiveDir)(dir, async (filepath, filename, ext) => {
|
|
94
|
+
try {
|
|
95
|
+
if (ext != '.ts' && ext != '.js')
|
|
96
|
+
return;
|
|
97
|
+
const content = await Promise.resolve(`${filepath}`).then(s => __importStar(require(s)));
|
|
98
|
+
if (!content)
|
|
99
|
+
return;
|
|
100
|
+
if (typeof content != 'object')
|
|
101
|
+
return;
|
|
102
|
+
const keys = Object.keys(content);
|
|
103
|
+
await Promise.all(keys.map(async (key) => {
|
|
104
|
+
try {
|
|
105
|
+
const data = content[key];
|
|
106
|
+
if (!data)
|
|
107
|
+
return;
|
|
108
|
+
if (Command.isValid(data)) {
|
|
109
|
+
await data.onRead();
|
|
110
|
+
commands.push(data);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
//@ts-ignore
|
|
114
|
+
const cmd = new data();
|
|
115
|
+
if (Command.isValid(cmd)) {
|
|
116
|
+
await cmd.onRead();
|
|
117
|
+
commands.push(cmd);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (_a) { }
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
catch (_a) { }
|
|
125
|
+
});
|
|
126
|
+
return commands;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Verifica se um objeto é uma instância válida de Command.
|
|
130
|
+
* @param message - O objeto a ser verificado.
|
|
131
|
+
* @returns Verdadeiro se o objeto for uma instância válida de Command, caso contrário, falso.
|
|
132
|
+
*/
|
|
133
|
+
static isValid(command) {
|
|
134
|
+
return (typeof command === 'object' &&
|
|
135
|
+
Object.keys(new Command()).every((key) => key in command));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.default = Command;
|
|
139
|
+
//# sourceMappingURL=Command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../src/modules/command/Command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAuD;AACvD,4EAAoD;AAEpD,8DAAsC;AACtC,mCAAkC;AA2BlC,MAAqB,OAAO;IAA5B;QACE,wBAAwB;QACjB,SAAI,GAAiB,EAAE,CAAC;QAC/B,wCAAwC;QACjC,gBAAW,GAAa,EAAE,CAAC;QAClC,qCAAqC;QAC9B,UAAK,GAAW,EAAE,CAAC;QAC1B,wCAAwC;QACjC,aAAQ,GAAW,EAAE,CAAC;IA6G/B,CAAC;IA3GC;;OAEG;IACI,KAAK,CAAC,UAAU,CAAC,OAAgB;QACtC,MAAM,WAAW,GAAwB,EAAE,CAAC;QAE5C,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;YACxC,MAAM,IAAI,GAAG,IAAA,eAAO,EAAC,UAAU,CAAC,CAAC;YAEjC,IAAI,CAAC,CAAC,MAAM,2BAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;gBACpD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBAExB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC,CACH,CAAC;QAEF,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;QAElD,OAAO,IAAI,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C;4BACN,YAAY;4BACZ,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;4BAEvB,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gCACzB,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;gCAEnB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BACrB,CAAC;wBACH,CAAC;oBACH,CAAC;oBAAC,WAAM,CAAC,CAAA,CAAC;gBACZ,CAAC,CAAC,CACH,CAAC;YACJ,CAAC;YAAC,WAAM,CAAC,CAAA,CAAC;QACZ,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAO,CAAC,OAAY;QAChC,OAAO,CACL,OAAO,OAAO,KAAK,QAAQ;YAC3B,MAAM,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,OAAO,CAAC,CAC1D,CAAC;IACJ,CAAC;CACF;AArHD,0BAqHC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import ICommandControllerConfig from "./ICommandControllerConfig";
|
|
2
|
+
import CommandControllerEvent from "./CommandControllerEvent";
|
|
3
|
+
import Message from "../../messages/Message";
|
|
4
|
+
import Command from "./Command";
|
|
5
|
+
export default class CommandController extends CommandControllerEvent {
|
|
6
|
+
/** Configuração do controlador */
|
|
7
|
+
config: ICommandControllerConfig;
|
|
8
|
+
/** Comandos */
|
|
9
|
+
commands: Command[];
|
|
10
|
+
/** ID do bot associado ao controlador de comandos */
|
|
11
|
+
botId: string;
|
|
12
|
+
/** ID do client associado ao controlador de comandos */
|
|
13
|
+
clientId: string;
|
|
14
|
+
constructor(config?: Partial<ICommandControllerConfig>);
|
|
15
|
+
/** Define os comandos
|
|
16
|
+
* @param commands Novos comandos
|
|
17
|
+
* */
|
|
18
|
+
setCommands(commands: Command[]): void;
|
|
19
|
+
/** @retuns Retorna os comandos */
|
|
20
|
+
getCommands(): Command[];
|
|
21
|
+
/** Adiciona um comando
|
|
22
|
+
* @param command Novo comando
|
|
23
|
+
*/
|
|
24
|
+
addCommand(command: Command): void;
|
|
25
|
+
/**
|
|
26
|
+
* Remove um comando
|
|
27
|
+
* @param command Comando que será removido
|
|
28
|
+
* */
|
|
29
|
+
removeCommand(command: Command): boolean;
|
|
30
|
+
/** Busca pelo comando
|
|
31
|
+
* @param text Texto onde será verificado se inclui o comando
|
|
32
|
+
*/
|
|
33
|
+
searchCommand(text: string): Command | null;
|
|
34
|
+
/** Execução do comando
|
|
35
|
+
* @param command Comando que será executado
|
|
36
|
+
* @param message Mensagem que chamou o comando
|
|
37
|
+
* @param type Tipo da execução doo comando
|
|
38
|
+
*/
|
|
39
|
+
runCommand(command: Command, message: Message, type?: string): Promise<any>;
|
|
40
|
+
/** Executa o comando
|
|
41
|
+
* @param message Mensagem que chamou o comando
|
|
42
|
+
* @param command Comando que será executado
|
|
43
|
+
*/
|
|
44
|
+
execCommand(message: Message, command: Command): Promise<any>;
|
|
45
|
+
/** Resposta ao comando
|
|
46
|
+
* @param message Mensagem que chamou o comando
|
|
47
|
+
* @param command Comando que receberá a resposta
|
|
48
|
+
*/
|
|
49
|
+
replyCommand(message: Message, command: Command): Promise<any>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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 defaults_1 = require("./defaults");
|
|
7
|
+
const CommandControllerEvent_1 = __importDefault(require("./CommandControllerEvent"));
|
|
8
|
+
const CommandEnums_1 = require("./CommandEnums");
|
|
9
|
+
class CommandController extends CommandControllerEvent_1.default {
|
|
10
|
+
constructor(config = {}) {
|
|
11
|
+
super();
|
|
12
|
+
/** Comandos */
|
|
13
|
+
this.commands = [];
|
|
14
|
+
/** ID do bot associado ao controlador de comandos */
|
|
15
|
+
this.botId = "";
|
|
16
|
+
/** ID do client associado ao controlador de comandos */
|
|
17
|
+
this.clientId = "";
|
|
18
|
+
this.config = { ...defaults_1.DEFAULT_COMMAND_CONTROLLER_CONFIG, ...config };
|
|
19
|
+
}
|
|
20
|
+
/** Define os comandos
|
|
21
|
+
* @param commands Novos comandos
|
|
22
|
+
* */
|
|
23
|
+
setCommands(commands) {
|
|
24
|
+
const cmds = [];
|
|
25
|
+
for (const command of commands) {
|
|
26
|
+
command.clientId = this.clientId;
|
|
27
|
+
command.botId = this.botId;
|
|
28
|
+
cmds.push(command);
|
|
29
|
+
}
|
|
30
|
+
this.commands = cmds;
|
|
31
|
+
}
|
|
32
|
+
/** @retuns Retorna os comandos */
|
|
33
|
+
getCommands() {
|
|
34
|
+
return this.commands;
|
|
35
|
+
}
|
|
36
|
+
/** Adiciona um comando
|
|
37
|
+
* @param command Novo comando
|
|
38
|
+
*/
|
|
39
|
+
addCommand(command) {
|
|
40
|
+
command.clientId = this.clientId;
|
|
41
|
+
command.botId = this.botId;
|
|
42
|
+
this.commands.push(command);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Remove um comando
|
|
46
|
+
* @param command Comando que será removido
|
|
47
|
+
* */
|
|
48
|
+
removeCommand(command) {
|
|
49
|
+
const commands = [];
|
|
50
|
+
const commandKeys = command.keys.map((key) => key.values.join("")).join("");
|
|
51
|
+
for (const cmd of this.commands) {
|
|
52
|
+
const keys = cmd.keys.map((key) => key.values.join("")).join("");
|
|
53
|
+
if (keys == commandKeys)
|
|
54
|
+
continue;
|
|
55
|
+
commands.push(cmd);
|
|
56
|
+
}
|
|
57
|
+
if (this.commands.length == commands.length)
|
|
58
|
+
return false;
|
|
59
|
+
this.commands = commands;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/** Busca pelo comando
|
|
63
|
+
* @param text Texto onde será verificado se inclui o comando
|
|
64
|
+
*/
|
|
65
|
+
searchCommand(text) {
|
|
66
|
+
const commands = [];
|
|
67
|
+
for (const command of this.commands) {
|
|
68
|
+
const key = command.onSearch(`${text}`, this.config);
|
|
69
|
+
if (key != null) {
|
|
70
|
+
commands.push({ key, command });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let commandResult = null;
|
|
74
|
+
for (const { key, command } of commands) {
|
|
75
|
+
if (commandResult == null) {
|
|
76
|
+
commandResult = { key, command };
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (key.values.join("").length > commandResult.key.values.join("").length) {
|
|
80
|
+
commandResult = { key, command };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (commandResult == null)
|
|
84
|
+
return null;
|
|
85
|
+
return commandResult.command;
|
|
86
|
+
}
|
|
87
|
+
/** Execução do comando
|
|
88
|
+
* @param command Comando que será executado
|
|
89
|
+
* @param message Mensagem que chamou o comando
|
|
90
|
+
* @param type Tipo da execução doo comando
|
|
91
|
+
*/
|
|
92
|
+
async runCommand(command, message, type = CommandEnums_1.CMDRunType.Exec) {
|
|
93
|
+
const permission = await command.checkPerms(message);
|
|
94
|
+
if (permission != null && !permission.isPermited) {
|
|
95
|
+
this.emit("no-allowed", { message, command, permission });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (type == CommandEnums_1.CMDRunType.Reply) {
|
|
99
|
+
return await this.replyCommand(message, command);
|
|
100
|
+
}
|
|
101
|
+
return this.execCommand(message, command);
|
|
102
|
+
}
|
|
103
|
+
/** Executa o comando
|
|
104
|
+
* @param message Mensagem que chamou o comando
|
|
105
|
+
* @param command Comando que será executado
|
|
106
|
+
*/
|
|
107
|
+
async execCommand(message, command) {
|
|
108
|
+
return await command.onExec(message);
|
|
109
|
+
}
|
|
110
|
+
/** Resposta ao comando
|
|
111
|
+
* @param message Mensagem que chamou o comando
|
|
112
|
+
* @param command Comando que receberá a resposta
|
|
113
|
+
*/
|
|
114
|
+
async replyCommand(message, command) {
|
|
115
|
+
return await command.onReply(message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.default = CommandController;
|
|
119
|
+
//# sourceMappingURL=CommandController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandController.js","sourceRoot":"","sources":["../../../src/modules/command/CommandController.ts"],"names":[],"mappings":";;;;;AACA,yCAA+D;AAC/D,sFAA8D;AAC9D,iDAA4C;AAK5C,MAAqB,iBAAkB,SAAQ,gCAAsB;IAUnE,YAAY,SAA4C,EAAE;QACxD,KAAK,EAAE,CAAC;QARV,eAAe;QACR,aAAQ,GAAc,EAAE,CAAC;QAChC,qDAAqD;QAC9C,UAAK,GAAW,EAAE,CAAC;QAC1B,wDAAwD;QACjD,aAAQ,GAAW,EAAE,CAAC;QAK3B,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,4CAAiC,EAAE,GAAG,MAAM,EAAE,CAAC;IACpE,CAAC;IAED;;SAEK;IACE,WAAW,CAAC,QAAmB;QACpC,MAAM,IAAI,GAAc,EAAE,CAAC;QAE3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YACjC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAE3B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,kCAAkC;IAC3B,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,UAAU,CAAC,OAAgB;QAChC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QACjC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAE3B,IAAI,CAAC,QA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M,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,YAAY,CAAC,OAAgB,EAAE,OAAgB;QAC1D,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;CACF;AAzID,oCAyIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import EventEmitter from "events";
|
|
2
|
+
import { CommandControllerEventsMap } from "./Command";
|
|
3
|
+
export default class CommandControllerEvent {
|
|
4
|
+
ev: EventEmitter<[never]>;
|
|
5
|
+
on<T extends keyof CommandControllerEventsMap>(eventName: T, listener: (arg: CommandControllerEventsMap[T]) => void): void;
|
|
6
|
+
off<T extends keyof CommandControllerEventsMap>(eventName: T, listener: (arg: CommandControllerEventsMap[T]) => void): void;
|
|
7
|
+
removeAllListeners<T extends keyof CommandControllerEventsMap>(event: T): void;
|
|
8
|
+
emit<T extends keyof CommandControllerEventsMap>(eventName: T, arg: CommandControllerEventsMap[T]): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 events_1 = __importDefault(require("events"));
|
|
7
|
+
class CommandControllerEvent {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.ev = new events_1.default();
|
|
10
|
+
}
|
|
11
|
+
on(eventName, listener) {
|
|
12
|
+
this.ev.on(eventName, listener);
|
|
13
|
+
}
|
|
14
|
+
off(eventName, listener) {
|
|
15
|
+
this.ev.off(eventName, listener);
|
|
16
|
+
}
|
|
17
|
+
removeAllListeners(event) {
|
|
18
|
+
this.ev.removeAllListeners(event);
|
|
19
|
+
}
|
|
20
|
+
emit(eventName, arg) {
|
|
21
|
+
return this.ev.emit(eventName, arg);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = CommandControllerEvent;
|
|
25
|
+
//# sourceMappingURL=CommandControllerEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandControllerEvent.js","sourceRoot":"","sources":["../../../src/modules/command/CommandControllerEvent.ts"],"names":[],"mappings":";;;;;AAAA,oDAAkC;AAIlC,MAAqB,sBAAsB;IAA3C;QACS,OAAE,GAAG,IAAI,gBAAY,EAAE,CAAC;IAiBjC,CAAC;IAfC,EAAE,CAA6C,SAAY,EAAE,QAAsD;QACjH,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED,GAAG,CAA6C,SAAY,EAAE,QAAsD;QAClH,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,kBAAkB,CAA6C,KAAQ;QACrE,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAA6C,SAAY,EAAE,GAAkC;QAC/F,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF;AAlBD,yCAkBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Tipo da chave do comando */
|
|
2
|
+
export declare enum CMDKeyType {
|
|
3
|
+
/** Chaves simples (includes all) */
|
|
4
|
+
Sample = "sample",
|
|
5
|
+
/** Chave exata (startsWith) */
|
|
6
|
+
Exact = "exact"
|
|
7
|
+
}
|
|
8
|
+
/** Tipo da execução do comando */
|
|
9
|
+
export declare enum CMDRunType {
|
|
10
|
+
/** Execução normal */
|
|
11
|
+
Exec = "exec",
|
|
12
|
+
/** Resposta ao comando */
|
|
13
|
+
Reply = "reply"
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CMDRunType = exports.CMDKeyType = void 0;
|
|
4
|
+
/** Tipo da chave do comando */
|
|
5
|
+
var CMDKeyType;
|
|
6
|
+
(function (CMDKeyType) {
|
|
7
|
+
/** Chaves simples (includes all) */
|
|
8
|
+
CMDKeyType["Sample"] = "sample";
|
|
9
|
+
/** Chave exata (startsWith) */
|
|
10
|
+
CMDKeyType["Exact"] = "exact";
|
|
11
|
+
})(CMDKeyType || (exports.CMDKeyType = CMDKeyType = {}));
|
|
12
|
+
/** Tipo da execução do comando */
|
|
13
|
+
var CMDRunType;
|
|
14
|
+
(function (CMDRunType) {
|
|
15
|
+
/** Execução normal */
|
|
16
|
+
CMDRunType["Exec"] = "exec";
|
|
17
|
+
/** Resposta ao comando */
|
|
18
|
+
CMDRunType["Reply"] = "reply";
|
|
19
|
+
})(CMDRunType || (exports.CMDRunType = CMDRunType = {}));
|
|
20
|
+
//# sourceMappingURL=CommandEnums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandEnums.js","sourceRoot":"","sources":["../../../src/modules/command/CommandEnums.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,oCAAoC;IACpC,+BAAiB,CAAA;IACjB,+BAA+B;IAC/B,6BAAe,CAAA;AACjB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAED,kCAAkC;AAClC,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,sBAAsB;IACtB,2BAAa,CAAA;IACb,0BAA0B;IAC1B,6BAAe,CAAA;AACjB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ICommandControllerConfig from './ICommandControllerConfig';
|
|
2
|
+
export default class CommandKey {
|
|
3
|
+
/** Tipo da chave */
|
|
4
|
+
type: string;
|
|
5
|
+
/** Valores da chave */
|
|
6
|
+
values: string[];
|
|
7
|
+
constructor(...values: string[]);
|
|
8
|
+
/**
|
|
9
|
+
* Procura pela chave em um texto
|
|
10
|
+
* @return retorna se a chave foi encontrada
|
|
11
|
+
*/
|
|
12
|
+
static search(text: string, config: ICommandControllerConfig, ...keys: CommandKey[]): CommandKey | null;
|
|
13
|
+
/** Verifica se o texto contem as chaves */
|
|
14
|
+
static verify(text: string, keys: string[]): boolean;
|
|
15
|
+
/** Verifica se o texto tem as chaves exatas */
|
|
16
|
+
static verifyExact(text: string, keys: string[]): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CommandEnums_1 = require("./CommandEnums");
|
|
4
|
+
class CommandKey {
|
|
5
|
+
constructor(...values) {
|
|
6
|
+
/** Tipo da chave */
|
|
7
|
+
this.type = CommandEnums_1.CMDKeyType.Sample;
|
|
8
|
+
/** Valores da chave */
|
|
9
|
+
this.values = [];
|
|
10
|
+
this.values = values;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Procura pela chave em um texto
|
|
14
|
+
* @return retorna se a chave foi encontrada
|
|
15
|
+
*/
|
|
16
|
+
static search(text, config, ...keys) {
|
|
17
|
+
if (config.prefix) {
|
|
18
|
+
if (!text.startsWith(config.prefix))
|
|
19
|
+
return null;
|
|
20
|
+
text = text.replace(config.prefix, '').trim();
|
|
21
|
+
}
|
|
22
|
+
if (config.lowerCase) {
|
|
23
|
+
text = text.toLowerCase();
|
|
24
|
+
keys = keys.map((key) => {
|
|
25
|
+
key.values = key.values.map((value) => value.toLowerCase());
|
|
26
|
+
return key;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const result = keys.filter((key) => {
|
|
30
|
+
if (key.type === CommandEnums_1.CMDKeyType.Exact) {
|
|
31
|
+
return CommandKey.verifyExact(text, key.values);
|
|
32
|
+
}
|
|
33
|
+
return CommandKey.verify(text, key.values);
|
|
34
|
+
});
|
|
35
|
+
if (result.length > 0) {
|
|
36
|
+
let key = result[0];
|
|
37
|
+
for (const res of result) {
|
|
38
|
+
if (res.values.join('').length < key.values.join('').length)
|
|
39
|
+
continue;
|
|
40
|
+
key = res;
|
|
41
|
+
}
|
|
42
|
+
return key;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/** Verifica se o texto contem as chaves */
|
|
47
|
+
static verify(text, keys) {
|
|
48
|
+
for (const key of keys) {
|
|
49
|
+
if (text.includes(key))
|
|
50
|
+
continue;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
/** Verifica se o texto tem as chaves exatas */
|
|
56
|
+
static verifyExact(text, keys) {
|
|
57
|
+
let result = `${text}`;
|
|
58
|
+
for (const key of keys) {
|
|
59
|
+
if (!result.startsWith(key))
|
|
60
|
+
return false;
|
|
61
|
+
result = result.replace(key, '').trim();
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = CommandKey;
|
|
67
|
+
//# sourceMappingURL=CommandKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandKey.js","sourceRoot":"","sources":["../../../src/modules/command/CommandKey.ts"],"names":[],"mappings":";;AACA,iDAA4C;AAE5C,MAAqB,UAAU;IAM7B,YAAY,GAAG,MAAgB;QAL/B,oBAAoB;QACb,SAAI,GAAW,yBAAU,CAAC,MAAM,CAAC;QACxC,uBAAuB;QAChB,WAAM,GAAa,EAAE,CAAC;QAG3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAClB,IAAY,EACZ,MAAgC,EAChC,GAAG,IAAkB;QAErB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC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CAAC;QACb,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2CAA2C;IACpC,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,IAAc;QAC/C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,SAAS;YAEjC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+CAA+C;IACxC,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,IAAc;QACpD,IAAI,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;QAEvB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAE1C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,6BA+EC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Message from "../../messages/Message";
|
|
2
|
+
export default class CommandPermission {
|
|
3
|
+
/** Identificador da permissão */
|
|
4
|
+
id: string;
|
|
5
|
+
/** Se tem permissão */
|
|
6
|
+
isPermited?: boolean;
|
|
7
|
+
constructor(id: string, isPermited?: boolean);
|
|
8
|
+
static check(message: Message, cmdPerm: CommandPermission): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Command_1 = require("./Command");
|
|
4
|
+
class CommandPermission {
|
|
5
|
+
constructor(id, isPermited = false) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.isPermited = isPermited;
|
|
8
|
+
}
|
|
9
|
+
static async check(message, cmdPerm) {
|
|
10
|
+
if (cmdPerm.id == Command_1.CMDPerms.ChatPv) {
|
|
11
|
+
return message.chat.type == "pv";
|
|
12
|
+
}
|
|
13
|
+
if (cmdPerm.id == Command_1.CMDPerms.ChatGroup) {
|
|
14
|
+
return message.chat.type == "group";
|
|
15
|
+
}
|
|
16
|
+
if (cmdPerm.id == Command_1.CMDPerms.BotChatLeader) {
|
|
17
|
+
return await message.chat.isLeader(message.botId);
|
|
18
|
+
}
|
|
19
|
+
if (cmdPerm.id == Command_1.CMDPerms.BotChatAdmin) {
|
|
20
|
+
return await message.chat.isAdmin(message.botId);
|
|
21
|
+
}
|
|
22
|
+
if (cmdPerm.id == Command_1.CMDPerms.BotChatLeader) {
|
|
23
|
+
return await message.chat.isLeader(message.botId);
|
|
24
|
+
}
|
|
25
|
+
if (cmdPerm.id == Command_1.CMDPerms.UserChatAdmin) {
|
|
26
|
+
return await message.chat.isAdmin(message.user.id);
|
|
27
|
+
}
|
|
28
|
+
if (cmdPerm.id == Command_1.CMDPerms.UserChatLeader) {
|
|
29
|
+
return await message.chat.isLeader(message.user.id);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.default = CommandPermission;
|
|
35
|
+
//# sourceMappingURL=CommandPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandPermission.js","sourceRoot":"","sources":["../../../src/modules/command/CommandPermission.ts"],"names":[],"mappings":";;AACA,uCAAqC;AAErC,MAAqB,iBAAiB;IAMpC,YAAY,EAAU,EAAE,aAAsB,KAAK;QACjD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAgB,EAAE,OAA0B;QACpE,IAAI,OAAO,CAAC,EAAE,IAAI,kBAAQ,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,OAAO,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