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.