Took API for C # from the official site of Telegram.

When creating a console application for receiving messages, the bot had enough recording:

Bot.StartReceiving(); Console.ReadLine(); Bot.StopReceiving(); 

But in a project with WinForm, the line Console.ReadLine(); does not read values.

What to replace it with? Or need another principle?

  • four
    Console.ReadLine() - to work with the console. With the console, Karl! - Anatol

1 answer 1

When you start a form, start receiving, when you close a form, stop. Something like this:

 public partial class Form1 : Form { private Telegram.Bot.Api bot; public Form1() { InitializeComponent(); } public private void Form1_Load(object sender, EventArgs e) { bot = new Telegram.Bot.Api("your API access Token"); bot.StartReceiving(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { bot.StopReceiving(); } }