using Telegram.Bot; using Telegram.Bot.Types.Enums; namespace GmRelay.Bot.Features.Notifications; public sealed record DirectNotificationRecipient(long TelegramId, string DisplayName); public sealed class DirectSessionNotificationSender( ITelegramBotClient bot, ILogger logger) { public async Task SendAsync( IEnumerable recipients, string htmlText, string notificationKind, Guid sessionId, CancellationToken ct) { foreach (var recipient in recipients) { try { await bot.SendMessage( chatId: recipient.TelegramId, text: htmlText, parseMode: ParseMode.Html, cancellationToken: ct); } catch (Exception ex) { logger.LogWarning( ex, "Failed to send {NotificationKind} DM for session {SessionId} to player {TelegramId} ({DisplayName})", notificationKind, sessionId, recipient.TelegramId, recipient.DisplayName); } } } }