Add support for handling inline query events

This commit is contained in:
netkas 2024-11-02 00:18:14 -04:00
parent a212671c49
commit ac431136de
3 changed files with 36 additions and 0 deletions

View file

@ -121,6 +121,11 @@
return UpdateEventType::CHOSEN_INLINE_RESULT;
}
if($update->getInlineQuery() !== null)
{
return UpdateEventType::INLINE_QUERY;
}
return UpdateEventType::UPDATE_EVENT;
}
}

View file

@ -8,6 +8,7 @@
use TgBotLib\Events\ChatJoinRequestEvent;
use TgBotLib\Events\ChatMemberUpdatedEvent;
use TgBotLib\Events\ChosenInlineResultEvent;
use TgBotLib\Events\InlineQueryEvent;
use TgBotLib\Events\MyChatMemberUpdatedEvent;
use TgBotLib\Events\PollAnswerEvent;
use TgBotLib\Events\PollEvent;
@ -32,4 +33,5 @@
case SHIPPING_QUERY = ShippingQueryEvent::class;
case CALLBACK_QUERY = CallbackQueryEvent::class;
case CHOSEN_INLINE_RESULT = ChosenInlineResultEvent::class;
case INLINE_QUERY = InlineQueryEvent::class;
}

View file

@ -0,0 +1,29 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Bot;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Inline\InlineQuery;
abstract class InlineQueryEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::INLINE_QUERY;
}
/**
* New incoming inline query
*
* @return InlineQuery
*/
protected function getInlineQuery(): InlineQuery
{
return $this->update->getInlineQuery();
}
}