0

I'm trying to develop my first Telegram bot using C# in Visual Studio. I've been following tutorials, and everything seems to be going smoothly. However, when I try to handle incoming messages using TelegramBotClient.OnMessage, I encounter an error stating: "'TelegramBotClient' does not contain the definition of 'OnMessage'." Here's a snippet of my code:

public static TelegramBotClient BotClient;

public static void Main(string[] args)
{
    BotClient = new TelegramBotClient("My Token");
    BotClient.OnMessage += BotClient_OnMessage();
    // Other code...
}

I understand that TelegramBotClient doesn't have an OnMessage event handler directly. Can someone guide me on how to properly handle incoming messages in the TelegramBotClient class? Thank you.

I expected that subscribing to the OnMessage event of the TelegramBotClient would allow me to handle incoming messages as shown in the tutorials I followed. However, I encountered the error mentioned earlier. I also attempted to find any relevant information in the official documentation or through online forums, but I couldn't find a solution.

1
  • I've solved my problem to use "TelegramBotClient.OnMessage" and other features just by downgrading the Telegram.Bot library in nuget package manager Commented May 12 at 9:17

1 Answer 1

0

Downgrade your "Telegram.Bot" version to "16.0.2". That worked for me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.