Home > Mobile >  Callback query is not empty and its commands are executed continuously
Callback query is not empty and its commands are executed continuously

Time:08-13

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

}

CodePudding user response:

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

CodePudding user response:

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.

  • Related