Add delete button for original message sender

This commit is contained in:
2023-04-18 23:17:18 +00:00
parent 10ca71448a
commit 71302338b8
4 changed files with 83 additions and 10 deletions

View File

@@ -0,0 +1,25 @@
<?php
namespace Bot\Command\System;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Request;
class CallbackqueryCommand extends SystemCommand
{
public function execute(): ServerResponse
{
try {
$callbackQuery = $this->getUpdate()->getCallbackQuery();
$originalSenderId = json_decode($callbackQuery->getData(), true)['sender_id'];
if ($originalSenderId === $callbackQuery->getFrom()?->getId()) {
return Request::deleteMessage([
'chat_id' => $callbackQuery->getMessage()->getChat()->getId(),
'message_id' => $callbackQuery->getMessage()->getMessageId(),
]);
}
} catch (\Exception $e) {
}
return Request::emptyResponse();
}
}