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

Conversation in CallbackqueryCommand? #67

Open
sascha-hendel opened this issue Nov 26, 2023 · 1 comment
Open

Conversation in CallbackqueryCommand? #67

sascha-hendel opened this issue Nov 26, 2023 · 1 comment

Comments

@sascha-hendel
Copy link

sascha-hendel commented Nov 26, 2023

Is it possible to start a conservation by pressing a InlineKeyboardButton (handle new Conversation() in CallbackqueryCommand.php)?

@sascha-hendel sascha-hendel changed the title Conversation in CalbackqueryCommand? Conversation in CallbackqueryCommand? Nov 26, 2023
@Hitmare
Copy link
Contributor

Hitmare commented Jun 18, 2024

hello. yes you can to that by sending a Callback with the InlineKeyboard and using CallbackQueryCommand.php to fetch that callbackquery. Using $this->telegram->executeCommand('commandname'); you can start the Conversationcommand that handles the conversation. To get the chatID and userID you need to extract them from the CallbackQuery itself since the command was started by the Callbackquery and not by the user

 if ($this->getCallbackQuery() !== null) {
    $message  = $this->getCallbackQuery()->getMessage();
    $callback_query     = $this->getCallbackQuery();
    $callback_data     = $callback_query->getData();
    $chat    = $message->getChat();
    $user    = $callback_query->getFrom();
    $text    = $callback_data;
    $chat_id = $chat->getId();
    $user_id = $callback_query->getFrom()->getId();
}
else {
    $message = $this->getMessage();
    $chat    = $message->getChat();
    $user    = $message->getFrom();
    $text    = trim($message->getText(true));
    $chat_id = $chat->getId();
    $user_id = $user->getId();
} 

In addition, if you want to use inlinekeyboards within a Conversation you need to change some stuff, listed in here https://pastebin.com/qxQAekwj

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

No branches or pull requests

2 participants