import { DyNTS_Bot_MessagingProvider_ServiceBase } from '../_services/bot-messaging-provider.service-base'; import { DyNTS_Bot_ChannelWrapper } from './bot-channel-wrapper.interface'; import { DyNTS_Bot_UserWrapper } from './bot-user-wrapper.interface'; export class DyNTS_Bot_MessageWrapper_Base< T_MessagingPlatformMessage extends any = any, T_MessagingPlatformChannel extends any = any, /* T_MessagingPlatformUser extends any = any, */ > { id: string; content: string; authorId: string; authorName: string; authorDisplayName: string; channelId: string; channelName: string; timestamp: number; isBot: boolean; isTextBased: boolean; isVoiceBased: boolean; isDM: boolean; replyToMessageId: string | null; replyToMessageAuthorId: string | null; mentions: string[]; // user IDs issuer: string; rawPlatformMessage: T_MessagingPlatformMessage; // Original platform message for platform-specific operations channel: DyNTS_Bot_ChannelWrapper; /* user: DyNTS_Bot_UserWrapper; */ /** Reference to the provider instance for sending replies */ provider: DyNTS_Bot_MessagingProvider_ServiceBase< T_MessagingPlatformChannel, T_MessagingPlatformMessage, any, /* T_MessagingPlatformUser, */ any >; } /** * Wraps a bot message with provider context * This ensures messages include the provider information needed to send replies * back through the correct platform */ export class DyNTS_Bot_MessageWrapper< T_MessagingPlatformMessage extends any = any, T_MessagingPlatformChannel extends any = any, //T_MessagingPlatformUser extends any = any, > extends DyNTS_Bot_MessageWrapper_Base< T_MessagingPlatformMessage, T_MessagingPlatformChannel/* , T_MessagingPlatformUser */ > { constructor( set: DyNTS_Bot_MessageWrapper_Base< T_MessagingPlatformMessage, T_MessagingPlatformChannel/* , T_MessagingPlatformUser */ > ) { super(); Object.assign(this, set); } async reply(content: string): Promise> { return await this.provider.replyToMessage(this, content); } async sendTyping(): Promise { await this.provider.sendTypingForMessage(this); } async fetchMessages(limit: number): Promise[]> { return await this.provider.fetchMessagesForMessage(this, limit); } async delete(): Promise { await this.provider.deleteMessage(this); } channelIsTextBased(): boolean { return this.channel.isTextBased; } }