Skip to content

Commit

Permalink
fix: fixing social embed feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bgwastu committed Jan 13, 2024
1 parent 7a9cc26 commit 4616f9b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ await _commandQueue.DispatchAsync(

// Handle Social Link (better preview)
if ((update.Message.Text ?? update.Message.Caption) is { } textOrCaption) {
IEnumerable<Uri> betterLinks = SocialLinkEmbedFixer.GetPossibleUrls(textOrCaption);
IEnumerable<Uri> possibleUrls = SocialLinkEmbedFixer.GetPossibleUrls(textOrCaption);

if (betterLinks.Any()) {
if (possibleUrls.Any()) {
// Fire and forget
Task _ = Task.Run(async () => {
try {
foreach (Uri betterLink in betterLinks) {
foreach (Uri url in possibleUrls) {
Uri fixedUrl = SocialLinkEmbedFixer.Fix(url);
await _telegramBotClient.SendTextMessageAsync(
chatId: update.Message.Chat.Id,
text: $"Preview: {betterLink.OriginalString}",
text: $"Preview: {fixedUrl.OriginalString}",
replyToMessageId: update.Message.MessageId,
cancellationToken: cancellationToken
);
Expand Down

0 comments on commit 4616f9b

Please sign in to comment.