25 lines
543 B
C#
25 lines
543 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) {
|
|
Console.WriteLine("Sent. Message ID: " + _bot.SendTextMessageAsync(chat, message).Result.MessageId);
|
|
}
|
|
}
|