@futdevpro/nts-dynamo 1.14.23 → 1.14.26
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/_services/ai-provider.service-base.d.ts +1 -1
- package/build/_modules/ai/_services/ai-provider.service-base.d.ts.map +1 -1
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.d.ts +39 -0
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.d.ts.map +1 -0
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.js +218 -0
- package/build/_modules/ai/_services/oai-to-ai-adapter.service.js.map +1 -0
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts +4 -3
- package/build/_modules/assistant/_services/ass-io.control-service.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass-io.control-service.js +6 -6
- package/build/_modules/assistant/_services/ass-io.control-service.js.map +1 -1
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts +2 -2
- package/build/_modules/assistant/_services/ass-main.control-service.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass.service-base.d.ts +6 -4
- package/build/_modules/assistant/_services/ass.service-base.d.ts.map +1 -1
- package/build/_modules/assistant/_services/ass.service-base.js +6 -4
- package/build/_modules/assistant/_services/ass.service-base.js.map +1 -1
- package/build/_modules/bot/_collections/bot-operations.util.d.ts +13 -13
- package/build/_modules/bot/_collections/bot-operations.util.d.ts.map +1 -1
- package/build/_modules/bot/_collections/bot-operations.util.js.map +1 -1
- package/build/_modules/bot/_enums/bot-message-provider.enum.d.ts +8 -0
- package/build/_modules/bot/_enums/bot-message-provider.enum.d.ts.map +1 -0
- package/build/_modules/bot/_enums/bot-message-provider.enum.js +12 -0
- package/build/_modules/bot/_enums/bot-message-provider.enum.js.map +1 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts +7 -0
- package/build/_modules/bot/_models/bot-global-settings.interface.d.ts.map +1 -1
- package/build/_modules/bot/_models/bot-message-provider.interface.d.ts +68 -0
- package/build/_modules/bot/_models/bot-message-provider.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-message-provider.interface.js +3 -0
- package/build/_modules/bot/_models/bot-message-provider.interface.js.map +1 -0
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts +21 -0
- package/build/_modules/bot/_models/bot-message-wrapper.interface.d.ts.map +1 -0
- package/build/_modules/bot/_models/bot-message-wrapper.interface.js +3 -0
- package/build/_modules/bot/_models/bot-message-wrapper.interface.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts +2 -2
- package/build/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts +2 -2
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_collections/dib.util.js.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.d.ts +56 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.js +379 -0
- package/build/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/discord-bot/index.d.ts +1 -1
- package/build/_modules/bot/_modules/discord-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/discord-bot/index.js +1 -1
- 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.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.d.ts +2 -2
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.js.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-message-provider.service.d.ts +55 -0
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-message-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-message-provider.service.js +313 -0
- package/build/_modules/bot/_modules/dynamo-bot/_services/dyb-message-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/dynamo-bot/index.d.ts +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/index.js +1 -1
- package/build/_modules/bot/_modules/dynamo-bot/index.js.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts +2 -2
- package/build/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/_services/slb-message-provider.service.d.ts +41 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-message-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-message-provider.service.js +119 -0
- package/build/_modules/bot/_modules/slack-bot/_services/slb-message-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/slack-bot/index.d.ts +1 -1
- package/build/_modules/bot/_modules/slack-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/slack-bot/index.js +1 -1
- package/build/_modules/bot/_modules/slack-bot/index.js.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts +2 -2
- package/build/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.d.ts.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/_services/teb-message-provider.service.d.ts +41 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-message-provider.service.d.ts.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-message-provider.service.js +119 -0
- package/build/_modules/bot/_modules/teams-bot/_services/teb-message-provider.service.js.map +1 -0
- package/build/_modules/bot/_modules/teams-bot/index.d.ts +1 -1
- package/build/_modules/bot/_modules/teams-bot/index.d.ts.map +1 -1
- package/build/_modules/bot/_modules/teams-bot/index.js +1 -1
- package/build/_modules/bot/_modules/teams-bot/index.js.map +1 -1
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts +4 -3
- package/build/_modules/bot/_services/bot-commands.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-commands.control-service.js +3 -2
- package/build/_modules/bot/_services/bot-commands.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-io.control-service.d.ts +7 -6
- package/build/_modules/bot/_services/bot-io.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-io.control-service.js +38 -17
- package/build/_modules/bot/_services/bot-io.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-main.control-service.d.ts +15 -2
- package/build/_modules/bot/_services/bot-main.control-service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-main.control-service.js +105 -1
- package/build/_modules/bot/_services/bot-main.control-service.js.map +1 -1
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts +3 -2
- package/build/_modules/bot/_services/bot-provider-factory.service.d.ts.map +1 -1
- package/build/_modules/bot/_services/bot-provider-factory.service.js +34 -18
- package/build/_modules/bot/_services/bot-provider-factory.service.js.map +1 -1
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts +2 -2
- package/build/_modules/bot/_services/bot-routines.control-service.d.ts.map +1 -1
- package/build/_modules/bot/index.d.ts +3 -2
- package/build/_modules/bot/index.d.ts.map +1 -1
- package/build/_modules/bot/index.js +3 -2
- package/build/_modules/bot/index.js.map +1 -1
- package/package.json +12 -1
- package/src/_modules/ai/_services/ai-provider.service-base.ts +1 -1
- package/src/_modules/assistant/_services/ass-io.control-service.ts +14 -9
- package/src/_modules/assistant/_services/ass-main.control-service.ts +3 -3
- package/src/_modules/assistant/_services/ass.service-base.ts +13 -5
- package/src/_modules/bot/_collections/bot-operations.util.ts +14 -14
- package/src/_modules/bot/_enums/{bot-provider.enum.ts → bot-message-provider.enum.ts} +1 -1
- package/src/_modules/bot/_models/bot-global-settings.interface.ts +9 -0
- package/src/_modules/bot/_models/{bot-provider.interface.ts → bot-message-provider.interface.ts} +10 -7
- package/src/_modules/bot/_models/bot-message-wrapper.interface.ts +31 -0
- package/src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts +2 -2
- package/src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts +2 -2
- package/src/_modules/bot/_modules/discord-bot/_services/{dib-provider.service.ts → dib-message-provider.service.ts} +20 -7
- package/src/_modules/bot/_modules/discord-bot/index.ts +1 -1
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb-operations.util.ts +3 -3
- package/src/_modules/bot/_modules/dynamo-bot/_collections/dyb.util.ts +2 -2
- package/src/_modules/bot/_modules/dynamo-bot/_services/{dyb-provider.service.ts → dyb-message-provider.service.ts} +12 -8
- package/src/_modules/bot/_modules/dynamo-bot/index.ts +1 -1
- package/src/_modules/bot/_modules/slack-bot/_collections/slb-operations.util.ts +2 -2
- package/src/_modules/bot/_modules/slack-bot/_services/{slb-provider.service.ts → slb-message-provider.service.ts} +11 -7
- package/src/_modules/bot/_modules/slack-bot/index.ts +1 -1
- package/src/_modules/bot/_modules/teams-bot/_collections/teb-operations.util.ts +2 -2
- package/src/_modules/bot/_modules/teams-bot/_services/{teb-provider.service.ts → teb-message-provider.service.ts} +11 -7
- package/src/_modules/bot/_modules/teams-bot/index.ts +1 -1
- package/src/_modules/bot/_services/bot-commands.control-service.ts +8 -6
- package/src/_modules/bot/_services/bot-io.control-service.ts +49 -23
- package/src/_modules/bot/_services/bot-main.control-service.ts +130 -5
- package/src/_modules/bot/_services/bot-provider-factory.service.ts +42 -20
- package/src/_modules/bot/_services/bot-routines.control-service.ts +3 -3
- package/src/_modules/bot/index.ts +3 -2
- package/src/_modules/messaging/README.md +359 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DyNTS_Bot_Command } from './bot-command.interface';
|
|
2
|
+
import { DyNTS_Bot_MessageProvider_Config } from './bot-message-provider.interface';
|
|
2
3
|
export interface DyNTS_Bot_Global_Settings {
|
|
3
4
|
/**
|
|
4
5
|
* this setting will set the debug level for the bot
|
|
@@ -76,4 +77,10 @@ export interface DyNTS_Bot_Global_Settings {
|
|
|
76
77
|
};
|
|
77
78
|
allowBotsInteractEachOther: boolean;
|
|
78
79
|
}
|
|
80
|
+
export interface DyNTS_Bot_MultiMessageProvider_Settings {
|
|
81
|
+
/** Array of provider configurations (use for multiple providers) */
|
|
82
|
+
providers: DyNTS_Bot_MessageProvider_Config[];
|
|
83
|
+
}
|
|
84
|
+
/** Union type supporting both single and multi-provider configurations */
|
|
85
|
+
export type DyNTS_Bot_Settings = DyNTS_Bot_MessageProvider_Config | (DyNTS_Bot_Global_Settings & DyNTS_Bot_MultiMessageProvider_Settings);
|
|
79
86
|
//# sourceMappingURL=bot-global-settings.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot-global-settings.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-global-settings.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"bot-global-settings.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-global-settings.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CAAC;AAEpF,MAAM,WAAW,yBAAyB;IACxC;;;;;;;;;;;;OAYG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB,YAAY,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC;IAE/B,eAAe,EAAE;QACf;;;WAGG;QACH,qBAAqB,EAAE,MAAM,CAAC;QAC9B;;;WAGG;QACH,sBAAsB,EAAE,MAAM,CAAC;QAC/B;;;WAGG;QACH,gBAAgB,EAAE,MAAM,CAAC;QAEzB;;;;;WAKG;QACH,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IAEF;;OAEG;IACH,eAAe,EAAE;QACf;;;;WAIG;QACH,iBAAiB,EAAE,MAAM,CAAC;QAE1B;;;;;WAKG;QACH,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B;;;;WAIG;QACH,WAAW,EAAE,OAAO,CAAC;QAErB;;;;;WAKG;QACH,eAAe,EAAE,MAAM,EAAE,CAAC;KAC3B,CAAC;IAEF,eAAe,EAAE;QACf,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;KAC/B,CAAC;IAEF,0BAA0B,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,uCAAuC;IACtD,oEAAoE;IACpE,SAAS,EAAE,gCAAgC,EAAE,CAAC;CAC/C;AAED,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG,gCAAgC,GAAG,CAAC,yBAAyB,GAAG,uCAAuC,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DyNTS_Bot_Message } from './bot-message.interface';
|
|
2
|
+
import { DyNTS_Bot_Channel } from './bot-channel.interface';
|
|
3
|
+
import { DyNTS_Bot_User } from './bot-user.interface';
|
|
4
|
+
import { DyNTS_Bot_LastMessageDate } from './bot-last-message-date.interface';
|
|
5
|
+
import { DyNTS_Bot_LastMentionDate } from './bot-last-mention-date.interface';
|
|
6
|
+
import { DyNTS_Bot_MessageProvider_Type } from '../_enums/bot-message-provider.enum';
|
|
7
|
+
import { DyNTS_Bot_Global_Settings } from './bot-global-settings.interface';
|
|
8
|
+
export interface DyNTS_Bot_MessageProvider_Config extends DyNTS_Bot_Global_Settings {
|
|
9
|
+
/** Unique identifier for this provider instance (required when using multiple providers) */
|
|
10
|
+
providerId?: string;
|
|
11
|
+
messageProvider: DyNTS_Bot_MessageProvider_Type;
|
|
12
|
+
messageProviderInstance?: DyNTS_Bot_MessageProvider;
|
|
13
|
+
discord?: {
|
|
14
|
+
token: string;
|
|
15
|
+
guildId: string;
|
|
16
|
+
clientId: string;
|
|
17
|
+
oauth2Url: string;
|
|
18
|
+
};
|
|
19
|
+
slack?: {
|
|
20
|
+
token: string;
|
|
21
|
+
workspace: string;
|
|
22
|
+
};
|
|
23
|
+
teams?: {
|
|
24
|
+
appId: string;
|
|
25
|
+
appPassword: string;
|
|
26
|
+
tenantId: string;
|
|
27
|
+
};
|
|
28
|
+
dynamo?: {
|
|
29
|
+
defaultConversationId?: string;
|
|
30
|
+
botUserId?: string;
|
|
31
|
+
botDisplayName?: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface DyNTS_Bot_MessageProvider<T_PlatformChannel extends DyNTS_Bot_Channel<any> = DyNTS_Bot_Channel<any>, T_PlatformMessage extends DyNTS_Bot_Message<any> = DyNTS_Bot_Message<any>, T_PlatformUser extends DyNTS_Bot_User<any> = DyNTS_Bot_User<any>> {
|
|
35
|
+
initialize(config: DyNTS_Bot_MessageProvider_Config): Promise<void>;
|
|
36
|
+
login(token: string): Promise<void>;
|
|
37
|
+
getChannelByName(name: string): Promise<T_PlatformChannel>;
|
|
38
|
+
sendMessageToChannelByName(channelName: string, message: string): Promise<T_PlatformMessage>;
|
|
39
|
+
getMessagesFromChannelByChannelName(channelName: string, limit?: number): Promise<T_PlatformMessage[]>;
|
|
40
|
+
getLastMessageInChannel(channelName: string): Promise<T_PlatformMessage>;
|
|
41
|
+
clearChannel(channelId: string): Promise<void>;
|
|
42
|
+
sendMessage(channelId: string, content: string): Promise<T_PlatformMessage>;
|
|
43
|
+
replyToMessage(messageId: string, channelId: string, content: string): Promise<T_PlatformMessage>;
|
|
44
|
+
sendTyping(channelId: string): Promise<void>;
|
|
45
|
+
fetchMessages(channelId: string, limit: number): Promise<T_PlatformMessage[]>;
|
|
46
|
+
fetchAllMessagesWithPaging(channelId: string, maxFetch?: number): Promise<T_PlatformMessage[]>;
|
|
47
|
+
deleteMessage(messageId: string, channelId: string): Promise<void>;
|
|
48
|
+
getUserByName(username: string): Promise<T_PlatformUser>;
|
|
49
|
+
getUserMention(userId: string): string;
|
|
50
|
+
readMembersInChannel(channelName: string): Promise<T_PlatformUser[]>;
|
|
51
|
+
readMemberNamesInChannel(channelName: string): Promise<string[]>;
|
|
52
|
+
getLastMessageSentBy(channelName: string, username: string): Promise<T_PlatformMessage>;
|
|
53
|
+
getLastMentionOf(channelName: string, username: string): Promise<T_PlatformMessage>;
|
|
54
|
+
readLastMessageDatesByMembers(channelName: string, memberNames: string[]): Promise<DyNTS_Bot_LastMessageDate[]>;
|
|
55
|
+
readLastMessageWithMemberNamePingInIt(channelName: string, users: T_PlatformUser[]): Promise<DyNTS_Bot_LastMentionDate[]>;
|
|
56
|
+
getRoleByName?(roleName: string): any;
|
|
57
|
+
getRolePingByName?(roleName: string): Promise<string>;
|
|
58
|
+
getRolePingsByName?(roleNames: string[]): Promise<string>;
|
|
59
|
+
onMessage(handler: (message: T_PlatformMessage, issuer: string, providerId?: string) => void): void;
|
|
60
|
+
onReady(handler: () => void): void;
|
|
61
|
+
onError(handler: (error: Error) => void): void;
|
|
62
|
+
getBotId(): string;
|
|
63
|
+
getBotDisplayName(): string;
|
|
64
|
+
getProviderName(): string;
|
|
65
|
+
getProviderId(): string;
|
|
66
|
+
isReady(): boolean;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=bot-message-provider.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-message-provider.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-message-provider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,E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;IAC5B,eAAe,IAAI,MAAM,CAAC;IAC1B,aAAa,IAAI,MAAM,CAAC;IACxB,OAAO,IAAI,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-message-provider.interface.js","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-message-provider.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DyNTS_Bot_Message } from './bot-message.interface';
|
|
2
|
+
import { DyNTS_Bot_Channel } from './bot-channel.interface';
|
|
3
|
+
import { DyNTS_Bot_User } from './bot-user.interface';
|
|
4
|
+
import { DyNTS_Bot_MessageProvider } from './bot-message-provider.interface';
|
|
5
|
+
import { DyNTS_Bot_MessageProvider_Type } from '../_enums/bot-message-provider.enum';
|
|
6
|
+
/**
|
|
7
|
+
* Wraps a bot message with provider context
|
|
8
|
+
* This ensures messages include the provider information needed to send replies
|
|
9
|
+
* back through the correct platform
|
|
10
|
+
*/
|
|
11
|
+
export interface DyNTS_Bot_MessageWrapper<T_PlatformMessage extends DyNTS_Bot_Message<any> = DyNTS_Bot_Message<any>> {
|
|
12
|
+
/** The wrapped message */
|
|
13
|
+
message: T_PlatformMessage;
|
|
14
|
+
/** Unique identifier for the provider instance */
|
|
15
|
+
providerId: string;
|
|
16
|
+
/** Type of the provider (discord, slack, teams, dynamo) */
|
|
17
|
+
providerType: DyNTS_Bot_MessageProvider_Type;
|
|
18
|
+
/** Reference to the provider instance for sending replies */
|
|
19
|
+
provider: DyNTS_Bot_MessageProvider<DyNTS_Bot_Channel<any>, T_PlatformMessage, DyNTS_Bot_User<any>>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=bot-message-wrapper.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-message-wrapper.interface.d.ts","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-message-wrapper.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CACvC,iBAAiB,SAAS,iBAAiB,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,GAAG,CAAC;IAEzE,0BAA0B;IAC1B,OAAO,EAAE,iBAAiB,CAAC;IAE3B,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IAEnB,2DAA2D;IAC3D,YAAY,EAAE,8BAA8B,CAAC;IAE7C,6DAA6D;IAC7D,QAAQ,EAAE,yBAAyB,CACjC,iBAAiB,CAAC,GAAG,CAAC,EACtB,iBAAiB,EACjB,cAAc,CAAC,GAAG,CAAC,CACpB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-message-wrapper.interface.js","sourceRoot":"","sources":["../../../../src/_modules/bot/_models/bot-message-wrapper.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DyNTS_Bot_Operations_Util } from '../../../_collections/bot-operations.util';
|
|
2
2
|
import { DyNTS_DiB_Message, DyNTS_DiB_Channel, DyNTS_DiB_User } from '../_models/dib-platform.types';
|
|
3
|
-
import {
|
|
3
|
+
import { DyNTS_DiB_MessageProvider } from '../_services/dib-message-provider.service';
|
|
4
4
|
/**
|
|
5
5
|
* Discord Bot Operations Utility
|
|
6
6
|
*
|
|
7
7
|
* Platform-specific implementation of bot operations for Discord
|
|
8
8
|
*/
|
|
9
|
-
export declare class DyNTS_DiB_Operations_Util extends DyNTS_Bot_Operations_Util<DyNTS_DiB_Channel, DyNTS_DiB_Message, DyNTS_DiB_User,
|
|
9
|
+
export declare class DyNTS_DiB_Operations_Util extends DyNTS_Bot_Operations_Util<DyNTS_DiB_Channel, DyNTS_DiB_Message, DyNTS_DiB_User, DyNTS_DiB_MessageProvider> {
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=dib-operations.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dib-operations.util.d.ts","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dib-operations.util.d.ts","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib-operations.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAEtF;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,yBAAyB,CACtE,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,yBAAyB,CAC1B;CAGA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DyNTS_DiB_MessageProvider } from '../_services/dib-message-provider.service';
|
|
2
2
|
export declare class DyNTS_DiB_Util {
|
|
3
|
-
static reportIn(provider:
|
|
3
|
+
static reportIn(provider: DyNTS_DiB_MessageProvider): Promise<void>;
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=dib.util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dib.util.d.ts","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"dib.util.d.ts","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAGtF,qBAAa,cAAc;WAEZ,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAa1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dib.util.js","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts"],"names":[],"mappings":";;;AAAA,sDAA6D;AAE7D,6FAA0F;AAE1F,MAAa,cAAc;IAEzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"dib.util.js","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_collections/dib.util.ts"],"names":[],"mappings":";;;AAAA,sDAA6D;AAE7D,6FAA0F;AAE1F,MAAa,cAAc;IAEzB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAmC;QACvD,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,GAAG,QAAQ,CAAC,iBAAiB,EAAE,oBAAoB;gBACvE,KAAK,6CAAqB,CAAC,aAAa,IAAI,6CAAqB,CAAC,YAAY,EAAE,WAAW,GAAG,CAAC;YAEjG,MAAM,QAAQ,CAAC,0BAA0B,CACvC,6CAAqB,CAAC,YAAY,EAAE,eAAe,EAAE,iBAAiB,IAAI,aAAa,EACvF,aAAa,CACd,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uBAAU,CAAC,SAAS,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;CACF;AAfD,wCAeC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Client, Guild, Role } from 'discord.js';
|
|
2
|
+
import { DyNTS_Bot_MessageProvider, DyNTS_Bot_MessageProvider_Config } from '../../../_models/bot-message-provider.interface';
|
|
3
|
+
import { DyNTS_Bot_LastMessageDate } from '../../../_models/bot-last-message-date.interface';
|
|
4
|
+
import { DyNTS_Bot_LastMentionDate } from '../../../_models/bot-last-mention-date.interface';
|
|
5
|
+
import { DyNTS_DiB_Message, DyNTS_DiB_Channel, DyNTS_DiB_User } from '../_models/dib-platform.types';
|
|
6
|
+
export declare class DyNTS_DiB_MessageProvider implements DyNTS_Bot_MessageProvider<DyNTS_DiB_Channel, DyNTS_DiB_Message, DyNTS_DiB_User> {
|
|
7
|
+
private client;
|
|
8
|
+
private guild;
|
|
9
|
+
private channelCache;
|
|
10
|
+
private roleCache;
|
|
11
|
+
private isInitialized;
|
|
12
|
+
private config;
|
|
13
|
+
private messageHandlers;
|
|
14
|
+
private readyHandlers;
|
|
15
|
+
private errorHandlers;
|
|
16
|
+
constructor();
|
|
17
|
+
get discordClient(): Client;
|
|
18
|
+
get discordGuild(): Guild;
|
|
19
|
+
initialize(config: DyNTS_Bot_MessageProvider_Config): Promise<void>;
|
|
20
|
+
login(token: string): Promise<void>;
|
|
21
|
+
private setupEventListeners;
|
|
22
|
+
getChannelByName(name: string): Promise<DyNTS_DiB_Channel>;
|
|
23
|
+
sendMessageToChannelByName(channelName: string, message: string): Promise<DyNTS_DiB_Message>;
|
|
24
|
+
getMessagesFromChannelByChannelName(channelName: string, limit?: number): Promise<DyNTS_DiB_Message[]>;
|
|
25
|
+
getLastMessageInChannel(channelName: string): Promise<DyNTS_DiB_Message>;
|
|
26
|
+
clearChannel(channelId: string): Promise<void>;
|
|
27
|
+
sendMessage(channelId: string, content: string): Promise<DyNTS_DiB_Message>;
|
|
28
|
+
replyToMessage(messageId: string, channelId: string, content: string): Promise<DyNTS_DiB_Message>;
|
|
29
|
+
sendTyping(channelId: string): Promise<void>;
|
|
30
|
+
fetchMessages(channelId: string, limit: number): Promise<DyNTS_DiB_Message[]>;
|
|
31
|
+
fetchAllMessagesWithPaging(channelId: string, maxFetch?: number): Promise<DyNTS_DiB_Message[]>;
|
|
32
|
+
deleteMessage(messageId: string, channelId: string): Promise<void>;
|
|
33
|
+
getUserByName(username: string): Promise<DyNTS_DiB_User>;
|
|
34
|
+
getUserMention(userId: string): string;
|
|
35
|
+
readMembersInChannel(channelName: string): Promise<DyNTS_DiB_User[]>;
|
|
36
|
+
readMemberNamesInChannel(channelName: string): Promise<string[]>;
|
|
37
|
+
getLastMessageSentBy(channelName: string, username: string): Promise<DyNTS_DiB_Message>;
|
|
38
|
+
getLastMentionOf(channelName: string, username: string): Promise<DyNTS_DiB_Message>;
|
|
39
|
+
readLastMessageDatesByMembers(channelName: string, memberNames: string[]): Promise<DyNTS_Bot_LastMessageDate[]>;
|
|
40
|
+
readLastMessageWithMemberNamePingInIt(channelName: string, users: DyNTS_DiB_User[]): Promise<DyNTS_Bot_LastMentionDate[]>;
|
|
41
|
+
getRoleByName(roleName: string): Role;
|
|
42
|
+
getRolePingByName(roleName: string): Promise<string>;
|
|
43
|
+
getRolePingsByName(roleNames: string[]): Promise<string>;
|
|
44
|
+
onMessage(handler: (message: DyNTS_DiB_Message, issuer: string) => void): void;
|
|
45
|
+
onReady(handler: () => void): void;
|
|
46
|
+
onError(handler: (error: Error) => void): void;
|
|
47
|
+
getBotId(): string;
|
|
48
|
+
getBotDisplayName(): string;
|
|
49
|
+
getProviderName(): string;
|
|
50
|
+
getProviderId(): string;
|
|
51
|
+
isReady(): boolean;
|
|
52
|
+
private translateMessage;
|
|
53
|
+
private translateChannel;
|
|
54
|
+
private translateUser;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=dib-message-provider.service.d.ts.map
|
package/build/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dib-message-provider.service.d.ts","sourceRoot":"","sources":["../../../../../../src/_modules/bot/_modules/discord-bot/_services/dib-message-provider.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,KAAK,EAA8C,IAAI,EAAe,MAAM,YAAY,CAAC;AAE7H,OAAO,EAAE,yBAAyB,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AAC9H,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGrG,qBAAa,yBAA0B,YAAW,yBAAyB,CACzE,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,CACf;IACC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,MAAM,CAAmC;IAGjD,OAAO,CAAC,eAAe,CAAmE;IAC1F,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,aAAa,CAAqC;;IAQ1D,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,YAAY,IAAI,KAAK,CAExB;IAEK,UAAU,CAAC,MAAM,EAAE,gCAAgC,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BnE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCzC,OAAO,CAAC,mBAAmB;IAUrB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiB1D,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAO5F,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EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAYnF,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAiC/G,qCAAqC,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAqC/H,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAY/B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKpD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ9D,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAI9E,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAIlC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI;IAK9C,QAAQ,IAAI,MAAM;IAIlB,iBAAiB,IAAI,MAAM;IAI3B,eAAe,IAAI,MAAM;IAIzB,aAAa,IAAI,MAAM;IAIvB,OAAO,IAAI,OAAO;IAKlB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DyNTS_DiB_MessageProvider = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
|
|
6
|
+
const bot_message_provider_enum_1 = require("../../../_enums/bot-message-provider.enum");
|
|
7
|
+
const global_settings_const_1 = require("../../../../../_collections/global-settings.const");
|
|
8
|
+
class DyNTS_DiB_MessageProvider {
|
|
9
|
+
client;
|
|
10
|
+
guild;
|
|
11
|
+
channelCache;
|
|
12
|
+
roleCache;
|
|
13
|
+
isInitialized = false;
|
|
14
|
+
config;
|
|
15
|
+
// Event handlers
|
|
16
|
+
messageHandlers = [];
|
|
17
|
+
readyHandlers = [];
|
|
18
|
+
errorHandlers = [];
|
|
19
|
+
constructor() {
|
|
20
|
+
this.channelCache = new Map();
|
|
21
|
+
this.roleCache = new Map();
|
|
22
|
+
}
|
|
23
|
+
// Public accessors for Discord-specific objects (for backward compatibility with CCAP)
|
|
24
|
+
get discordClient() {
|
|
25
|
+
return this.client;
|
|
26
|
+
}
|
|
27
|
+
get discordGuild() {
|
|
28
|
+
return this.guild;
|
|
29
|
+
}
|
|
30
|
+
async initialize(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
if (config.messageProvider !== bot_message_provider_enum_1.DyNTS_Bot_MessageProvider_Type.discord) {
|
|
33
|
+
throw new Error(`Invalid provider type: ${config.messageProvider}. Expected 'discord'`);
|
|
34
|
+
}
|
|
35
|
+
if (!config.discord) {
|
|
36
|
+
throw new Error('Discord configuration is required');
|
|
37
|
+
}
|
|
38
|
+
this.client = new discord_js_1.Client({
|
|
39
|
+
intents: [
|
|
40
|
+
discord_js_1.GatewayIntentBits.Guilds,
|
|
41
|
+
discord_js_1.GatewayIntentBits.GuildMembers,
|
|
42
|
+
discord_js_1.GatewayIntentBits.GuildMessages,
|
|
43
|
+
discord_js_1.GatewayIntentBits.MessageContent,
|
|
44
|
+
discord_js_1.GatewayIntentBits.DirectMessages,
|
|
45
|
+
discord_js_1.GatewayIntentBits.GuildVoiceStates,
|
|
46
|
+
],
|
|
47
|
+
partials: [
|
|
48
|
+
discord_js_1.Partials.Channel,
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
this.isInitialized = true;
|
|
52
|
+
fsm_dynamo_1.DyFM_Log.success('Discord provider initialized');
|
|
53
|
+
}
|
|
54
|
+
async login(token) {
|
|
55
|
+
if (!this.isInitialized) {
|
|
56
|
+
throw new Error('Provider not initialized. Call initialize() first.');
|
|
57
|
+
}
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
this.client.on('ready', async () => {
|
|
60
|
+
if (global_settings_const_1.DyNTS_global_settings.bot_settings?.debugLevel >= 1) {
|
|
61
|
+
fsm_dynamo_1.DyFM_Log.success(`Discord bot logged in as ${this.client.user?.tag}`);
|
|
62
|
+
}
|
|
63
|
+
// Get guild
|
|
64
|
+
this.guild = this.client.guilds.cache.get(this.config.discord.guildId);
|
|
65
|
+
if (!this.guild) {
|
|
66
|
+
reject(new Error(`Discord server not found with ID: ${this.config.discord.guildId}`));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Set up event listeners
|
|
70
|
+
this.setupEventListeners();
|
|
71
|
+
// Trigger ready handlers
|
|
72
|
+
this.readyHandlers.forEach(handler => handler());
|
|
73
|
+
resolve();
|
|
74
|
+
});
|
|
75
|
+
this.client.on('error', (error) => {
|
|
76
|
+
this.errorHandlers.forEach(handler => handler(error));
|
|
77
|
+
reject(error);
|
|
78
|
+
});
|
|
79
|
+
this.client.login(token).catch(reject);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
setupEventListeners() {
|
|
83
|
+
this.client.on('messageCreate', (message) => {
|
|
84
|
+
if (message.author.bot)
|
|
85
|
+
return; // Ignore bot messages
|
|
86
|
+
const botMessage = this.translateMessage(message);
|
|
87
|
+
this.messageHandlers.forEach(handler => handler(botMessage, 'discord-message'));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// Channel operations
|
|
91
|
+
async getChannelByName(name) {
|
|
92
|
+
if (this.channelCache.has(name)) {
|
|
93
|
+
return this.translateChannel(this.channelCache.get(name));
|
|
94
|
+
}
|
|
95
|
+
const channel = this.guild.channels.cache.find((ch) => ch.name === name && ch.isTextBased());
|
|
96
|
+
if (!channel) {
|
|
97
|
+
throw new Error(`No text channel found with name "${name}"`);
|
|
98
|
+
}
|
|
99
|
+
this.channelCache.set(name, channel);
|
|
100
|
+
return this.translateChannel(channel);
|
|
101
|
+
}
|
|
102
|
+
async sendMessageToChannelByName(channelName, message) {
|
|
103
|
+
const channel = await this.getChannelByName(channelName);
|
|
104
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
105
|
+
const sentMessage = await discordChannel.send(message);
|
|
106
|
+
return this.translateMessage(sentMessage);
|
|
107
|
+
}
|
|
108
|
+
async getMessagesFromChannelByChannelName(channelName, limit = 100) {
|
|
109
|
+
const channel = await this.getChannelByName(channelName);
|
|
110
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
111
|
+
const messages = await discordChannel.messages.fetch({ limit });
|
|
112
|
+
return Array.from(messages.values()).map(msg => this.translateMessage(msg));
|
|
113
|
+
}
|
|
114
|
+
async getLastMessageInChannel(channelName) {
|
|
115
|
+
const channel = await this.getChannelByName(channelName);
|
|
116
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
117
|
+
const messages = await discordChannel.messages.fetch({ limit: 1 });
|
|
118
|
+
const lastMessage = messages.first();
|
|
119
|
+
return lastMessage ? this.translateMessage(lastMessage) : null;
|
|
120
|
+
}
|
|
121
|
+
async clearChannel(channelId) {
|
|
122
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
123
|
+
if (!channel) {
|
|
124
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
125
|
+
}
|
|
126
|
+
let lastId = undefined;
|
|
127
|
+
let fetched = 0;
|
|
128
|
+
const maxFetch = 1000;
|
|
129
|
+
while (fetched < maxFetch) {
|
|
130
|
+
const options = { limit: 100 };
|
|
131
|
+
if (lastId)
|
|
132
|
+
options.before = lastId;
|
|
133
|
+
const messageCollection = await channel.messages.fetch(options);
|
|
134
|
+
if (messageCollection.size === 0)
|
|
135
|
+
break;
|
|
136
|
+
const deletePromises = Array.from(messageCollection.values()).map(message => message.delete().catch((error) => {
|
|
137
|
+
fsm_dynamo_1.DyFM_Error.logSimple('Failed to delete message', error);
|
|
138
|
+
}));
|
|
139
|
+
await Promise.all(deletePromises);
|
|
140
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
141
|
+
fetched += messageCollection.size;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Message operations
|
|
145
|
+
async sendMessage(channelId, content) {
|
|
146
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
147
|
+
if (!channel) {
|
|
148
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
149
|
+
}
|
|
150
|
+
const message = await channel.send(content);
|
|
151
|
+
return this.translateMessage(message);
|
|
152
|
+
}
|
|
153
|
+
async replyToMessage(messageId, channelId, content) {
|
|
154
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
155
|
+
if (!channel) {
|
|
156
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
157
|
+
}
|
|
158
|
+
const message = await channel.messages.fetch(messageId);
|
|
159
|
+
const reply = await message.reply(content);
|
|
160
|
+
return this.translateMessage(reply);
|
|
161
|
+
}
|
|
162
|
+
async sendTyping(channelId) {
|
|
163
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
164
|
+
if (!channel) {
|
|
165
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
166
|
+
}
|
|
167
|
+
await channel.sendTyping();
|
|
168
|
+
}
|
|
169
|
+
async fetchMessages(channelId, limit) {
|
|
170
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
171
|
+
if (!channel) {
|
|
172
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
173
|
+
}
|
|
174
|
+
const messages = await channel.messages.fetch({ limit });
|
|
175
|
+
return Array.from(messages.values()).map(msg => this.translateMessage(msg));
|
|
176
|
+
}
|
|
177
|
+
async fetchAllMessagesWithPaging(channelId, maxFetch = 1000) {
|
|
178
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
179
|
+
if (!channel) {
|
|
180
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
181
|
+
}
|
|
182
|
+
let lastId = undefined;
|
|
183
|
+
let fetched = 0;
|
|
184
|
+
const allMessages = [];
|
|
185
|
+
while (fetched < maxFetch) {
|
|
186
|
+
const options = { limit: 100 };
|
|
187
|
+
if (lastId)
|
|
188
|
+
options.before = lastId;
|
|
189
|
+
const messageCollection = await channel.messages.fetch(options);
|
|
190
|
+
if (messageCollection.size === 0)
|
|
191
|
+
break;
|
|
192
|
+
Array.from(messageCollection.values()).forEach((msg) => {
|
|
193
|
+
allMessages.push(this.translateMessage(msg));
|
|
194
|
+
});
|
|
195
|
+
lastId = Array.from(messageCollection.values()).pop()?.id;
|
|
196
|
+
fetched += messageCollection.size;
|
|
197
|
+
}
|
|
198
|
+
return allMessages;
|
|
199
|
+
}
|
|
200
|
+
async deleteMessage(messageId, channelId) {
|
|
201
|
+
const channel = this.guild.channels.cache.get(channelId);
|
|
202
|
+
if (!channel) {
|
|
203
|
+
throw new Error(`Channel not found with ID: ${channelId}`);
|
|
204
|
+
}
|
|
205
|
+
const message = await channel.messages.fetch(messageId);
|
|
206
|
+
await message.delete();
|
|
207
|
+
}
|
|
208
|
+
// User operations
|
|
209
|
+
async getUserByName(username) {
|
|
210
|
+
const member = this.guild.members.cache.find(m => m.user.username === username);
|
|
211
|
+
if (!member) {
|
|
212
|
+
throw new Error(`User not found with username: ${username}`);
|
|
213
|
+
}
|
|
214
|
+
return this.translateUser(member);
|
|
215
|
+
}
|
|
216
|
+
getUserMention(userId) {
|
|
217
|
+
return `<@${userId}>`;
|
|
218
|
+
}
|
|
219
|
+
async readMembersInChannel(channelName) {
|
|
220
|
+
const channel = await this.getChannelByName(channelName);
|
|
221
|
+
const discordChannel = this.channelCache.get(channelName);
|
|
222
|
+
const members = await this.guild.members.fetch();
|
|
223
|
+
const allowedMembers = members.filter((member) => discordChannel.permissionsFor(member)?.has('ViewChannel'));
|
|
224
|
+
return Array.from(allowedMembers.values()).map(member => this.translateUser(member));
|
|
225
|
+
}
|
|
226
|
+
async readMemberNamesInChannel(channelName) {
|
|
227
|
+
const members = await this.readMembersInChannel(channelName);
|
|
228
|
+
return members.map(member => member.username);
|
|
229
|
+
}
|
|
230
|
+
// Advanced message queries
|
|
231
|
+
async getLastMessageSentBy(channelName, username) {
|
|
232
|
+
const messages = await this.fetchAllMessagesWithPaging((await this.getChannelByName(channelName)).id, 1000);
|
|
233
|
+
return messages.find(msg => msg.authorName === username) || null;
|
|
234
|
+
}
|
|
235
|
+
async getLastMentionOf(channelName, username) {
|
|
236
|
+
const messages = await this.fetchAllMessagesWithPaging((await this.getChannelByName(channelName)).id, 1000);
|
|
237
|
+
return messages.find(msg => msg.content.includes(`@${username}`) ||
|
|
238
|
+
msg.content.includes(`<@${username}>`)) || null;
|
|
239
|
+
}
|
|
240
|
+
async readLastMessageDatesByMembers(channelName, memberNames) {
|
|
241
|
+
const channel = await this.getChannelByName(channelName);
|
|
242
|
+
const messages = await this.fetchAllMessagesWithPaging(channel.id, 1000);
|
|
243
|
+
const memberStatus = {};
|
|
244
|
+
memberNames.forEach(name => {
|
|
245
|
+
memberStatus[name] = { lastMessageDate: null, allMessages: 0 };
|
|
246
|
+
});
|
|
247
|
+
const cutoffTime = Date.now() - (3 * 7 * 24 * 60 * 60 * 1000); // 3 weeks
|
|
248
|
+
messages.forEach((message) => {
|
|
249
|
+
if (message.timestamp < cutoffTime)
|
|
250
|
+
return;
|
|
251
|
+
const author = message.authorName;
|
|
252
|
+
if (memberStatus[author] !== undefined) {
|
|
253
|
+
memberStatus[author].allMessages++;
|
|
254
|
+
if (!memberStatus[author].lastMessageDate) {
|
|
255
|
+
memberStatus[author].lastMessageDate = new Date(message.timestamp);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return memberNames.map((memberName) => {
|
|
260
|
+
const status = memberStatus[memberName];
|
|
261
|
+
return {
|
|
262
|
+
memberName: memberName,
|
|
263
|
+
allMessages: status.allMessages,
|
|
264
|
+
lastMessageDate: status.lastMessageDate
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async readLastMessageWithMemberNamePingInIt(channelName, users) {
|
|
269
|
+
const channel = await this.getChannelByName(channelName);
|
|
270
|
+
const messages = await this.fetchAllMessagesWithPaging(channel.id, 1000);
|
|
271
|
+
const memberStatus = {};
|
|
272
|
+
users.forEach(user => {
|
|
273
|
+
memberStatus[user.username] = { lastMentionDate: null, allMentions: 0 };
|
|
274
|
+
});
|
|
275
|
+
const cutoffTime = Date.now() - (3 * 7 * 24 * 60 * 60 * 1000); // 3 weeks
|
|
276
|
+
messages.forEach((message) => {
|
|
277
|
+
if (message.timestamp < cutoffTime)
|
|
278
|
+
return;
|
|
279
|
+
users.forEach(user => {
|
|
280
|
+
if (message.content.includes(`@${user.id}`) &&
|
|
281
|
+
!memberStatus[user.username].lastMentionDate) {
|
|
282
|
+
memberStatus[user.username].lastMentionDate = new Date(message.timestamp);
|
|
283
|
+
memberStatus[user.username].allMentions++;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
return users.map((user) => {
|
|
288
|
+
const status = memberStatus[user.username];
|
|
289
|
+
return {
|
|
290
|
+
memberId: user.id,
|
|
291
|
+
memberName: user.username,
|
|
292
|
+
allMentions: status.allMentions,
|
|
293
|
+
lastMentionDate: status.lastMentionDate
|
|
294
|
+
};
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// Discord-specific features
|
|
298
|
+
getRoleByName(roleName) {
|
|
299
|
+
if (this.roleCache.has(roleName)) {
|
|
300
|
+
return this.roleCache.get(roleName);
|
|
301
|
+
}
|
|
302
|
+
const role = this.guild.roles.cache.find(r => r.name === roleName);
|
|
303
|
+
if (role) {
|
|
304
|
+
this.roleCache.set(roleName, role);
|
|
305
|
+
}
|
|
306
|
+
return role;
|
|
307
|
+
}
|
|
308
|
+
async getRolePingByName(roleName) {
|
|
309
|
+
const role = this.getRoleByName(roleName);
|
|
310
|
+
return role ? `<@&${role.id}>` : '';
|
|
311
|
+
}
|
|
312
|
+
async getRolePingsByName(roleNames) {
|
|
313
|
+
const pings = await Promise.all(roleNames.map(roleName => this.getRolePingByName(roleName)));
|
|
314
|
+
return pings.join(' ');
|
|
315
|
+
}
|
|
316
|
+
// Event binding
|
|
317
|
+
onMessage(handler) {
|
|
318
|
+
this.messageHandlers.push(handler);
|
|
319
|
+
}
|
|
320
|
+
onReady(handler) {
|
|
321
|
+
this.readyHandlers.push(handler);
|
|
322
|
+
}
|
|
323
|
+
onError(handler) {
|
|
324
|
+
this.errorHandlers.push(handler);
|
|
325
|
+
}
|
|
326
|
+
// Metadata
|
|
327
|
+
getBotId() {
|
|
328
|
+
return this.client?.user?.id;
|
|
329
|
+
}
|
|
330
|
+
getBotDisplayName() {
|
|
331
|
+
return this.client?.user?.displayName;
|
|
332
|
+
}
|
|
333
|
+
getProviderName() {
|
|
334
|
+
return 'discord';
|
|
335
|
+
}
|
|
336
|
+
getProviderId() {
|
|
337
|
+
return this.config?.providerId || this.getProviderName();
|
|
338
|
+
}
|
|
339
|
+
isReady() {
|
|
340
|
+
return this.isInitialized && this.client?.readyAt !== null;
|
|
341
|
+
}
|
|
342
|
+
// Translation methods
|
|
343
|
+
translateMessage(discordMessage) {
|
|
344
|
+
return {
|
|
345
|
+
id: discordMessage.id,
|
|
346
|
+
content: discordMessage.content,
|
|
347
|
+
authorId: discordMessage.author.id,
|
|
348
|
+
authorName: discordMessage.author.username,
|
|
349
|
+
authorDisplayName: discordMessage.author.displayName,
|
|
350
|
+
channelId: discordMessage.channelId,
|
|
351
|
+
channelName: discordMessage.channel?.name || 'unknown',
|
|
352
|
+
timestamp: discordMessage.createdTimestamp,
|
|
353
|
+
isBot: discordMessage.author.bot,
|
|
354
|
+
replyToMessageId: discordMessage.reference?.messageId,
|
|
355
|
+
mentions: Array.from(discordMessage.mentions.users.keys()),
|
|
356
|
+
rawPlatformMessage: discordMessage
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
translateChannel(discordChannel) {
|
|
360
|
+
return {
|
|
361
|
+
id: discordChannel.id,
|
|
362
|
+
name: discordChannel.name,
|
|
363
|
+
isTextBased: discordChannel.isTextBased(),
|
|
364
|
+
isDM: discordChannel.isDMBased(),
|
|
365
|
+
rawPlatformChannel: discordChannel
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
translateUser(discordMember) {
|
|
369
|
+
return {
|
|
370
|
+
id: discordMember.user.id,
|
|
371
|
+
username: discordMember.user.username,
|
|
372
|
+
displayName: discordMember.displayName,
|
|
373
|
+
isBot: discordMember.user.bot,
|
|
374
|
+
rawPlatformUser: discordMember
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
exports.DyNTS_DiB_MessageProvider = DyNTS_DiB_MessageProvider;
|
|
379
|
+
//# sourceMappingURL=dib-message-provider.service.js.map
|