diff --git a/Services/HandleStartMessage.cs b/Services/HandleStartMessage.cs index cb8b331..adee34b 100755 --- a/Services/HandleStartMessage.cs +++ b/Services/HandleStartMessage.cs @@ -17,16 +17,22 @@ namespace CatsOfMastodonBot.Services { public static async Task HandleStartMessageAsync(Message message, TelegramBotClient _bot, IDocumentCollection _db, ILogger? logger) { + logger?.LogInformation("Start message received"); + // choose all media attachments that are approved - var mediaAttachmentsToSelect = _db.AsQueryable().Where(p => p.MediaAttachments.Any(m => m.Approved == true)).ToList(); + var mediaAttachmentsToSelect = _db.AsQueryable() + .Where(post => post.MediaAttachments.Any(media => media.Approved)) + .ToList(); // select random approved media attachment var selectedMediaAttachment = mediaAttachmentsToSelect[new Random().Next(mediaAttachmentsToSelect.Count)]; // send media attachment await _bot.SendPhotoAsync(message.Chat.Id, selectedMediaAttachment.MediaAttachments.FirstOrDefault(m => m.Approved == true).Url, - caption: $"" + $"Here is your cat!" + "
" + "View on Mastodon 🐈" + "
", parseMode: ParseMode.Html + caption: $"Here is your cat!🐈\n"+"" + $"View on Mastodon " + " ", parseMode: ParseMode.Html , replyMarkup: new InlineKeyboardMarkup().AddButton(InlineKeyboardButton.WithUrl("Join channel 😺", selectedMediaAttachment.Url)) .AddNewRow() .AddButton(InlineKeyboardButton.WithCallbackData("Send me another one!", $"new_random"))); + + logger?.LogInformation("Random cat sent!"); }