25 lines
484 B
C#
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);
|
||
|
}
|
||
|
}
|