<commit_before>﻿using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;

namespace HitagiBot.Utilities
{
    public static class MessagerHelper
    {
        public static string InsertInvisibleLink(string link, ParseMode parseMode)
        {
            return parseMode == ParseMode.Html ? $"<a href=\"{link}\">\u2063</a>" : $"[\u2063]({link})";
        }

        public static async Task<Message> SendSmartTextMessageAsync(this TelegramBotClient botClient, Message source,
            string text, ParseMode parseMode = ParseMode.Default)
        {
            var replyToMessageId = source.Chat.Type == ChatType.Private ? 0 : source.MessageId;

            return await botClient.SendTextMessageAsync(source.Chat.Id, text, parseMode,
                replyToMessageId: replyToMessageId);
        }
    }
}<commit_msg>Implemented a message retry to handle 429 (Too Many Requests).<commit_after>﻿using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;

namespace HitagiBot.Utilities
{
    public static class MessagerHelper
    {
        public static string InsertInvisibleLink(string link, ParseMode parseMode)
        {
            return parseMode == ParseMode.Html ? $"<a href=\"{link}\">\u2063</a>" : $"[\u2063]({link})";
        }

        public static async Task<Message> SendSmartTextMessageAsync(this TelegramBotClient botClient, Message source,
            string text, ParseMode parseMode = ParseMode.Default)
        {
            Message resultMessage = null;
            var replyToMessageId = source.Chat.Type == ChatType.Private ? 0 : source.MessageId;

            for (var i = 0; i < 3; ++i)
                try
                {
                    resultMessage = await botClient.SendTextMessageAsync(source.Chat.Id, text, parseMode,
                        replyToMessageId: replyToMessageId);
                    break;
                }
                catch (HttpRequestException)
                {
                    await Task.Delay(TimeSpan.FromSeconds(1 * i));
                }

            return resultMessage;
        }
    }
}
{'fraction_non_alphanumeric': 0.09600717810677434, 'fraction_numerical': 0.010767160161507403, 'mean_word_length': 2.293943870014771, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4722927', 'n_tokens_mistral': 625, 'n_tokens_neox': 596, 'n_words': 142}