using System.Security.Authentication; namespace Telegram.Bot.SpaceApi.Backend; using TgBot = Telegram.Bot.TelegramBotClient; public class TelegramBotClient { private TgBot _bot; public TelegramBotClient(string token) { _bot = new TgBot(token); try { _ = _bot.GetMeAsync().Result; } catch { throw new InvalidCredentialException("Invalid bot token."); } } public void SendMessage(string chat, string message) { Console.WriteLine($"Sent message to chat {chat}. Message ID: " + _bot.SendTextMessageAsync(chat, message).Result.MessageId); } }