public class TelegramSend
{
private static string token = Variables.apiTg;
private static TelegramBotClient bot;
private static long chatId = Variables.chatIdTg;
public async void BotStart()
{
bot = new TelegramBotClient(token);
TeleJob();
}
public static async void TeleJob()
{
try
{
GetMessage();
}
catch (Exception ex)
{
MessageBox.Show("Сообщение телеграм: " + ex.Message);
}
}
static async Task GetMessage()
{
try
{
string screen = String.Format(Directory.GetCurrentDirectory() + @"\Qr_Photo\test{0}.png",Variables.bmpFileNum);
using (var fileStream = new FileStream(screen, FileMode.Open, FileAccess.Read, FileShare.Read))
{
await bot.SendPhotoAsync(chatId: new Telegram.Bot.Types.ChatId(chatId), photo: new Telegram.Bot.Types.InputFiles.InputOnlineFile(fileStream), caption: "QrCode");
fileStream.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("GetMessage: " + ex.Message);
}
}
}