Rename EventType to UpdateEventType for clarity

This commit is contained in:
netkas 2024-11-01 18:11:11 -04:00
parent b8b1a87639
commit 73d14179b1
9 changed files with 31 additions and 31 deletions

View file

@ -3,7 +3,7 @@
namespace TgBotLib\Abstracts;
use TgBotLib\Bot;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Update;
abstract class UpdateEvent
@ -23,11 +23,11 @@
/**
* Retrieves the event type.
* @return EventType The event type of the current instance.
* @return UpdateEventType The event type of the current instance.
*/
public static function getEventType(): EventType
public static function getEventType(): UpdateEventType
{
return EventType::UPDATE_EVENT;
return UpdateEventType::UPDATE_EVENT;
}
public abstract function handle(Bot $bot): void;

View file

@ -14,7 +14,7 @@
use TgBotLib\Abstracts\Method;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Classes\Logger;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Enums\Methods;
use TgBotLib\Enums\Types\ChatActionType;
use TgBotLib\Enums\Types\ParseMode;
@ -271,10 +271,10 @@
/**
* Retrieves all event handlers that match a specified event type.
*
* @param EventType $type The event type to filter handlers by.
* @param UpdateEventType $type The event type to filter handlers by.
* @return array An array of event handlers that handle the specified event type.
*/
public function getEventHandlersByType(EventType $type): array
public function getEventHandlersByType(UpdateEventType $type): array
{
$results = [];
/** @var UpdateEvent $eventHandler */
@ -302,10 +302,10 @@
/**
* Removes all event handlers of a specified type.
*
* @param EventType $type The event type to filter handlers by.
* @param UpdateEventType $type The event type to filter handlers by.
* @return void
*/
public function removeEventHandlersByType(EventType $type): void
public function removeEventHandlersByType(UpdateEventType $type): void
{
$this->eventHandlers = array_filter($this->eventHandlers, function($eventHandler) use ($type)
{

View file

@ -5,7 +5,7 @@
use Exception;
use LogLib\Log;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Currency;
use TgBotLib\Objects\Update;
@ -57,30 +57,30 @@
* Determines the type of event based on the provided update object.
*
* @param Update $update The update object containing event information.
* @return EventType The determined type of the event.
* @return UpdateEventType The determined type of the event.
*/
public static function determineEventType(Update $update): EventType
public static function determineEventType(Update $update): UpdateEventType
{
if($update->getRemovedChatBoost() !== null)
{
return EventType::REMOVED_CHAT_BOOST_EVENT;
return UpdateEventType::REMOVED_CHAT_BOOST_EVENT;
}
if($update->getChatBoost() !== null)
{
return EventType::CHAT_BOOST_EVENT;
return UpdateEventType::CHAT_BOOST_EVENT;
}
if($update->getChatJoinRequest() !== null)
{
return EventType::CHAT_JOIN_REQUEST_EVENT;
return UpdateEventType::CHAT_JOIN_REQUEST_EVENT;
}
if($update->getChatMember() !== null)
{
return EventType::CHAT_MEMBER_UPDATED;
return UpdateEventType::CHAT_MEMBER_UPDATED;
}
return EventType::UPDATE_EVENT;
return UpdateEventType::UPDATE_EVENT;
}
}

View file

@ -8,7 +8,7 @@
use TgBotLib\Events\ChatMemberUpdatedEvent;
use TgBotLib\Events\RemovedChatBoostEvent;
enum EventType : string
enum UpdateEventType : string
{
case UPDATE_EVENT = UpdateEvent::class;
case REMOVED_CHAT_BOOST_EVENT = RemovedChatBoostEvent::class;

View file

@ -3,7 +3,7 @@
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\ChatBoostUpdated;
abstract class ChatBoostEvent extends UpdateEvent
@ -11,9 +11,9 @@
/**
* @inheritDoc
*/
public static function getEventType(): EventType
public static function getEventType(): UpdateEventType
{
return EventType::CHAT_BOOST_EVENT;
return UpdateEventType::CHAT_BOOST_EVENT;
}
/**

View file

@ -4,14 +4,14 @@
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Bot;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\ChatJoinRequest;
abstract class ChatJoinRequestEvent extends UpdateEvent
{
public static function getEventType(): EventType
public static function getEventType(): UpdateEventType
{
return EventType::CHAT_JOIN_REQUEST_EVENT;
return UpdateEventType::CHAT_JOIN_REQUEST_EVENT;
}
/**

View file

@ -4,7 +4,7 @@
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Bot;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\ChatMemberUpdated;
abstract class ChatMemberUpdatedEvent extends UpdateEvent
@ -12,9 +12,9 @@
/**
* @inheritDoc
*/
public static function getEventType(): EventType
public static function getEventType(): UpdateEventType
{
return EventType::CHAT_MEMBER_UPDATED;
return UpdateEventType::CHAT_MEMBER_UPDATED;
}
/**

View file

@ -3,7 +3,7 @@
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\ChatBoostRemoved;
abstract class RemovedChatBoostEvent extends UpdateEvent
@ -11,9 +11,9 @@
/**
* @inheritDoc
*/
public static function getEventType(): EventType
public static function getEventType(): UpdateEventType
{
return EventType::REMOVED_CHAT_BOOST_EVENT;
return UpdateEventType::REMOVED_CHAT_BOOST_EVENT;
}
/**

View file

@ -4,7 +4,7 @@
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Classes\Utilities;
use TgBotLib\Enums\EventType;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Update;
class PollingBot extends Bot