Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallbackqueryCommand -> executeCommand #1444

Open
VAtapin opened this issue Jan 26, 2024 · 2 comments
Open

CallbackqueryCommand -> executeCommand #1444

VAtapin opened this issue Jan 26, 2024 · 2 comments
Labels

Comments

@VAtapin
Copy link

VAtapin commented Jan 26, 2024

| Operating system | Ubuntu 20.04.6 LTS
| PHP Telegram Bot version | 0.81
| PHP version | 8.1.27
| MySQL version | x none
| Update Method | Webhook
| Self-signed certificate | no

On several occasions, I dedicated my evenings to solving a seemingly simple problem, only to discover a multitude of individuals facing the same challenge as myself. It became evident that this issue is systemic and demands clarification.

In the realm of inline keyboards, I diligently specified the callback_data argument, following the example provided by the bot. I received an alert as expected, accompanied by gratitude for the exemplary illustration. However, I encountered a stumbling block – a crucial piece of information was elusive. I couldn't find any guidance on how to execute a command, such as $this->getTelegram()->executeCommand('command'), when a button is pressed. This seems like a natural progression in the process. Why go through the trouble of implementing CallbackqueryCommand if this essential aspect is not addressed?

Regrettably, the example provided appears to be incomplete or, perhaps, insufficiently informative. Have I overlooked a crucial detail in the solution? Your guidance on this matter would be immensely appreciated. Thank you in advance for any hints you can provide.

@araikphp
Copy link

I completely agree with your perspective. It's quite logical to expect that if you're adding a keyboard to a command, the callback triggered by that command's button should intuitively direct back to the same command. The lack of clear documentation or guidance on executing a command like $this->getTelegram()->executeCommand('command') upon pressing a button is indeed a significant oversight. It's a step that naturally extends the functionality of inline keyboards and should be addressed in the documentation or examples provided. Your effort to shed light on this issue is valuable, and hopefully, it will prompt an enhancement in the resources available to developers.

@Hitmare
Copy link
Collaborator

Hitmare commented Mar 3, 2024

The way Telegram sends interactions with InlineButtons is through Callbackqueries.

To start a command or any function that is not implemented by Telegram like URL, Web App, Login URL and such is done by sending a callback_data InlineKeyboard API Funciton

The callback_data is send back to the bot and can be handled by the CallbackQueryCommand.php Command file, found in the example-bot

there you can access the callback_data and use functions like switch or if to check if the callback_data contains a certain value to then trigger the $this->getTelegram()->executeCommand('command') function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants