core icon indicating copy to clipboard operation
core copied to clipboard

inline button "back" and delete inline button messages

Open batyayura0 opened this issue 3 years ago • 4 comments

❓ Support Question

I can't remember the function that returns Back when the inline button is pressed, there is no need to use something complicated there.

It is also not possible to delete messages with inline buttons.

Thank you very much for your time.

batyayura0 avatar Jul 09 '22 18:07 batyayura0

What is your question here? 🤔

TiiFuchs avatar Jul 09 '22 21:07 TiiFuchs

What is your question here? 🤔

need to make the back button inline

batyayura0 avatar Jul 10 '22 08:07 batyayura0

That‘s still not a question…?

TiiFuchs avatar Jul 10 '22 08:07 TiiFuchs

HI

It is Possible to delete messages with Inline buttons, i do it myself

In your Callbackquery you will need the following:

$deldata = [
'chat_id' => $chat_id,
'message_id' => $message_id
];
Request::deleteMessage($deldata);

You can get the nessesary ID's with

$callback_query    = $this->getCallbackQuery();
$message = $callback_query->getMessage(); 
$message_id = $message->getMessageId();
$chat = $message->getChat();
$chat_id = $chat->getId();

For a "Back" Button there are different solutions, depending how your code is build

If you have send another inline keyboard via Callbackquery, you simply need to call that menu again If you want to trigger the /command again you will need to add two things:

In CallbackqueryCommand.php:

//Your Code to check to check if the Back Button was pressed
return $this->telegram->executeCommand('command');

In Your Command file you need to check if a Callbackquery is present to aquire the ChatID from the callbackquery

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

If you have further Questions please ask them. Maybe with a bit more detail and Information ;)

Hitmare avatar Jul 12 '22 08:07 Hitmare

Closed since there was no further interaction.

TiiFuchs avatar Aug 27 '22 14:08 TiiFuchs