Skip to content

Conversation in CallbackqueryCommand? #67

Open

Description

@sascha-hendel

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

Activity

  1. changed the title [-]Conversation in CalbackqueryCommand?[/-] [+]Conversation in CallbackqueryCommand?[/+] on Nov 26, 2023
  2. Hitmare commented on Jun 18, 2024

    @Hitmare
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions