From 709e5794d564c34fd14cb1f601824b5dee4afa17 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 1 Nov 2024 21:54:05 -0400 Subject: [PATCH] Add support for CallbackQuery events. --- src/TgBotLib/Classes/Utilities.php | 5 ++++ src/TgBotLib/Enums/UpdateEventType.php | 2 ++ src/TgBotLib/Events/CallbackQueryEvent.php | 28 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/TgBotLib/Events/CallbackQueryEvent.php diff --git a/src/TgBotLib/Classes/Utilities.php b/src/TgBotLib/Classes/Utilities.php index 98edc3b..790d40f 100644 --- a/src/TgBotLib/Classes/Utilities.php +++ b/src/TgBotLib/Classes/Utilities.php @@ -111,6 +111,11 @@ return UpdateEventType::PRE_CHECKOUT_QUERY; } + if($update->getCallbackQuery() !== null) + { + return UpdateEventType::CALLBACK_QUERY; + } + return UpdateEventType::UPDATE_EVENT; } } \ No newline at end of file diff --git a/src/TgBotLib/Enums/UpdateEventType.php b/src/TgBotLib/Enums/UpdateEventType.php index bd3b279..d960ca5 100644 --- a/src/TgBotLib/Enums/UpdateEventType.php +++ b/src/TgBotLib/Enums/UpdateEventType.php @@ -3,6 +3,7 @@ namespace TgBotLib\Enums; use TgBotLib\Abstracts\UpdateEvent; + use TgBotLib\Events\CallbackQueryEvent; use TgBotLib\Events\ChatBoostEvent; use TgBotLib\Events\ChatJoinRequestEvent; use TgBotLib\Events\ChatMemberUpdatedEvent; @@ -27,4 +28,5 @@ case PAID_MEDIA_PURCHASED = PaidMediaPurchasedEvent::class; case PRE_CHECKOUT_QUERY = PreCheckoutQueryEvent::class; case SHIPPING_QUERY = ShippingQueryEvent::class; + case CALLBACK_QUERY = CallbackQueryEvent::class; } diff --git a/src/TgBotLib/Events/CallbackQueryEvent.php b/src/TgBotLib/Events/CallbackQueryEvent.php new file mode 100644 index 0000000..f01d21c --- /dev/null +++ b/src/TgBotLib/Events/CallbackQueryEvent.php @@ -0,0 +1,28 @@ +update->getCallbackQuery(); + } + } \ No newline at end of file