Add support for CallbackQuery events.

This commit is contained in:
netkas 2024-11-01 21:54:05 -04:00
parent e843c8ca4f
commit 709e5794d5
3 changed files with 35 additions and 0 deletions

View file

@ -111,6 +111,11 @@
return UpdateEventType::PRE_CHECKOUT_QUERY;
}
if($update->getCallbackQuery() !== null)
{
return UpdateEventType::CALLBACK_QUERY;
}
return UpdateEventType::UPDATE_EVENT;
}
}

View file

@ -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;
}

View file

@ -0,0 +1,28 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\CallbackQuery;
abstract class CallbackQueryEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::CALLBACK_QUERY;
}
/**
* New incoming callback query
*
* @return CallbackQuery
*/
protected function getCallbackQuery(): CallbackQuery
{
return $this->update->getCallbackQuery();
}
}