Improved fetching config data, implemented envinronmet variable support alongside .env support
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using CatsOfMastodonBot.Models;
|
||||
using JsonFlatFileDataStore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using mstdnCats.Models;
|
||||
@@ -12,6 +13,8 @@ namespace mstdnCats.Services
|
||||
{
|
||||
public static async Task HandleCallbackQuery(CallbackQuery callbackQuery, IDocumentCollection<Post> _db, TelegramBotClient _bot, ILogger<MastodonBot>? logger)
|
||||
{
|
||||
var config = new configData.config();
|
||||
|
||||
// Extract media ID from callback query data
|
||||
string[] parts = callbackQuery.Data.Split('-');
|
||||
if (parts.Length != 2)
|
||||
@@ -52,7 +55,7 @@ namespace mstdnCats.Services
|
||||
if (updated)
|
||||
{
|
||||
// Send the media attachment to the channel
|
||||
await _bot.SendPhotoAsync(DotNetEnv.Env.GetString("CHANNEL_NUMID"), post.MediaAttachments.First().Url, caption: $"Post from " + $"<a href=\"" + post.Account.Url + "\">" + post.Account.DisplayName + " </a>", parseMode: ParseMode.Html
|
||||
await _bot.SendPhotoAsync(config.ADMIN_NUMID, post.MediaAttachments.First().Url, caption: $"Post from " + $"<a href=\"" + post.Account.Url + "\">" + post.Account.DisplayName + " </a>", parseMode: ParseMode.Html
|
||||
, replyMarkup: new InlineKeyboardMarkup(InlineKeyboardButton.WithUrl("View on Mastodon", post.Url)));
|
||||
|
||||
await _bot.AnswerCallbackQueryAsync(callbackQuery.Id, "Media attachment approved and sent to channel.");
|
||||
|
Reference in New Issue
Block a user