Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
GenericmessageCommand.php
Original at around line 75:
$conversation = new Conversation(
$message->getFrom()->getId(),
$message->getChat()->getId()
);
// Fetch conversation command if it exists and execute it.
if ($conversation->exists() && $command = $conversation->getCommand()) {
return $this->telegram->executeCommand($command);
}
Chang to:
if ($this->getCallbackQuery() == null) {
$conversation = new Conversation(
$message->getFrom()->getId(),
$message->getChat()->getId()
);
// Fetch conversation command if it exists and execute it.
if ($conversation->exists() && $command = $conversation->getCommand()) {
return $this->telegram->executeCommand($command);
}
}
CallbackqueryCommand.php
Add under the other "use
" calls
use Longman\TelegramBot\Conversation;
Add after "$callback_data = $callback_query->getData();
" at around line 53:
$message = $callback_query->getMessage();
// If a conversation is busy, execute the conversation command after handling the message.
$conversation = new Conversation(
$callback_query->getFrom()->getId(),
$message->getChat()->getId()
);
// Fetch conversation command if it exists and execute it.
if ($conversation->exists() && $command = $conversation->getCommand()) {
return $this->telegram->executeCommand($command);
}
In your Survey Command
Original within the public function execute(): ServerResponse
function :
$message = $this->getMessage();
$chat = $message->getChat();
$user = $message->getFrom();
$text = trim($message->getText(true));
$chat_id = $chat->getId();
$user_id = $user->getId();
Change to:
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();
}
Add Comment
Please, Sign In to add comment