@futdevpro/nts-dynamo 1.14.8 → 1.14.10
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/build/_collections/global-settings.const.d.ts.map +1 -1
- package/build/_collections/global-settings.const.js +1 -0
- package/build/_collections/global-settings.const.js.map +1 -1
- package/build/_models/interfaces/global-settings.interface.d.ts +18 -2
- package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
- package/build/_modules/assistant/_collections/ass-global-settings.const.d.ts +3 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.d.ts.map +1 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.js +15 -0
- package/build/_modules/assistant/_collections/ass-global-settings.const.js.map +1 -0
- package/build/_modules/assistant/_collections/ass.util.d.ts +16 -0
- package/build/_modules/assistant/_collections/ass.util.d.ts.map +1 -0
- package/build/_modules/assistant/_collections/ass.util.js +43 -0
- package/build/_modules/assistant/_collections/ass.util.js.map +1 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.d.ts +14 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.js +3 -0
- package/build/_modules/assistant/_models/ass-global-settings.interface.js.map +1 -0
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts +23 -0
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass-io.control-service.js +59 -0
- package/build/_modules/assistant/_services/ass-io.control-service.js.map +1 -0
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts +15 -0
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass-main.control-service.js +12 -0
- package/build/_modules/assistant/_services/ass-main.control-service.js.map +1 -0
- package/build/_modules/assistant/_services/ass.service-base.d.ts +31 -0
- package/build/_modules/assistant/_services/ass.service-base.d.ts.map +1 -0
- package/build/_modules/assistant/_services/ass.service-base.js +56 -0
- package/build/_modules/assistant/_services/ass.service-base.js.map +1 -0
- package/build/_modules/assistant/index.d.ts +7 -0
- package/build/_modules/assistant/index.d.ts.map +1 -0
- package/build/_modules/assistant/index.js +19 -0
- package/build/_modules/assistant/index.js.map +1 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.d.ts +3 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.js +14 -0
- package/build/_modules/bot/_collections/bot-default-commands.const.js.map +1 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.d.ts +3 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.js +32 -0
- package/build/_modules/bot/_collections/bot-global-settings.const.js.map +1 -0
- package/build/_modules/bot/_collections/bot-operations.util.d.ts +21 -0
- package/build/_modules/bot/_collections/bot-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_collections/bot-operations.util.js +74 -0
- package/build/_modules/bot/_collections/bot-operations.util.js.map +1 -0
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts +7 -0
- package/build/_modules/bot/_enums/bot-provider.enum.d.ts.map +1 -0
- package/build/_modules/bot/_enums/bot-provider.enum.js +11 -0
- package/build/_modules/bot/_enums/bot-provider.enum.js.map +1 -0
- package/build/_modules/bot/_models/bot-channel.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-channel.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-channel.interface.js +3 -0
- package/build/_modules/bot/_models/bot-channel.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-command.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-command.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-command.interface.js +3 -0
- package/build/_modules/bot/_models/bot-command.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts +79 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.js +3 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.d.ts +7 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.js +3 -0
- package/build/_modules/bot/_models/bot-last-mention-date.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.d.ts +6 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.js +3 -0
- package/build/_modules/bot/_models/bot-last-message-date.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-message.interface.d.ts +15 -0
- package/build/_modules/bot/_models/bot-message.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-message.interface.js +3 -0
- package/build/_modules/bot/_models/bot-message.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-provider.interface.d.ts +60 -0
- package/build/_modules/bot/_models/bot-provider.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-provider.interface.js +3 -0
- package/build/_modules/bot/_models/bot-provider.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-user.interface.d.ts +8 -0
- package/build/_modules/bot/_models/bot-user.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-user.interface.js +3 -0
- package/build/_modules/bot/_models/bot-user.interface.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js +13 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts +5 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js +19 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts +8 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js +3 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts +53 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js +369 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts +5 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.js +16 -0
- package/build/_modules/bot/_modules/discord-bot/index.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js +13 -0
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts +7 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.js +3 -0
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts +40 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js +116 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts +4 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.js +15 -0
- package/build/_modules/bot/_modules/slack-bot/index.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts +11 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js +13 -0
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts +7 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.js +3 -0
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts +40 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js +116 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts +4 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.js +15 -0
- package/build/_modules/bot/_modules/teams-bot/index.js.map +1 -0
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts +15 -0
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-commands.control-service.js +72 -0
- package/build/_modules/bot/_services/bot-commands.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-io.control-service.d.ts +24 -0
- package/build/_modules/bot/_services/bot-io.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-io.control-service.js +207 -0
- package/build/_modules/bot/_services/bot-io.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-main.control-service.d.ts +42 -0
- package/build/_modules/bot/_services/bot-main.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-main.control-service.js +223 -0
- package/build/_modules/bot/_services/bot-main.control-service.js.map +1 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts +5 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.js +28 -0
- package/build/_modules/bot/_services/bot-provider-factory.service.js.map +1 -0
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts +17 -0
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-routines.control-service.js +40 -0
- package/build/_modules/bot/_services/bot-routines.control-service.js.map +1 -0
- package/build/_modules/bot/index.d.ts +21 -0
- package/build/_modules/bot/index.d.ts.map +1 -0
- package/build/_modules/bot/index.js +35 -0
- package/build/_modules/bot/index.js.map +1 -0
- package/build/_modules/defaults/_models/default-user.data-model.d.ts +20 -0
- package/build/_modules/defaults/_models/default-user.data-model.d.ts.map +1 -0
- package/build/_modules/defaults/_models/default-user.data-model.js +73 -0
- package/build/_modules/defaults/_models/default-user.data-model.js.map +1 -0
- package/build/_modules/defaults/_services/default-auth.service.d.ts +51 -0
- package/build/_modules/defaults/_services/default-auth.service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-auth.service.js +159 -0
- package/build/_modules/defaults/_services/default-auth.service.js.map +1 -0
- package/build/_modules/defaults/_services/default-socket-events.service.d.ts +24 -0
- package/build/_modules/defaults/_services/default-socket-events.service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-socket-events.service.js +61 -0
- package/build/_modules/defaults/_services/default-socket-events.service.js.map +1 -0
- package/build/_modules/defaults/_services/default-user.data-service.d.ts +25 -0
- package/build/_modules/defaults/_services/default-user.data-service.d.ts.map +1 -0
- package/build/_modules/defaults/_services/default-user.data-service.js +88 -0
- package/build/_modules/defaults/_services/default-user.data-service.js.map +1 -0
- package/build/_modules/defaults/index.d.ts +5 -0
- package/build/_modules/defaults/index.d.ts.map +1 -0
- package/build/_modules/defaults/index.js +16 -0
- package/build/_modules/defaults/index.js.map +1 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts +6 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts.map +1 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.js +27 -0
- package/build/_modules/messaging/_collections/msg-global-settings.const.js.map +1 -0
- package/build/_modules/messaging/_collections/msg.util.d.ts +25 -0
- package/build/_modules/messaging/_collections/msg.util.d.ts.map +1 -0
- package/build/_modules/messaging/_collections/msg.util.js +63 -0
- package/build/_modules/messaging/_collections/msg.util.js.map +1 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts +38 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts.map +1 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.js +3 -0
- package/build/_modules/messaging/_models/msg-global-settings.interface.js.map +1 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.d.ts +29 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.js +110 -0
- package/build/_modules/messaging/_services/msg-conversation.data-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-events.service.d.ts +62 -0
- package/build/_modules/messaging/_services/msg-events.service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-events.service.js +204 -0
- package/build/_modules/messaging/_services/msg-events.service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts +26 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.js +126 -0
- package/build/_modules/messaging/_services/msg-integration.control-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-main.control-service.d.ts +62 -0
- package/build/_modules/messaging/_services/msg-main.control-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-main.control-service.js +408 -0
- package/build/_modules/messaging/_services/msg-main.control-service.js.map +1 -0
- package/build/_modules/messaging/_services/msg-message.data-service.d.ts +29 -0
- package/build/_modules/messaging/_services/msg-message.data-service.d.ts.map +1 -0
- package/build/_modules/messaging/_services/msg-message.data-service.js +104 -0
- package/build/_modules/messaging/_services/msg-message.data-service.js.map +1 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.d.ts +8 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.d.ts.map +1 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.js +21 -0
- package/build/_modules/messaging/get-messaging-routing-module.util.js.map +1 -0
- package/build/_modules/messaging/index.d.ts +12 -0
- package/build/_modules/messaging/index.d.ts.map +1 -0
- package/build/_modules/messaging/index.js +30 -0
- package/build/_modules/messaging/index.js.map +1 -0
- package/build/_modules/messaging/messaging.controller.d.ts +13 -0
- package/build/_modules/messaging/messaging.controller.d.ts.map +1 -0
- package/build/_modules/messaging/messaging.controller.js +257 -0
- package/build/_modules/messaging/messaging.controller.js.map +1 -0
- package/package.json +72 -4
- package/src/_collections/global-settings.const.ts +2 -0
- package/src/_models/interfaces/global-settings.interface.ts +20 -2
- package/src/_modules/assistant/_collections/ass-global-settings.const.ts +13 -0
- package/src/_modules/assistant/_collections/ass.util.ts +50 -0
- package/src/_modules/assistant/_models/ass-global-settings.interface.ts +15 -0
- package/src/_modules/assistant/_services/ass-io.control-service.ts +100 -0
- package/src/_modules/assistant/_services/ass-main.control-service.ts +38 -0
- package/src/_modules/assistant/_services/ass.service-base.ts +92 -0
- package/src/_modules/assistant/index.ts +19 -0
- package/src/_modules/bot/_collections/bot-default-commands.const.ts +12 -0
- package/src/_modules/bot/_collections/bot-global-settings.const.ts +39 -0
- package/src/_modules/bot/_collections/bot-operations.util.ts +149 -0
- package/src/_modules/bot/_enums/bot-provider.enum.ts +6 -0
- package/src/_modules/bot/_models/bot-channel.interface.ts +7 -0
- package/src/_modules/bot/_models/bot-command.interface.ts +8 -0
- package/src/_modules/bot/_models/bot-global-settings.interface.ts +87 -0
- package/src/_modules/bot/_models/bot-last-mention-date.interface.ts +6 -0
- package/src/_modules/bot/_models/bot-last-message-date.interface.ts +5 -0
- package/src/_modules/bot/_models/bot-message.interface.ts +14 -0
- package/src/_modules/bot/_models/bot-provider.interface.ts +80 -0
- package/src/_modules/bot/_models/bot-user.interface.ts +7 -0
- package/src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts +20 -0
- package/src/_modules/bot/_modules/discord-bot/_models/dib-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/discord-bot/_services/dib-provider.service.ts +462 -0
- package/src/_modules/bot/_modules/discord-bot/index.ts +15 -0
- package/src/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/slack-bot/_models/slb-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/slack-bot/_services/slb-provider.service.ts +152 -0
- package/src/_modules/bot/_modules/slack-bot/index.ts +14 -0
- package/src/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.ts +18 -0
- package/src/_modules/bot/_modules/teams-bot/_models/teb-platform.types.ts +9 -0
- package/src/_modules/bot/_modules/teams-bot/_services/teb-provider.service.ts +152 -0
- package/src/_modules/bot/_modules/teams-bot/index.ts +14 -0
- package/src/_modules/bot/_services/bot-commands.control-service.ts +126 -0
- package/src/_modules/bot/_services/bot-io.control-service.ts +325 -0
- package/src/_modules/bot/_services/bot-main.control-service.ts +344 -0
- package/src/_modules/bot/_services/bot-provider-factory.service.ts +30 -0
- package/src/_modules/bot/_services/bot-routines.control-service.ts +83 -0
- package/src/_modules/bot/index.ts +36 -0
- package/src/_modules/defaults/_models/default-user.data-model.ts +72 -0
- package/src/_modules/defaults/_services/default-auth.service.ts +177 -0
- package/src/_modules/defaults/_services/default-socket-events.service.ts +61 -0
- package/src/_modules/defaults/_services/default-user.data-service.ts +98 -0
- package/src/_modules/defaults/index.ts +14 -0
- package/src/_modules/messaging/_collections/msg-global-settings.const.ts +27 -0
- package/src/_modules/messaging/_collections/msg.util.ts +83 -0
- package/src/_modules/messaging/_models/msg-global-settings.interface.ts +49 -0
- package/src/_modules/messaging/_services/msg-conversation.data-service.ts +146 -0
- package/src/_modules/messaging/_services/msg-events.service.ts +267 -0
- package/src/_modules/messaging/_services/msg-integration.control-service.ts +179 -0
- package/src/_modules/messaging/_services/msg-main.control-service.ts +548 -0
- package/src/_modules/messaging/_services/msg-message.data-service.ts +129 -0
- package/src/_modules/messaging/get-messaging-routing-module.util.ts +26 -0
- package/src/_modules/messaging/index.ts +33 -0
- package/src/_modules/messaging/messaging.controller.ts +370 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import { Client, GatewayIntentBits, Guild, Collection, GuildMember, Message, Partials, Role, TextChannel } from 'discord.js';
|
|
2
|
+
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DyNTS_Bot_Provider, DyNTS_Bot_Provider_Config } from '../../../_models/bot-provider.interface';
|
|
4
|
+
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
5
|
+
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
6
|
+
import { DyNTS_Bot_Provider_Type } from '../../../_enums/bot-provider.enum';
|
|
7
|
+
import { DyNTS_DiB_Message, DyNTS_DiB_Channel, DyNTS_DiB_User } from '../_models/dib-platform.types';
|
|
8
|
+
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
9
|
+
|
|
10
|
+
export class DyNTS_DiB_Provider implements DyNTS_Bot_Provider<
|
|
11
|
+
DyNTS_DiB_Channel,
|
|
12
|
+
DyNTS_DiB_Message,
|
|
13
|
+
DyNTS_DiB_User
|
|
14
|
+
> {
|
|
15
|
+
private client: Client;
|
|
16
|
+
private guild: Guild;
|
|
17
|
+
private channelCache: Map<string, TextChannel>;
|
|
18
|
+
private roleCache: Map<string, Role>;
|
|
19
|
+
private isInitialized: boolean = false;
|
|
20
|
+
private config: DyNTS_Bot_Provider_Config;
|
|
21
|
+
|
|
22
|
+
// Event handlers
|
|
23
|
+
private messageHandlers: Array<(message: DyNTS_DiB_Message, issuer: string) => void> = [];
|
|
24
|
+
private readyHandlers: Array<() => void> = [];
|
|
25
|
+
private errorHandlers: Array<(error: Error) => void> = [];
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
this.channelCache = new Map();
|
|
29
|
+
this.roleCache = new Map();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async initialize(config: DyNTS_Bot_Provider_Config): Promise<void> {
|
|
33
|
+
this.config = config;
|
|
34
|
+
|
|
35
|
+
if (config.provider !== DyNTS_Bot_Provider_Type.discord) {
|
|
36
|
+
throw new Error(`Invalid provider type: ${config.provider}. Expected 'discord'`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!config.discord) {
|
|
40
|
+
throw new Error('Discord configuration is required');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.client = new Client({
|
|
44
|
+
intents: [
|
|
45
|
+
GatewayIntentBits.Guilds,
|
|
46
|
+
GatewayIntentBits.GuildMembers,
|
|
47
|
+
GatewayIntentBits.GuildMessages,
|
|
48
|
+
GatewayIntentBits.MessageContent,
|
|
49
|
+
GatewayIntentBits.DirectMessages,
|
|
50
|
+
GatewayIntentBits.GuildVoiceStates,
|
|
51
|
+
],
|
|
52
|
+
partials: [
|
|
53
|
+
Partials.Channel,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.isInitialized = true;
|
|
58
|
+
DyFM_Log.success('Discord provider initialized');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async login(token: string): Promise<void> {
|
|
62
|
+
if (!this.isInitialized) {
|
|
63
|
+
throw new Error('Provider not initialized. Call initialize() first.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
this.client.on('ready', async () => {
|
|
68
|
+
if (DyNTS_global_settings.bot_settings?.debugLevel >= 1) {
|
|
69
|
+
DyFM_Log.success(`Discord bot logged in as ${this.client.user?.tag}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Get guild
|
|
73
|
+
this.guild = this.client.guilds.cache.get(this.config.discord.guildId);
|
|
74
|
+
if (!this.guild) {
|
|
75
|
+
reject(new Error(`Discord server not found with ID: ${this.config.discord.guildId}`));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Set up event listeners
|
|
80
|
+
this.setupEventListeners();
|
|
81
|
+
|
|
82
|
+
// Trigger ready handlers
|
|
83
|
+
this.readyHandlers.forEach(handler => handler());
|
|
84
|
+
|
|
85
|
+
resolve();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
this.client.on('error', (error) => {
|
|
89
|
+
this.errorHandlers.forEach(handler => handler(error));
|
|
90
|
+
reject(error);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
this.client.login(token).catch(reject);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private setupEventListeners(): void {
|
|
98
|
+
this.client.on('messageCreate', (message: Message) => {
|
|
99
|
+
if (message.author.bot) return; // Ignore bot messages
|
|
100
|
+
|
|
101
|
+
const botMessage = this.translateMessage(message);
|
|
102
|
+
this.messageHandlers.forEach(handler => handler(botMessage, 'discord-message'));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Channel operations
|
|
107
|
+
async getChannelByName(name: string): Promise<DyNTS_DiB_Channel> {
|
|
108
|
+
if (this.channelCache.has(name)) {
|
|
109
|
+
return this.translateChannel(this.channelCache.get(name));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const channel = this.guild.channels.cache.find(
|
|
113
|
+
(ch) => ch.name === name && ch.isTextBased()
|
|
114
|
+
) as TextChannel;
|
|
115
|
+
|
|
116
|
+
if (!channel) {
|
|
117
|
+
throw new Error(`No text channel found with name "${name}"`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.channelCache.set(name, channel);
|
|
121
|
+
return this.translateChannel(channel);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async sendMessageToChannelByName(channelName: string, message: string): Promise<DyNTS_DiB_Message> {
|
|
125
|
+
const channel = await this.getChannelByName(channelName);
|
|
126
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
127
|
+
const sentMessage = await discordChannel.send(message);
|
|
128
|
+
return this.translateMessage(sentMessage);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async getMessagesFromChannelByChannelName(channelName: string, limit: number = 100): Promise<DyNTS_DiB_Message[]> {
|
|
132
|
+
const channel = await this.getChannelByName(channelName);
|
|
133
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
134
|
+
const messages = await discordChannel.messages.fetch({ limit });
|
|
135
|
+
return Array.from(messages.values()).map(msg => this.translateMessage(msg));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async getLastMessageInChannel(channelName: string): Promise<DyNTS_DiB_Message> {
|
|
139
|
+
const channel = await this.getChannelByName(channelName);
|
|
140
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
141
|
+
const messages = await discordChannel.messages.fetch({ limit: 1 });
|
|
142
|
+
const lastMessage = messages.first();
|
|
143
|
+
return lastMessage ? this.translateMessage(lastMessage) : null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async clearChannel(channelId: string): Promise<void> {
|
|
147
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
148
|
+
if (!channel) {
|
|
149
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let lastId: string | undefined = undefined;
|
|
153
|
+
let fetched = 0;
|
|
154
|
+
const maxFetch = 1000;
|
|
155
|
+
|
|
156
|
+
while (fetched < maxFetch) {
|
|
157
|
+
const options: { limit: number; before?: string } = { limit: 100 };
|
|
158
|
+
if (lastId) options.before = lastId;
|
|
159
|
+
|
|
160
|
+
const messageCollection: Collection<string, Message> = await channel.messages.fetch(options);
|
|
161
|
+
if (messageCollection.size === 0) break;
|
|
162
|
+
|
|
163
|
+
const deletePromises = Array.from(messageCollection.values()).map(message =>
|
|
164
|
+
message.delete().catch((error) => {
|
|
165
|
+
DyFM_Error.logSimple('Failed to delete message', error);
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await Promise.all(deletePromises);
|
|
170
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
171
|
+
fetched += messageCollection.size;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Message operations
|
|
176
|
+
async sendMessage(channelId: string, content: string): Promise<DyNTS_DiB_Message> {
|
|
177
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
178
|
+
if (!channel) {
|
|
179
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
180
|
+
}
|
|
181
|
+
const message = await channel.send(content);
|
|
182
|
+
return this.translateMessage(message);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async replyToMessage(messageId: string, channelId: string, content: string): Promise<DyNTS_DiB_Message> {
|
|
186
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
187
|
+
if (!channel) {
|
|
188
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
189
|
+
}
|
|
190
|
+
const message = await channel.messages.fetch(messageId);
|
|
191
|
+
const reply = await message.reply(content);
|
|
192
|
+
return this.translateMessage(reply);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async sendTyping(channelId: string): Promise<void> {
|
|
196
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
197
|
+
if (!channel) {
|
|
198
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
199
|
+
}
|
|
200
|
+
await channel.sendTyping();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async fetchMessages(channelId: string, limit: number): Promise<DyNTS_DiB_Message[]> {
|
|
204
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
205
|
+
if (!channel) {
|
|
206
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
207
|
+
}
|
|
208
|
+
const messages = await channel.messages.fetch({ limit });
|
|
209
|
+
return Array.from(messages.values()).map(msg => this.translateMessage(msg));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async fetchAllMessagesWithPaging(channelId: string, maxFetch: number = 1000): Promise<DyNTS_DiB_Message[]> {
|
|
213
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
214
|
+
if (!channel) {
|
|
215
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let lastId: string | undefined = undefined;
|
|
219
|
+
let fetched = 0;
|
|
220
|
+
const allMessages: DyNTS_DiB_Message[] = [];
|
|
221
|
+
|
|
222
|
+
while (fetched < maxFetch) {
|
|
223
|
+
const options: { limit: number; before?: string } = { limit: 100 };
|
|
224
|
+
if (lastId) options.before = lastId;
|
|
225
|
+
|
|
226
|
+
const messageCollection: Collection<string, Message> = await channel.messages.fetch(options);
|
|
227
|
+
if (messageCollection.size === 0) break;
|
|
228
|
+
|
|
229
|
+
Array.from(messageCollection.values()).forEach((msg: Message) => {
|
|
230
|
+
allMessages.push(this.translateMessage(msg));
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
234
|
+
fetched += messageCollection.size;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return allMessages;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
async deleteMessage(messageId: string, channelId: string): Promise<void> {
|
|
241
|
+
const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
242
|
+
if (!channel) {
|
|
243
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
244
|
+
}
|
|
245
|
+
const message = await channel.messages.fetch(messageId);
|
|
246
|
+
await message.delete();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// User operations
|
|
250
|
+
async getUserByName(username: string): Promise<DyNTS_DiB_User> {
|
|
251
|
+
const member = this.guild.members.cache.find(m => m.user.username === username);
|
|
252
|
+
if (!member) {
|
|
253
|
+
throw new Error(`User not found with username: ${username}`);
|
|
254
|
+
}
|
|
255
|
+
return this.translateUser(member);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
getUserMention(userId: string): string {
|
|
259
|
+
return `<@${userId}>`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async readMembersInChannel(channelName: string): Promise<DyNTS_DiB_User[]> {
|
|
263
|
+
const channel = await this.getChannelByName(channelName);
|
|
264
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
265
|
+
const members = await this.guild.members.fetch();
|
|
266
|
+
|
|
267
|
+
const allowedMembers = members.filter((member) =>
|
|
268
|
+
discordChannel.permissionsFor(member)?.has('ViewChannel')
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
return Array.from(allowedMembers.values()).map(member => this.translateUser(member));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async readMemberNamesInChannel(channelName: string): Promise<string[]> {
|
|
275
|
+
const members = await this.readMembersInChannel(channelName);
|
|
276
|
+
return members.map(member => member.username);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Advanced message queries
|
|
280
|
+
async getLastMessageSentBy(channelName: string, username: string): Promise<DyNTS_DiB_Message> {
|
|
281
|
+
const messages = await this.fetchAllMessagesWithPaging(
|
|
282
|
+
(await this.getChannelByName(channelName)).id,
|
|
283
|
+
1000
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
return messages.find(msg => msg.authorName === username) || null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async getLastMentionOf(channelName: string, username: string): Promise<DyNTS_DiB_Message> {
|
|
290
|
+
const messages = await this.fetchAllMessagesWithPaging(
|
|
291
|
+
(await this.getChannelByName(channelName)).id,
|
|
292
|
+
1000
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
return messages.find(msg =>
|
|
296
|
+
msg.content.includes(`@${username}`) ||
|
|
297
|
+
msg.content.includes(`<@${username}>`)
|
|
298
|
+
) || null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async readLastMessageDatesByMembers(channelName: string, memberNames: string[]): Promise<DyNTS_Bot_LastMessageDate[]> {
|
|
302
|
+
const channel = await this.getChannelByName(channelName);
|
|
303
|
+
const messages = await this.fetchAllMessagesWithPaging(channel.id, 1000);
|
|
304
|
+
|
|
305
|
+
const memberStatus: Record<string, { lastMessageDate: Date | null, allMessages: number }> = {};
|
|
306
|
+
memberNames.forEach(name => {
|
|
307
|
+
memberStatus[name] = { lastMessageDate: null, allMessages: 0 };
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const cutoffTime = Date.now() - (3 * 7 * 24 * 60 * 60 * 1000); // 3 weeks
|
|
311
|
+
|
|
312
|
+
messages.forEach((message) => {
|
|
313
|
+
if (message.timestamp < cutoffTime) return;
|
|
314
|
+
|
|
315
|
+
const author = message.authorName;
|
|
316
|
+
if (memberStatus[author] !== undefined) {
|
|
317
|
+
memberStatus[author].allMessages++;
|
|
318
|
+
if (!memberStatus[author].lastMessageDate) {
|
|
319
|
+
memberStatus[author].lastMessageDate = new Date(message.timestamp);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
return memberNames.map((memberName) => {
|
|
325
|
+
const status = memberStatus[memberName];
|
|
326
|
+
return {
|
|
327
|
+
memberName: memberName,
|
|
328
|
+
allMessages: status.allMessages,
|
|
329
|
+
lastMessageDate: status.lastMessageDate
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async readLastMessageWithMemberNamePingInIt(channelName: string, users: DyNTS_DiB_User[]): Promise<DyNTS_Bot_LastMentionDate[]> {
|
|
335
|
+
const channel = await this.getChannelByName(channelName);
|
|
336
|
+
const messages = await this.fetchAllMessagesWithPaging(channel.id, 1000);
|
|
337
|
+
|
|
338
|
+
const memberStatus: Record<string, { lastMentionDate: Date | null, allMentions: number }> = {};
|
|
339
|
+
users.forEach(user => {
|
|
340
|
+
memberStatus[user.username] = { lastMentionDate: null, allMentions: 0 };
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const cutoffTime = Date.now() - (3 * 7 * 24 * 60 * 60 * 1000); // 3 weeks
|
|
344
|
+
|
|
345
|
+
messages.forEach((message) => {
|
|
346
|
+
if (message.timestamp < cutoffTime) return;
|
|
347
|
+
|
|
348
|
+
users.forEach(user => {
|
|
349
|
+
if (
|
|
350
|
+
message.content.includes(`@${user.id}`) &&
|
|
351
|
+
!memberStatus[user.username].lastMentionDate
|
|
352
|
+
) {
|
|
353
|
+
memberStatus[user.username].lastMentionDate = new Date(message.timestamp);
|
|
354
|
+
memberStatus[user.username].allMentions++;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
return users.map((user) => {
|
|
360
|
+
const status = memberStatus[user.username];
|
|
361
|
+
return {
|
|
362
|
+
memberId: user.id,
|
|
363
|
+
memberName: user.username,
|
|
364
|
+
allMentions: status.allMentions,
|
|
365
|
+
lastMentionDate: status.lastMentionDate
|
|
366
|
+
};
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Discord-specific features
|
|
371
|
+
getRoleByName(roleName: string): Role {
|
|
372
|
+
if (this.roleCache.has(roleName)) {
|
|
373
|
+
return this.roleCache.get(roleName);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const role = this.guild.roles.cache.find(r => r.name === roleName);
|
|
377
|
+
if (role) {
|
|
378
|
+
this.roleCache.set(roleName, role);
|
|
379
|
+
}
|
|
380
|
+
return role;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
async getRolePingByName(roleName: string): Promise<string> {
|
|
384
|
+
const role = this.getRoleByName(roleName);
|
|
385
|
+
return role ? `<@&${role.id}>` : '';
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async getRolePingsByName(roleNames: string[]): Promise<string> {
|
|
389
|
+
const pings: string[] = await Promise.all(
|
|
390
|
+
roleNames.map(roleName => this.getRolePingByName(roleName))
|
|
391
|
+
);
|
|
392
|
+
return pings.join(' ');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Event binding
|
|
396
|
+
onMessage(handler: (message: DyNTS_DiB_Message, issuer: string) => void): void {
|
|
397
|
+
this.messageHandlers.push(handler);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
onReady(handler: () => void): void {
|
|
401
|
+
this.readyHandlers.push(handler);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
onError(handler: (error: Error) => void): void {
|
|
405
|
+
this.errorHandlers.push(handler);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Metadata
|
|
409
|
+
getBotId(): string {
|
|
410
|
+
return this.client?.user?.id;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
getBotDisplayName(): string {
|
|
414
|
+
return this.client?.user?.displayName;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
getProviderName(): string {
|
|
418
|
+
return 'discord';
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
isReady(): boolean {
|
|
422
|
+
return this.isInitialized && this.client?.readyAt !== null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Translation methods
|
|
426
|
+
private translateMessage(discordMessage: Message): DyNTS_DiB_Message {
|
|
427
|
+
return {
|
|
428
|
+
id: discordMessage.id,
|
|
429
|
+
content: discordMessage.content,
|
|
430
|
+
authorId: discordMessage.author.id,
|
|
431
|
+
authorName: discordMessage.author.username,
|
|
432
|
+
authorDisplayName: discordMessage.author.displayName,
|
|
433
|
+
channelId: discordMessage.channelId,
|
|
434
|
+
channelName: (discordMessage.channel as TextChannel)?.name || 'unknown',
|
|
435
|
+
timestamp: discordMessage.createdTimestamp,
|
|
436
|
+
isBot: discordMessage.author.bot,
|
|
437
|
+
replyToMessageId: discordMessage.reference?.messageId,
|
|
438
|
+
mentions: Array.from(discordMessage.mentions.users.keys()),
|
|
439
|
+
rawPlatformMessage: discordMessage
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private translateChannel(discordChannel: TextChannel): DyNTS_DiB_Channel {
|
|
444
|
+
return {
|
|
445
|
+
id: discordChannel.id,
|
|
446
|
+
name: discordChannel.name,
|
|
447
|
+
isTextBased: discordChannel.isTextBased(),
|
|
448
|
+
isDM: discordChannel.isDMBased(),
|
|
449
|
+
rawPlatformChannel: discordChannel
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
private translateUser(discordMember: GuildMember): DyNTS_DiB_User {
|
|
454
|
+
return {
|
|
455
|
+
id: discordMember.user.id,
|
|
456
|
+
username: discordMember.user.username,
|
|
457
|
+
displayName: discordMember.displayName,
|
|
458
|
+
isBot: discordMember.user.bot,
|
|
459
|
+
rawPlatformUser: discordMember
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Discord Bot Provider
|
|
3
|
+
//
|
|
4
|
+
// This module provides Discord-specific implementation of the Bot provider interface
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
// TYPES
|
|
8
|
+
export * from './_models/dib-platform.types';
|
|
9
|
+
|
|
10
|
+
// SERVICES
|
|
11
|
+
export * from './_services/dib-provider.service';
|
|
12
|
+
|
|
13
|
+
// COLLECTIONS
|
|
14
|
+
export * from './_collections/dib-operations.util';
|
|
15
|
+
export * from './_collections/dib.util';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DyNTS_Bot_Operations_Util } from '../../../_collections/bot-operations.util';
|
|
2
|
+
import { DyNTS_SlB_Message, DyNTS_SlB_Channel, DyNTS_SlB_User } from '../_models/slb-platform.types';
|
|
3
|
+
import { DyNTS_SlB_Provider } from '../_services/slb-provider.service';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Slack Bot Operations Utility
|
|
7
|
+
*
|
|
8
|
+
* Platform-specific implementation of bot operations for Slack
|
|
9
|
+
*/
|
|
10
|
+
export class DyNTS_SlB_Operations_Util extends DyNTS_Bot_Operations_Util<
|
|
11
|
+
DyNTS_SlB_Channel,
|
|
12
|
+
DyNTS_SlB_Message,
|
|
13
|
+
DyNTS_SlB_User,
|
|
14
|
+
DyNTS_SlB_Provider
|
|
15
|
+
> {
|
|
16
|
+
// Slack-specific operations can be added here
|
|
17
|
+
// All base operations are inherited from the generic class
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DyNTS_Bot_Message } from '../../../_models/bot-message.interface';
|
|
2
|
+
import { DyNTS_Bot_Channel } from '../../../_models/bot-channel.interface';
|
|
3
|
+
import { DyNTS_Bot_User } from '../../../_models/bot-user.interface';
|
|
4
|
+
|
|
5
|
+
// Slack Bot Platform-Specific Types
|
|
6
|
+
// TODO: Replace 'any' with actual Slack SDK types when implementing
|
|
7
|
+
export type DyNTS_SlB_Message = DyNTS_Bot_Message<any>;
|
|
8
|
+
export type DyNTS_SlB_Channel = DyNTS_Bot_Channel<any>;
|
|
9
|
+
export type DyNTS_SlB_User = DyNTS_Bot_User<any>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { DyNTS_Bot_Provider, DyNTS_Bot_Provider_Config } from '../../../_models/bot-provider.interface';
|
|
2
|
+
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
3
|
+
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
4
|
+
import { DyNTS_Bot_Provider_Type } from '../../../_enums/bot-provider.enum';
|
|
5
|
+
import { DyNTS_SlB_Message, DyNTS_SlB_Channel, DyNTS_SlB_User } from '../_models/slb-platform.types';
|
|
6
|
+
|
|
7
|
+
export class DyNTS_SlB_Provider implements DyNTS_Bot_Provider<
|
|
8
|
+
DyNTS_SlB_Channel,
|
|
9
|
+
DyNTS_SlB_Message,
|
|
10
|
+
DyNTS_SlB_User
|
|
11
|
+
> {
|
|
12
|
+
private isInitialized: boolean = false;
|
|
13
|
+
private config: DyNTS_Bot_Provider_Config;
|
|
14
|
+
|
|
15
|
+
// Event handlers
|
|
16
|
+
private messageHandlers: Array<(message: DyNTS_SlB_Message, issuer: string) => void> = [];
|
|
17
|
+
private readyHandlers: Array<() => void> = [];
|
|
18
|
+
private errorHandlers: Array<(error: Error) => void> = [];
|
|
19
|
+
|
|
20
|
+
async initialize(config: DyNTS_Bot_Provider_Config): Promise<void> {
|
|
21
|
+
this.config = config;
|
|
22
|
+
|
|
23
|
+
if (config.provider !== DyNTS_Bot_Provider_Type.slack) {
|
|
24
|
+
throw new Error(`Invalid provider type: ${config.provider}. Expected 'slack'`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!config.slack) {
|
|
28
|
+
throw new Error('Slack configuration is required');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.isInitialized = true;
|
|
32
|
+
// TODO: Initialize Slack client
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async login(token: string): Promise<void> {
|
|
36
|
+
if (!this.isInitialized) {
|
|
37
|
+
throw new Error('Provider not initialized. Call initialize() first.');
|
|
38
|
+
}
|
|
39
|
+
// TODO: Implement Slack login
|
|
40
|
+
throw new Error('Slack provider not yet implemented');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Channel operations
|
|
44
|
+
async getChannelByName(name: string): Promise<DyNTS_SlB_Channel> {
|
|
45
|
+
throw new Error('Slack provider not yet implemented');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async sendMessageToChannelByName(channelName: string, message: string): Promise<DyNTS_SlB_Message> {
|
|
49
|
+
throw new Error('Slack provider not yet implemented');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async getMessagesFromChannelByChannelName(channelName: string, limit?: number): Promise<DyNTS_SlB_Message[]> {
|
|
53
|
+
throw new Error('Slack provider not yet implemented');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async getLastMessageInChannel(channelName: string): Promise<DyNTS_SlB_Message> {
|
|
57
|
+
throw new Error('Slack provider not yet implemented');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async clearChannel(channelId: string): Promise<void> {
|
|
61
|
+
throw new Error('Slack provider not yet implemented');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Message operations
|
|
65
|
+
async sendMessage(channelId: string, content: string): Promise<DyNTS_SlB_Message> {
|
|
66
|
+
throw new Error('Slack provider not yet implemented');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async replyToMessage(messageId: string, channelId: string, content: string): Promise<DyNTS_SlB_Message> {
|
|
70
|
+
throw new Error('Slack provider not yet implemented');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async sendTyping(channelId: string): Promise<void> {
|
|
74
|
+
throw new Error('Slack provider not yet implemented');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async fetchMessages(channelId: string, limit: number): Promise<DyNTS_SlB_Message[]> {
|
|
78
|
+
throw new Error('Slack provider not yet implemented');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async fetchAllMessagesWithPaging(channelId: string, maxFetch?: number): Promise<DyNTS_SlB_Message[]> {
|
|
82
|
+
throw new Error('Slack provider not yet implemented');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async deleteMessage(messageId: string, channelId: string): Promise<void> {
|
|
86
|
+
throw new Error('Slack provider not yet implemented');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// User operations
|
|
90
|
+
async getUserByName(username: string): Promise<DyNTS_SlB_User> {
|
|
91
|
+
throw new Error('Slack provider not yet implemented');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getUserMention(userId: string): string {
|
|
95
|
+
return `<@${userId}>`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async readMembersInChannel(channelName: string): Promise<DyNTS_SlB_User[]> {
|
|
99
|
+
throw new Error('Slack provider not yet implemented');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async readMemberNamesInChannel(channelName: string): Promise<string[]> {
|
|
103
|
+
throw new Error('Slack provider not yet implemented');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Advanced message queries
|
|
107
|
+
async getLastMessageSentBy(channelName: string, username: string): Promise<DyNTS_SlB_Message> {
|
|
108
|
+
throw new Error('Slack provider not yet implemented');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async getLastMentionOf(channelName: string, username: string): Promise<DyNTS_SlB_Message> {
|
|
112
|
+
throw new Error('Slack provider not yet implemented');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async readLastMessageDatesByMembers(channelName: string, memberNames: string[]): Promise<DyNTS_Bot_LastMessageDate[]> {
|
|
116
|
+
throw new Error('Slack provider not yet implemented');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async readLastMessageWithMemberNamePingInIt(channelName: string, users: DyNTS_SlB_User[]): Promise<DyNTS_Bot_LastMentionDate[]> {
|
|
120
|
+
throw new Error('Slack provider not yet implemented');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Event binding
|
|
124
|
+
onMessage(handler: (message: DyNTS_SlB_Message, issuer: string) => void): void {
|
|
125
|
+
this.messageHandlers.push(handler);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onReady(handler: () => void): void {
|
|
129
|
+
this.readyHandlers.push(handler);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
onError(handler: (error: Error) => void): void {
|
|
133
|
+
this.errorHandlers.push(handler);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Metadata
|
|
137
|
+
getBotId(): string {
|
|
138
|
+
return 'slack-bot-stub';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
getBotDisplayName(): string {
|
|
142
|
+
return 'Slack Bot (Stub)';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getProviderName(): string {
|
|
146
|
+
return 'slack';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
isReady(): boolean {
|
|
150
|
+
return this.isInitialized;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Slack Bot Provider
|
|
3
|
+
//
|
|
4
|
+
// This module provides Slack-specific implementation of the Bot provider interface
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
// TYPES
|
|
8
|
+
export * from './_models/slb-platform.types';
|
|
9
|
+
|
|
10
|
+
// SERVICES
|
|
11
|
+
export * from './_services/slb-provider.service';
|
|
12
|
+
|
|
13
|
+
// COLLECTIONS
|
|
14
|
+
export * from './_collections/slb-operations.util';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DyNTS_Bot_Operations_Util } from '../../../_collections/bot-operations.util';
|
|
2
|
+
import { DyNTS_TeB_Message, DyNTS_TeB_Channel, DyNTS_TeB_User } from '../_models/teb-platform.types';
|
|
3
|
+
import { DyNTS_TeB_Provider } from '../_services/teb-provider.service';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Teams Bot Operations Utility
|
|
7
|
+
*
|
|
8
|
+
* Platform-specific implementation of bot operations for Teams
|
|
9
|
+
*/
|
|
10
|
+
export class DyNTS_TeB_Operations_Util extends DyNTS_Bot_Operations_Util<
|
|
11
|
+
DyNTS_TeB_Channel,
|
|
12
|
+
DyNTS_TeB_Message,
|
|
13
|
+
DyNTS_TeB_User,
|
|
14
|
+
DyNTS_TeB_Provider
|
|
15
|
+
> {
|
|
16
|
+
// Teams-specific operations can be added here
|
|
17
|
+
// All base operations are inherited from the generic class
|
|
18
|
+
}
|