Telegram.Bot.SpaceApi/Backend/TelegramBotClient.cs
2023-04-08 14:47:20 +02:00

25 lines
484 B
C#

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) {
_bot.SendTextMessageAsync(chat, message);
}
}