skip to Main Content

I created a Telegram bot in C# language and used inline keyboards in one part of it.
When the user clicks on one of the keyboards, a message is supposed to be sent to him, my problem is that this message keeps repeating and I haven’t found a way to empty the callback query. I want to do this because I control with an if condition that the commands will be executed if the callback query is not empty, but after it is executed, I don’t know what to do so that it is executed only once. Thank you for your help.

if (up.CallbackQuery != null)
{
                        
     enter code here

}

2

Answers


  1. Chosen as BEST ANSWER

    I found the answer to my question and thought I'd share it here, maybe someone else will run into the same problem as me. The problem was due to my carelessness, I had put the offset value after the if condition and actually the offset value was not updated.


  2. You should take a look at the Observer Design Pattern that should a good solution for you. And this pattern will allow you to add/remove subscribers with their respective callbacks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search