Shorter Delete button

This commit is contained in:
2023-04-19 19:34:08 +00:00
parent 71302338b8
commit cc302e5431
2 changed files with 11 additions and 3 deletions

View File

@@ -12,11 +12,19 @@ class CallbackqueryCommand extends SystemCommand
try {
$callbackQuery = $this->getUpdate()->getCallbackQuery();
$originalSenderId = json_decode($callbackQuery->getData(), true)['sender_id'];
if ($originalSenderId === $callbackQuery->getFrom()?->getId()) {
$callbackSenderId = $callbackQuery->getFrom()?->getId();
if ($originalSenderId === $callbackSenderId) {
return Request::deleteMessage([
'chat_id' => $callbackQuery->getMessage()->getChat()->getId(),
'chat_id' => $callbackQuery->getMessage()->getChat()->getId(),
'message_id' => $callbackQuery->getMessage()->getMessageId(),
]);
} else {
// Only possible if the user already has an DM channel open with the bot
// but better than nothing
return Request::sendMessage([
'chat_id' => $callbackSenderId,
'text' => 'Only the person sending the original message can delete the reply.',
]);
}
} catch (\Exception $e) {
}