Handle FX-VX swapping, support x.com
This commit is contained in:
@@ -16,6 +16,7 @@ class CallbackqueryCommand extends SystemCommand
|
||||
$callbackData = json_decode($callbackQuery->getData(), true);
|
||||
$response = match ($callbackData['action'] ?? null) {
|
||||
'REFRESH' => $this->handleRefresh($callbackQuery, $callbackData),
|
||||
'FXVX' => $this->handleSwapFxVx($callbackQuery, $callbackData),
|
||||
default => $this->handleDelete($callbackQuery, $callbackData),
|
||||
};
|
||||
|
||||
@@ -31,7 +32,9 @@ class CallbackqueryCommand extends SystemCommand
|
||||
{
|
||||
$originalSenderId = $callbackData['sender_id'];
|
||||
$callbackSenderId = $callbackQuery->getFrom()?->getId();
|
||||
if ($originalSenderId === $callbackSenderId || $callbackSenderId === 625413203) { // Me
|
||||
if (
|
||||
$originalSenderId === $callbackSenderId
|
||||
) {
|
||||
return Request::deleteMessage([
|
||||
'chat_id' => $callbackQuery->getMessage()->getChat()->getId(),
|
||||
'message_id' => $callbackQuery->getMessage()->getMessageId(),
|
||||
@@ -47,9 +50,31 @@ class CallbackqueryCommand extends SystemCommand
|
||||
return null;
|
||||
}
|
||||
|
||||
private function handleSwapFxVx(CallbackQuery $callbackQuery, array $callbackData): ?ServerResponse
|
||||
{
|
||||
if (!$callbackQuery->getMessage()?->getText()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$link = $callbackQuery->getMessage()->getText();
|
||||
$count = 1;
|
||||
if (str_starts_with($link, 'https://vx')) {
|
||||
$link = str_replace('https://vx', 'https://fx', $link, $count);
|
||||
} elseif (str_starts_with($link, 'https://fx')) {
|
||||
$link = str_replace('https://fx', 'https://vx', $link, $count);
|
||||
}
|
||||
|
||||
return Request::editMessageText([
|
||||
'chat_id' => $callbackQuery->getMessage()->getChat()->getId(),
|
||||
'message_id' => $callbackQuery->getMessage()->getMessageId(),
|
||||
'text'=> $link,
|
||||
'reply_markup' => $callbackQuery->getMessage()->getReplyMarkup(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function handleRefresh(CallbackQuery $callbackQuery, array $callbackData): ?ServerResponse
|
||||
{
|
||||
if (!$callbackQuery->getMessage()) {
|
||||
if (!$callbackQuery->getMessage()?->getText()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user