@futdevpro/nts-dynamo 1.14.29 → 1.14.32
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/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts +0 -3
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js +20 -15
- package/build/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -1
- package/build/_modules/ai/_services/ai-llm.service-base.d.ts +0 -2
- package/build/_modules/ai/_services/ai-llm.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_services/ai-provider.service-base.d.ts +2 -1
- package/build/_modules/ai/_services/ai-provider.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_services/ai-provider.service-base.js +2 -1
- package/build/_modules/ai/_services/ai-provider.service-base.js.map +1 -1
- package/build/_modules/assistant/_collections/ass.util.d.ts +2 -2
- package/build/_modules/assistant/_collections/ass.util.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts +5 -9
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass-io.control-service.js +9 -10
- package/build/_modules/assistant/_services/ass-io.control-service.js.map +1 -1
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts +26 -10
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass-main.control-service.js +49 -4
- package/build/_modules/assistant/_services/ass-main.control-service.js.map +1 -1
- package/build/_modules/assistant/index.d.ts +1 -1
- package/build/_modules/assistant/index.d.ts.map +1 -1
- package/build/_modules/assistant/index.js +1 -1
- package/build/_modules/assistant/index.js.map +1 -1
- package/build/_modules/bot/_models/bot-channel-wrapper.interface.d.ts +17 -0
- package/build/_modules/bot/_models/bot-channel-wrapper.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/{bot-message.interface.js → bot-channel-wrapper.interface.js} +1 -1
- package/build/_modules/bot/_models/bot-channel-wrapper.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-command.interface.d.ts +2 -2
- package/build/_modules/bot/_models/bot-command.interface.d.ts.map +1 -1
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts +1 -1
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts.map +1 -1
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts +16 -13
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts.map +1 -1
- package/build/_modules/bot/_models/bot-user-wrapper.interface.d.ts +17 -0
- package/build/_modules/bot/_models/bot-user-wrapper.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/{bot-channel.interface.js → bot-user-wrapper.interface.js} +1 -1
- package/build/_modules/bot/_models/bot-user-wrapper.interface.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts +0 -7
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js +10 -2
- package/build/_modules/bot/_modules/discord-bot/_models/dib-platform.types.js.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.d.ts +68 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.js +397 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts +1 -4
- package/build/_modules/bot/_modules/discord-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/index.js +2 -5
- package/build/_modules/bot/_modules/discord-bot/index.js.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.d.ts +3 -3
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.js +2 -2
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.js.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.d.ts +6 -6
- package/build/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.d.ts.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.d.ts +60 -0
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/dynamo-bot/_services/{dyb-messaging-provider.service.js → dyb-messaging-provider.control-service.js} +134 -108
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.js.map +1 -0
- package/build/_modules/bot/_modules/dynamo-bot/index.d.ts +1 -2
- package/build/_modules/bot/_modules/dynamo-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/index.js +1 -2
- package/build/_modules/bot/_modules/dynamo-bot/index.js.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts +6 -6
- package/build/_modules/bot/_modules/slack-bot/_models/slb-platform.types.d.ts.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.d.ts +56 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.js +135 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts +1 -2
- package/build/_modules/bot/_modules/slack-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/index.js +1 -3
- package/build/_modules/bot/_modules/slack-bot/index.js.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts +6 -6
- package/build/_modules/bot/_modules/teams-bot/_models/teb-platform.types.d.ts.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.d.ts +56 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.js +135 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts +1 -2
- package/build/_modules/bot/_modules/teams-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/index.js +1 -3
- package/build/_modules/bot/_modules/teams-bot/index.js.map +1 -1
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts +8 -11
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-commands.control-service.js +60 -15
- package/build/_modules/bot/_services/bot-commands.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-io.control-service.d.ts +16 -17
- package/build/_modules/bot/_services/bot-io.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-io.control-service.js +60 -51
- package/build/_modules/bot/_services/bot-io.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-main.control-service.d.ts +18 -37
- package/build/_modules/bot/_services/bot-main.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-main.control-service.js +127 -264
- package/build/_modules/bot/_services/bot-main.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.d.ts +71 -0
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.d.ts.map +1 -0
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.js +16 -0
- package/build/_modules/bot/_services/bot-messaging-provider.service-base.js.map +1 -0
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts +6 -9
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-routines.control-service.js +29 -9
- package/build/_modules/bot/_services/bot-routines.control-service.js.map +1 -1
- package/build/_modules/bot/index.d.ts +3 -7
- package/build/_modules/bot/index.d.ts.map +1 -1
- package/build/_modules/bot/index.js +9 -7
- package/build/_modules/bot/index.js.map +1 -1
- package/build/_modules/messaging/_collections/msg-global-settings.const.d.ts.map +1 -1
- package/build/_modules/messaging/_collections/msg-global-settings.const.js +0 -5
- package/build/_modules/messaging/_collections/msg-global-settings.const.js.map +1 -1
- package/build/_modules/messaging/_collections/msg.util.d.ts +2 -2
- package/build/_modules/messaging/_collections/msg.util.d.ts.map +1 -1
- package/build/_modules/messaging/_collections/msg.util.js.map +1 -1
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts +0 -9
- package/build/_modules/messaging/_models/msg-global-settings.interface.d.ts.map +1 -1
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts +0 -25
- package/build/_modules/messaging/_services/msg-integration.control-service.d.ts.map +1 -1
- package/build/_modules/messaging/_services/msg-integration.control-service.js +180 -125
- package/build/_modules/messaging/_services/msg-integration.control-service.js.map +1 -1
- package/build/_modules/messaging/index.d.ts +0 -1
- package/build/_modules/messaging/index.d.ts.map +1 -1
- package/build/_modules/messaging/index.js +1 -1
- package/build/_modules/messaging/index.js.map +1 -1
- package/package.json +1 -1
- package/src/_modules/ai/_modules/open-ai/_services/oai-llm.service-base.ts +4 -4
- package/src/_modules/ai/_services/ai-llm.service-base.ts +2 -2
- package/src/_modules/ai/_services/ai-provider.service-base.ts +2 -1
- package/src/_modules/assistant/_collections/ass.util.ts +2 -2
- package/src/_modules/assistant/_services/ass-io.control-service.ts +17 -48
- package/src/_modules/assistant/_services/ass-main.control-service.ts +82 -32
- package/src/_modules/assistant/index.ts +1 -1
- package/src/_modules/bot/_models/bot-channel-wrapper.interface.ts +24 -0
- package/src/_modules/bot/_models/bot-command.interface.ts +2 -2
- package/src/_modules/bot/_models/bot-global-settings.interface.ts +1 -1
- package/src/_modules/bot/_models/bot-message-wrapper.interface.ts +18 -18
- package/src/_modules/bot/_models/bot-user-wrapper.interface.ts +35 -0
- package/src/_modules/bot/_modules/discord-bot/_models/dib-platform.types.ts +8 -7
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.ts +529 -0
- package/src/_modules/bot/_modules/discord-bot/index.ts +2 -5
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.ts +8 -5
- package/src/_modules/bot/_modules/dynamo-bot/_models/dyb-platform.types.ts +6 -6
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.control-service.ts +436 -0
- package/src/_modules/bot/_modules/dynamo-bot/index.ts +1 -2
- package/src/_modules/bot/_modules/slack-bot/_models/slb-platform.types.ts +6 -6
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.control-service.ts +190 -0
- package/src/_modules/bot/_modules/slack-bot/index.ts +1 -3
- package/src/_modules/bot/_modules/teams-bot/_models/teb-platform.types.ts +6 -6
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.control-service.ts +190 -0
- package/src/_modules/bot/_modules/teams-bot/index.ts +1 -4
- package/src/_modules/bot/_services/bot-commands.control-service.ts +64 -34
- package/src/_modules/bot/_services/bot-io.control-service.ts +86 -95
- package/src/_modules/bot/_services/bot-main.control-service.ts +253 -240
- package/src/_modules/bot/_services/bot-messaging-provider.service-base.ts +153 -0
- package/src/_modules/bot/_services/bot-routines.control-service.ts +39 -44
- package/src/_modules/bot/index.ts +9 -7
- package/src/_modules/messaging/README.md +2 -7
- package/src/_modules/messaging/_collections/msg-global-settings.const.ts +0 -6
- package/src/_modules/messaging/_collections/msg.util.ts +2 -2
- package/src/_modules/messaging/_models/msg-global-settings.interface.ts +0 -12
- package/src/_modules/messaging/_services/msg-integration.control-service.ts +180 -179
- package/src/_modules/messaging/index.ts +1 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.d.ts +0 -22
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.d.ts.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.js +0 -187
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-chunk-data.service.js.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.d.ts +0 -27
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.d.ts.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.js +0 -277
- package/build/_modules/ai/_modules/open-ai/_services/oai-doc-page.data-service.js.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.d.ts +0 -23
- package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.d.ts.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.js +0 -319
- package/build/_modules/ai/_modules/open-ai/_services/oai-document.data-service.js.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.d.ts +0 -118
- package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.d.ts.map +0 -1
- package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.js +0 -460
- package/build/_modules/ai/_modules/open-ai/_services/oai-vector-data.service.js.map +0 -1
- package/build/_modules/assistant/_services/ass.service-base.d.ts +0 -33
- package/build/_modules/assistant/_services/ass.service-base.d.ts.map +0 -1
- package/build/_modules/assistant/_services/ass.service-base.js +0 -58
- package/build/_modules/assistant/_services/ass.service-base.js.map +0 -1
- package/build/_modules/bot/_collections/bot-operations.util.d.ts +0 -21
- package/build/_modules/bot/_collections/bot-operations.util.d.ts.map +0 -1
- package/build/_modules/bot/_collections/bot-operations.util.js +0 -74
- package/build/_modules/bot/_collections/bot-operations.util.js.map +0 -1
- package/build/_modules/bot/_models/bot-channel.interface.d.ts +0 -8
- package/build/_modules/bot/_models/bot-channel.interface.d.ts.map +0 -1
- package/build/_modules/bot/_models/bot-channel.interface.js.map +0 -1
- package/build/_modules/bot/_models/bot-message.interface.d.ts +0 -15
- package/build/_modules/bot/_models/bot-message.interface.d.ts.map +0 -1
- package/build/_modules/bot/_models/bot-message.interface.js.map +0 -1
- package/build/_modules/bot/_models/bot-messaging-provider.interface.d.ts +0 -68
- package/build/_modules/bot/_models/bot-messaging-provider.interface.d.ts.map +0 -1
- package/build/_modules/bot/_models/bot-messaging-provider.interface.js +0 -3
- package/build/_modules/bot/_models/bot-messaging-provider.interface.js.map +0 -1
- package/build/_modules/bot/_models/bot-user.interface.d.ts +0 -8
- package/build/_modules/bot/_models/bot-user.interface.d.ts.map +0 -1
- package/build/_modules/bot/_models/bot-user.interface.js +0 -3
- package/build/_modules/bot/_models/bot-user.interface.js.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts +0 -11
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js +0 -13
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.js.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts +0 -5
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js +0 -19
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.d.ts +0 -56
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.js +0 -379
- package/build/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.d.ts +0 -5
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.d.ts.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.js +0 -26
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.js.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.d.ts +0 -55
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts +0 -11
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js +0 -13
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.js.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.d.ts +0 -41
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.js +0 -119
- package/build/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.js.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts +0 -11
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js +0 -13
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.js.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.d.ts +0 -41
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.d.ts.map +0 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.js +0 -119
- package/build/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.js.map +0 -1
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.d.ts +0 -6
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.d.ts.map +0 -1
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.js +0 -47
- package/build/_modules/bot/_services/bot-messaging-provider-factory.service.js.map +0 -1
- package/src/_modules/assistant/_services/ass.service-base.ts +0 -100
- package/src/_modules/bot/_collections/bot-operations.util.ts +0 -149
- package/src/_modules/bot/_models/bot-channel.interface.ts +0 -7
- package/src/_modules/bot/_models/bot-message.interface.ts +0 -14
- package/src/_modules/bot/_models/bot-messaging-provider.interface.ts +0 -88
- package/src/_modules/bot/_models/bot-user.interface.ts +0 -7
- package/src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts +0 -18
- package/src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts +0 -20
- package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.service.ts +0 -475
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.ts +0 -26
- package/src/_modules/bot/_modules/dynamo-bot/_services/dyb-messaging-provider.service.ts +0 -403
- package/src/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.ts +0 -18
- package/src/_modules/bot/_modules/slack-bot/_services/slb-messaging-provider.service.ts +0 -156
- package/src/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.ts +0 -18
- package/src/_modules/bot/_modules/teams-bot/_services/teb-messaging-provider.service.ts +0 -156
- package/src/_modules/bot/_services/bot-messaging-provider-factory.service.ts +0 -56
package/src/_modules/bot/_modules/discord-bot/_services/dib-messaging-provider.control-service.ts
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import { Client, GatewayIntentBits, Guild, Collection, GuildMember, Message, Partials, Role, TextChannel, Channel, DMChannel } from 'discord.js';
|
|
2
|
+
import { DyFM_AnyError, DyFM_Error, DyFM_Log, week } from '@futdevpro/fsm-dynamo';
|
|
3
|
+
import { DyNTS_Bot_MessagingProvider_ServiceBase, DyNTS_Bot_MessagingProvider_Config } from '../../../_services/bot-messaging-provider.service-base';
|
|
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_MessagingProvider_Type } from '../../../_enums/bot-message-provider.enum';
|
|
7
|
+
import { DyNTS_global_settings } from '../../../../../_collections/global-settings.const';
|
|
8
|
+
import { DyNTS_Bot_ChannelWrapper } from '../../../_models/bot-channel-wrapper.interface';
|
|
9
|
+
import { DyNTS_Bot_MessageWrapper } from '../../../_models/bot-message-wrapper.interface';
|
|
10
|
+
import { DyNTS_Bot_UserWrapper } from '../../../_models/bot-user-wrapper.interface';
|
|
11
|
+
|
|
12
|
+
export type DyNTS_DiB_Message = DyNTS_Bot_MessageWrapper<Message>;
|
|
13
|
+
export type DyNTS_DiB_Channel = DyNTS_Bot_ChannelWrapper<Channel>;
|
|
14
|
+
export type DyNTS_DiB_User = DyNTS_Bot_UserWrapper<GuildMember>;
|
|
15
|
+
|
|
16
|
+
export interface Discord_MessagingProviderConfig extends DyNTS_Bot_MessagingProvider_Config {
|
|
17
|
+
token: string;
|
|
18
|
+
guildId: string;
|
|
19
|
+
clientId: string;
|
|
20
|
+
oauth2Url: string;
|
|
21
|
+
intents: GatewayIntentBits[];
|
|
22
|
+
partials: Partials[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class DyNTS_DiB_MessagingProvider_ControlService extends DyNTS_Bot_MessagingProvider_ServiceBase<
|
|
26
|
+
Channel,
|
|
27
|
+
Message,
|
|
28
|
+
GuildMember,
|
|
29
|
+
Discord_MessagingProviderConfig,
|
|
30
|
+
Role
|
|
31
|
+
> {
|
|
32
|
+
readonly name = 'discord';
|
|
33
|
+
readonly type = DyNTS_Bot_MessagingProvider_Type.discord;
|
|
34
|
+
|
|
35
|
+
get botId(): string {
|
|
36
|
+
return this.client.user?.id;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get botDisplayName(): string {
|
|
40
|
+
return this.client.user?.displayName;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override readonly config: Discord_MessagingProviderConfig;
|
|
44
|
+
|
|
45
|
+
private client: Client;
|
|
46
|
+
private guild: Guild;
|
|
47
|
+
|
|
48
|
+
constructor(
|
|
49
|
+
setConfig: Discord_MessagingProviderConfig
|
|
50
|
+
) {
|
|
51
|
+
super();
|
|
52
|
+
|
|
53
|
+
this.config = setConfig;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Public accessors for Discord-specific objects (for backward compatibility with CCAP)
|
|
57
|
+
get discordClient(): Client {
|
|
58
|
+
return this.client;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get discordGuild(): Guild {
|
|
62
|
+
return this.guild;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async setup(issuer: string): Promise<void> {
|
|
66
|
+
try {
|
|
67
|
+
this.client = new Client({
|
|
68
|
+
intents: this.config.intents,
|
|
69
|
+
partials: this.config.partials,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
} catch (error) {
|
|
73
|
+
DyFM_Error.logSimple('Error during Discord bot setup:', error);
|
|
74
|
+
|
|
75
|
+
throw new DyFM_Error({
|
|
76
|
+
...this.getDefaultErrorSettings('setup', error, issuer),
|
|
77
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiB-MessagingProvider-S000`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async start(issuer: string): Promise<void> {
|
|
83
|
+
try {
|
|
84
|
+
if (!this.client) {
|
|
85
|
+
throw new Error('Discord client not initialized. Call setup() first.');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
this.client.on('ready', async () => {
|
|
90
|
+
if (DyNTS_global_settings.bot_settings?.debugLevel >= 1) {
|
|
91
|
+
DyFM_Log.success(`Discord bot logged in as ${this.client.user?.tag}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Get guild
|
|
95
|
+
this.guild = this.client.guilds.cache.get(this.config.guildId);
|
|
96
|
+
if (!this.guild) {
|
|
97
|
+
reject(new Error(`Discord server not found with ID: ${this.config.guildId}`));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
resolve();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.client.login(this.config.token).catch(reject);
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
DyFM_Error.logSimple('Error during Discord bot start:', error);
|
|
108
|
+
|
|
109
|
+
throw new DyFM_Error({
|
|
110
|
+
...this.getDefaultErrorSettings('start', error, issuer),
|
|
111
|
+
errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiB-MessagingProvider-S001`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async getChannelByName(name: string): Promise<DyNTS_DiB_Channel> {
|
|
117
|
+
if (this.channelCache.has(name)) {
|
|
118
|
+
return this.wrapChannel(this.channelCache.get(name));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const channel = this.guild.channels.cache.find(
|
|
122
|
+
(ch) => ch.name === name && ch.isTextBased()
|
|
123
|
+
) as TextChannel;
|
|
124
|
+
|
|
125
|
+
if (!channel) {
|
|
126
|
+
throw new Error(`No text channel found with name "${name}"`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
this.channelCache.set(name, channel);
|
|
130
|
+
return this.wrapChannel(channel);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async getChannelById(id: string): Promise<DyNTS_DiB_Channel> {
|
|
134
|
+
const channel = this.guild.channels.cache.get(id) as TextChannel;
|
|
135
|
+
if (!channel) {
|
|
136
|
+
throw new Error(`No text channel found with ID "${id}"`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!this.channelCache.has(channel.name)) {
|
|
140
|
+
this.channelCache.set(channel.name, channel);
|
|
141
|
+
}
|
|
142
|
+
return this.wrapChannel(channel);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async sendMessageToChannelByName(channelName: string, message: string): Promise<DyNTS_DiB_Message> {
|
|
146
|
+
const discordChannel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
147
|
+
|
|
148
|
+
if (!discordChannel.rawPlatformChannel.isTextBased()) {
|
|
149
|
+
throw new Error(`Channel "${channelName}" is not a text channel`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const sentMessage: Message = await (discordChannel.rawPlatformChannel as TextChannel).send(message);
|
|
153
|
+
|
|
154
|
+
return this.wrapMessage(sentMessage);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async getMessagesFromChannelByChannelName(channelName: string, limit: number = 100): Promise<DyNTS_DiB_Message[]> {
|
|
158
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
159
|
+
|
|
160
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
161
|
+
throw new Error(`Channel "${channelName}" is not a text channel`);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const messages: Collection<string, Message> = await (channel.rawPlatformChannel as TextChannel).messages.fetch({
|
|
165
|
+
limit: limit
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return Array.from(messages.values()).map((msg: Message) => this.wrapMessage(msg));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async getLastMessageInChannel(channelName: string): Promise<DyNTS_DiB_Message> {
|
|
172
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
173
|
+
|
|
174
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
175
|
+
throw new Error(`Channel "${channelName}" is not a text channel`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const messages: Collection<string, Message> = await (channel.rawPlatformChannel as TextChannel).messages.fetch({
|
|
179
|
+
limit: 1
|
|
180
|
+
});
|
|
181
|
+
const lastMessage: Message = messages.first();
|
|
182
|
+
|
|
183
|
+
return lastMessage ? this.wrapMessage(lastMessage) : null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async clearChannel(channel: DyNTS_DiB_Channel): Promise<void> {
|
|
187
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
188
|
+
throw new Error(`Channel "${channel.name}" is not a text channel`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let lastId: string | undefined = undefined;
|
|
192
|
+
let fetched: number = 0;
|
|
193
|
+
const maxFetch: number = 1000;
|
|
194
|
+
|
|
195
|
+
while (fetched < maxFetch) {
|
|
196
|
+
const options: { limit: number; before?: string } = { limit: 100 };
|
|
197
|
+
if (lastId) {
|
|
198
|
+
options.before = lastId;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const messageCollection: Collection<string, Message> = await channel.rawPlatformChannel.messages.fetch(options);
|
|
202
|
+
if (messageCollection.size === 0) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const deletePromises = Array.from(messageCollection.values()).map((message: Message) =>
|
|
207
|
+
message.delete().catch((error) => {
|
|
208
|
+
DyFM_Error.logSimple('Failed to delete message', error);
|
|
209
|
+
})
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
await Promise.all(deletePromises);
|
|
213
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
214
|
+
fetched += messageCollection.size;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Message operations
|
|
219
|
+
async sendMessage(channel: DyNTS_DiB_Channel, content: string): Promise<DyNTS_DiB_Message> {
|
|
220
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
221
|
+
throw new Error(`Channel "${channel.name}" is not a text channel`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const message: Message = await (channel.rawPlatformChannel as TextChannel).send(content);
|
|
225
|
+
return this.wrapMessage(message);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async replyToMessage(message: DyNTS_DiB_Message, content: string): Promise<DyNTS_DiB_Message> {
|
|
229
|
+
/* const channel = this.guild.channels.cache.get(channelId) as TextChannel;
|
|
230
|
+
if (!channel) {
|
|
231
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
232
|
+
}
|
|
233
|
+
const message = await channel.messages.fetch(messageId); */
|
|
234
|
+
if (!message.rawPlatformMessage.channel.isTextBased()) {
|
|
235
|
+
throw new Error(`Message "${message.id}" is not a text message`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const reply: Message= await message.rawPlatformMessage.reply(content);
|
|
239
|
+
return this.wrapMessage(reply);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async sendTyping(channel: DyNTS_DiB_Channel): Promise<void> {
|
|
243
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
244
|
+
throw new Error(`Channel "${channel.name}" is not a text channel`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
await (channel.rawPlatformChannel as TextChannel).sendTyping();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async sendTypingForMessage(message: DyNTS_DiB_Message): Promise<void> {
|
|
251
|
+
if (!message.rawPlatformMessage.channel.isTextBased()) {
|
|
252
|
+
throw new Error(`Message "${message.id}" is not a text message`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
await (message.rawPlatformMessage.channel as TextChannel).sendTyping();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async fetchMessages(channel: DyNTS_DiB_Channel, limit: number): Promise<DyNTS_DiB_Message[]> {
|
|
259
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
260
|
+
throw new Error(`Channel "${channel.name}" is not a text channel`);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const messages: Collection<string, Message> = await (channel.rawPlatformChannel as TextChannel).messages.fetch({
|
|
264
|
+
limit: limit
|
|
265
|
+
});
|
|
266
|
+
return Array.from(messages.values()).map((msg: Message) => this.wrapMessage(msg));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async fetchMessagesById(id: string, limit: number): Promise<DyNTS_DiB_Message[]> {
|
|
270
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelById(id);
|
|
271
|
+
return this.fetchMessages(channel, limit);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async fetchMessagesForMessage(message: DyNTS_DiB_Message, limit: number): Promise<DyNTS_DiB_Message[]> {
|
|
275
|
+
if (!message.rawPlatformMessage.channel.isTextBased()) {
|
|
276
|
+
throw new Error(`Message "${message.id}" is not a text message`);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const messages: Collection<string, Message> = await message.rawPlatformMessage.channel.messages.fetch({
|
|
280
|
+
limit: limit
|
|
281
|
+
});
|
|
282
|
+
return Array.from(messages.values()).map((msg: Message) => this.wrapMessage(msg));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async fetchAllMessagesWithPaging(channel: DyNTS_DiB_Channel, maxFetch: number = 1000): Promise<DyNTS_DiB_Message[]> {
|
|
286
|
+
if (!channel.rawPlatformChannel.isTextBased()) {
|
|
287
|
+
throw new Error(`Channel "${channel.name}" is not a text channel`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
let lastId: string | undefined = undefined;
|
|
291
|
+
let fetched: number = 0;
|
|
292
|
+
const allMessages: DyNTS_DiB_Message[] = [];
|
|
293
|
+
|
|
294
|
+
while (fetched < maxFetch) {
|
|
295
|
+
const options: { limit: number; before?: string } = { limit: 100 };
|
|
296
|
+
if (lastId) options.before = lastId;
|
|
297
|
+
|
|
298
|
+
const messageCollection: Collection<string, Message> = await channel.rawPlatformChannel.messages.fetch(options);
|
|
299
|
+
if (messageCollection.size === 0) break;
|
|
300
|
+
|
|
301
|
+
Array.from(messageCollection.values()).forEach((msg: Message) => {
|
|
302
|
+
allMessages.push(this.wrapMessage(msg));
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
306
|
+
fetched += messageCollection.size;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return allMessages;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async deleteMessage(message: DyNTS_DiB_Message): Promise<void> {
|
|
313
|
+
await message.rawPlatformMessage.delete();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// User operations
|
|
317
|
+
async getUserByName(username: string): Promise<DyNTS_DiB_User> {
|
|
318
|
+
const member: GuildMember = this.guild.members.cache.find((m: GuildMember) => m.user.username === username);
|
|
319
|
+
|
|
320
|
+
if (!member) {
|
|
321
|
+
throw new Error(`User not found with username: ${username}`);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return this.wrapUser(member);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
getUserMention(userId: string): string {
|
|
328
|
+
return `<@${userId}>`;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async readMembersInChannel(channelName: string): Promise<DyNTS_DiB_User[]> {
|
|
332
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
333
|
+
const members: Collection<string, GuildMember> = await this.guild.members.fetch();
|
|
334
|
+
|
|
335
|
+
const allowedMembers: Collection<string, GuildMember> = members.filter((member: GuildMember) =>
|
|
336
|
+
channel.rawPlatformChannel.isTextBased() &&
|
|
337
|
+
(channel.rawPlatformChannel as TextChannel).permissionsFor(member)?.has('ViewChannel')
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
return Array.from(allowedMembers.values()).map((member: GuildMember) => this.wrapUser(member));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async readMemberNamesInChannel(channelName: string): Promise<string[]> {
|
|
344
|
+
const members: DyNTS_DiB_User[] = await this.readMembersInChannel(channelName);
|
|
345
|
+
return members.map((member: DyNTS_DiB_User) => member.username);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Advanced message queries
|
|
349
|
+
async getLastMessageSentBy(channelName: string, username: string): Promise<DyNTS_DiB_Message> {
|
|
350
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
351
|
+
const messages: DyNTS_DiB_Message[] = await this.fetchAllMessagesWithPaging(channel, 1000);
|
|
352
|
+
|
|
353
|
+
return messages.find((msg: DyNTS_DiB_Message) => msg.authorName === username) || null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
async getLastMentionOf(channelName: string, username: string): Promise<DyNTS_DiB_Message> {
|
|
357
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
358
|
+
const messages: DyNTS_DiB_Message[] = await this.fetchAllMessagesWithPaging(channel, 1000);
|
|
359
|
+
|
|
360
|
+
return messages.find((msg: DyNTS_DiB_Message) =>
|
|
361
|
+
msg.content.includes(`@${username}`) ||
|
|
362
|
+
msg.content.includes(`<@${username}>`)
|
|
363
|
+
) || null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Advanced message queries
|
|
367
|
+
async readLastMessageDatesByMembers(channelName: string, memberNames: string[]): Promise<DyNTS_Bot_LastMessageDate[]> {
|
|
368
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
369
|
+
const messages: DyNTS_DiB_Message[] = await this.fetchAllMessagesWithPaging(channel, 1000);
|
|
370
|
+
|
|
371
|
+
const memberStatus: Record<string, { lastMessageDate: Date | null, allMessages: number }> = {};
|
|
372
|
+
memberNames.forEach((name: string) => {
|
|
373
|
+
memberStatus[name] = { lastMessageDate: null, allMessages: 0 };
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const cutoffTime: number = Date.now() - (3 * week); // 3 weeks
|
|
377
|
+
|
|
378
|
+
messages.forEach((message: DyNTS_DiB_Message) => {
|
|
379
|
+
if (message.timestamp < cutoffTime) return;
|
|
380
|
+
|
|
381
|
+
const author = message.authorName;
|
|
382
|
+
if (memberStatus[author] !== undefined) {
|
|
383
|
+
memberStatus[author].allMessages++;
|
|
384
|
+
if (!memberStatus[author].lastMessageDate) {
|
|
385
|
+
memberStatus[author].lastMessageDate = new Date(message.timestamp);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
return memberNames.map((memberName: string) => {
|
|
391
|
+
const status: { lastMessageDate: Date | null, allMessages: number } = memberStatus[memberName];
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
memberName: memberName,
|
|
395
|
+
allMessages: status.allMessages,
|
|
396
|
+
lastMessageDate: status.lastMessageDate
|
|
397
|
+
};
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Advanced message queries
|
|
402
|
+
async readLastMessageWithMemberNamePingInIt(channelName: string, users: DyNTS_DiB_User[]): Promise<DyNTS_Bot_LastMentionDate[]> {
|
|
403
|
+
const channel: DyNTS_DiB_Channel = await this.getChannelByName(channelName);
|
|
404
|
+
const messages: DyNTS_DiB_Message[] = await this.fetchAllMessagesWithPaging(channel, 1000);
|
|
405
|
+
|
|
406
|
+
const memberStatus: Record<string, { lastMentionDate: Date | null, allMentions: number }> = {};
|
|
407
|
+
users.forEach((user: DyNTS_DiB_User) => {
|
|
408
|
+
memberStatus[user.username] = { lastMentionDate: null, allMentions: 0 };
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
const cutoffTime: number = Date.now() - (3 * week); // 3 weeks
|
|
412
|
+
|
|
413
|
+
messages.forEach((message: DyNTS_DiB_Message) => {
|
|
414
|
+
if (message.timestamp < cutoffTime) return;
|
|
415
|
+
|
|
416
|
+
users.forEach((user: DyNTS_DiB_User) => {
|
|
417
|
+
if (
|
|
418
|
+
message.content.includes(`@${user.id}`) &&
|
|
419
|
+
!memberStatus[user.username].lastMentionDate
|
|
420
|
+
) {
|
|
421
|
+
memberStatus[user.username].lastMentionDate = new Date(message.timestamp);
|
|
422
|
+
memberStatus[user.username].allMentions++;
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
return users.map((user: DyNTS_DiB_User) => {
|
|
428
|
+
const status: { lastMentionDate: Date | null, allMentions: number } = memberStatus[user.username];
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
memberId: user.id,
|
|
432
|
+
memberName: user.username,
|
|
433
|
+
allMentions: status.allMentions,
|
|
434
|
+
lastMentionDate: status.lastMentionDate
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// Discord-specific features
|
|
440
|
+
getRoleByName(roleName: string): Role {
|
|
441
|
+
if (this.roleCache.has(roleName)) {
|
|
442
|
+
return this.roleCache.get(roleName);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const role: Role = this.guild.roles.cache.find((r: Role) => r.name === roleName);
|
|
446
|
+
if (role) {
|
|
447
|
+
this.roleCache.set(roleName, role);
|
|
448
|
+
}
|
|
449
|
+
return role;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async getRolePingByName(roleName: string): Promise<string> {
|
|
453
|
+
const role: Role = this.getRoleByName(roleName);
|
|
454
|
+
return role ? `<@&${role.id}>` : '';
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async getRolePingsByName(roleNames: string[]): Promise<string> {
|
|
458
|
+
const pings: string[] = await Promise.all(
|
|
459
|
+
roleNames.map((roleName: string) => this.getRolePingByName(roleName))
|
|
460
|
+
);
|
|
461
|
+
return pings.join(' ');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
create_onMessageEventListener(handler: (message: DyNTS_DiB_Message, issuer: string) => void): void {
|
|
465
|
+
this.client.on('messageCreate', (message: Message) => {
|
|
466
|
+
handler(this.wrapMessage(message), 'discord');
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
create_onErrorEventListener(handler: (error: DyFM_AnyError) => void): void {
|
|
471
|
+
this.client.on('error', (error: Error) => {
|
|
472
|
+
handler(error);
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
async sendReport(message: string): Promise<DyNTS_DiB_Message> {
|
|
477
|
+
return await this.sendMessageToChannelByName(this.config.reportChannelName, message);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
async sendReportIn(message: string): Promise<DyNTS_DiB_Message> {
|
|
481
|
+
return await this.sendMessageToChannelByName(
|
|
482
|
+
this.config.reportChannelName,
|
|
483
|
+
`${this.botDisplayName} report for duty! ` +
|
|
484
|
+
`(v${DyNTS_global_settings.systemVersion} ${DyNTS_global_settings.env_settings?.environment})`
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
wrapMessage(message: Message): DyNTS_DiB_Message {
|
|
489
|
+
return {
|
|
490
|
+
id: message.id,
|
|
491
|
+
content: message.content,
|
|
492
|
+
authorId: message.author.id,
|
|
493
|
+
authorName: message.author.username,
|
|
494
|
+
authorDisplayName: message.author.displayName,
|
|
495
|
+
channelId: message.channel.id,
|
|
496
|
+
channelName: (message.channel as TextChannel)?.name || 'DM Channel with ' + (message.channel as DMChannel).recipient.username,
|
|
497
|
+
timestamp: message.createdTimestamp,
|
|
498
|
+
isBot: message.author.bot,
|
|
499
|
+
replyToMessageId: message.reference?.messageId,
|
|
500
|
+
mentions: Array.from(message.mentions.users.keys()),
|
|
501
|
+
rawPlatformMessage: message,
|
|
502
|
+
provider: this,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
wrapChannel(channel: Channel): DyNTS_DiB_Channel {
|
|
507
|
+
return {
|
|
508
|
+
id: channel.id,
|
|
509
|
+
name: (channel as TextChannel).name || ('DM Channel with ' + (channel as DMChannel).recipient.username),
|
|
510
|
+
isTextBased: channel.isTextBased(),
|
|
511
|
+
isDM: channel.isDMBased(),
|
|
512
|
+
rawPlatformChannel: channel,
|
|
513
|
+
|
|
514
|
+
provider: this,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
wrapUser(user: GuildMember): DyNTS_DiB_User {
|
|
519
|
+
return {
|
|
520
|
+
id: user.user.id,
|
|
521
|
+
username: user.user.username,
|
|
522
|
+
displayName: user.displayName,
|
|
523
|
+
isBot: user.user.bot,
|
|
524
|
+
rawPlatformUser: user,
|
|
525
|
+
|
|
526
|
+
provider: this,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
//
|
|
6
6
|
|
|
7
7
|
// TYPES
|
|
8
|
-
export * from './_models/dib-platform.types';
|
|
8
|
+
/* export * from './_models/dib-platform.types'; */
|
|
9
9
|
|
|
10
10
|
// SERVICES
|
|
11
|
-
export * from './_services/dib-messaging-provider.service';
|
|
11
|
+
export * from './_services/dib-messaging-provider.control-service';
|
|
12
12
|
|
|
13
|
-
// COLLECTIONS
|
|
14
|
-
export * from './_collections/dib-operations.util';
|
|
15
|
-
export * from './_collections/dib.util';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DyFM_Error, DyFM_Log } from '@futdevpro/fsm-dynamo';
|
|
2
|
-
import {
|
|
2
|
+
import { DyNTS_DyB_MessagingProvider_ControlService } from '../_services/dyb-messaging-provider.control-service';
|
|
3
3
|
import { DyNTS_DyB_Message, DyNTS_DyB_Channel } from '../_models/dyb-platform.types';
|
|
4
4
|
|
|
5
5
|
export class DyNTS_DyB_Operations_Util {
|
|
@@ -7,13 +7,16 @@ export class DyNTS_DyB_Operations_Util {
|
|
|
7
7
|
/**
|
|
8
8
|
* Get conversation statistics
|
|
9
9
|
*/
|
|
10
|
-
static async getConversationStats(
|
|
10
|
+
static async getConversationStats(
|
|
11
|
+
provider: DyNTS_DyB_MessagingProvider_ControlService,
|
|
12
|
+
conversationId: string
|
|
13
|
+
): Promise<{
|
|
11
14
|
messageCount: number;
|
|
12
15
|
participantCount: number;
|
|
13
16
|
lastActivity: Date | null;
|
|
14
17
|
}> {
|
|
15
18
|
try {
|
|
16
|
-
const messages: DyNTS_DyB_Message[] = await provider.
|
|
19
|
+
const messages: DyNTS_DyB_Message[] = await provider.fetchMessagesById(conversationId, 1000);
|
|
17
20
|
const channel: DyNTS_DyB_Channel = await provider.getChannelById(conversationId);
|
|
18
21
|
|
|
19
22
|
return {
|
|
@@ -35,12 +38,12 @@ export class DyNTS_DyB_Operations_Util {
|
|
|
35
38
|
* Search messages in conversation
|
|
36
39
|
*/
|
|
37
40
|
static async searchMessages(
|
|
38
|
-
provider:
|
|
41
|
+
provider: DyNTS_DyB_MessagingProvider_ControlService,
|
|
39
42
|
conversationId: string,
|
|
40
43
|
searchTerm: string
|
|
41
44
|
): Promise<DyNTS_DyB_Message[]> {
|
|
42
45
|
try {
|
|
43
|
-
const messages: DyNTS_DyB_Message[] = await provider.
|
|
46
|
+
const messages: DyNTS_DyB_Message[] = await provider.fetchMessagesById(conversationId, 1000);
|
|
44
47
|
return messages.filter((msg: DyNTS_DyB_Message) =>
|
|
45
48
|
msg.content.toLowerCase().includes(searchTerm.toLowerCase())
|
|
46
49
|
);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { DyNTS_Bot_MessageWrapper } from '../../../_models/bot-message-wrapper.interface';
|
|
2
|
+
import { DyNTS_Bot_ChannelWrapper } from '../../../_models/bot-channel-wrapper.interface';
|
|
3
|
+
import { DyNTS_Bot_UserWrapper } from '../../../_models/bot-user-wrapper.interface';
|
|
4
4
|
import { DyFM_Msg_Message, DyFM_Msg_Conversation, DyFM_Msg_Participant } from '@futdevpro/fsm-dynamo/messaging';
|
|
5
5
|
|
|
6
6
|
// Dynamo Bot Platform-Specific Types
|
|
7
7
|
// Uses messaging system models as the underlying platform
|
|
8
|
-
export type DyNTS_DyB_Message =
|
|
8
|
+
export type DyNTS_DyB_Message = DyNTS_Bot_MessageWrapper<DyFM_Msg_Message>;
|
|
9
9
|
|
|
10
10
|
// Extended channel interface for dynamo bot with participants
|
|
11
|
-
export interface DyNTS_DyB_Channel extends
|
|
11
|
+
export interface DyNTS_DyB_Channel extends DyNTS_Bot_ChannelWrapper<DyFM_Msg_Conversation> {
|
|
12
12
|
participants?: DyFM_Msg_Participant[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export type DyNTS_DyB_User =
|
|
15
|
+
export type DyNTS_DyB_User = DyNTS_Bot_UserWrapper<any>; // Messaging system user (generic)
|