Rename EventType to UpdateEventType for clarity
This commit is contained in:
parent
b8b1a87639
commit
73d14179b1
9 changed files with 31 additions and 31 deletions
|
@ -3,7 +3,7 @@
|
||||||
namespace TgBotLib\Abstracts;
|
namespace TgBotLib\Abstracts;
|
||||||
|
|
||||||
use TgBotLib\Bot;
|
use TgBotLib\Bot;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\Update;
|
use TgBotLib\Objects\Update;
|
||||||
|
|
||||||
abstract class UpdateEvent
|
abstract class UpdateEvent
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the event type.
|
* 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;
|
public abstract function handle(Bot $bot): void;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
use TgBotLib\Abstracts\Method;
|
use TgBotLib\Abstracts\Method;
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Classes\Logger;
|
use TgBotLib\Classes\Logger;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Enums\Methods;
|
use TgBotLib\Enums\Methods;
|
||||||
use TgBotLib\Enums\Types\ChatActionType;
|
use TgBotLib\Enums\Types\ChatActionType;
|
||||||
use TgBotLib\Enums\Types\ParseMode;
|
use TgBotLib\Enums\Types\ParseMode;
|
||||||
|
@ -271,10 +271,10 @@
|
||||||
/**
|
/**
|
||||||
* Retrieves all event handlers that match a specified event type.
|
* 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.
|
* @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 = [];
|
$results = [];
|
||||||
/** @var UpdateEvent $eventHandler */
|
/** @var UpdateEvent $eventHandler */
|
||||||
|
@ -302,10 +302,10 @@
|
||||||
/**
|
/**
|
||||||
* Removes all event handlers of a specified type.
|
* 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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function removeEventHandlersByType(EventType $type): void
|
public function removeEventHandlersByType(UpdateEventType $type): void
|
||||||
{
|
{
|
||||||
$this->eventHandlers = array_filter($this->eventHandlers, function($eventHandler) use ($type)
|
$this->eventHandlers = array_filter($this->eventHandlers, function($eventHandler) use ($type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\Currency;
|
use TgBotLib\Objects\Currency;
|
||||||
use TgBotLib\Objects\Update;
|
use TgBotLib\Objects\Update;
|
||||||
|
|
||||||
|
@ -57,30 +57,30 @@
|
||||||
* Determines the type of event based on the provided update object.
|
* Determines the type of event based on the provided update object.
|
||||||
*
|
*
|
||||||
* @param Update $update The update object containing event information.
|
* @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)
|
if($update->getRemovedChatBoost() !== null)
|
||||||
{
|
{
|
||||||
return EventType::REMOVED_CHAT_BOOST_EVENT;
|
return UpdateEventType::REMOVED_CHAT_BOOST_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($update->getChatBoost() !== null)
|
if($update->getChatBoost() !== null)
|
||||||
{
|
{
|
||||||
return EventType::CHAT_BOOST_EVENT;
|
return UpdateEventType::CHAT_BOOST_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($update->getChatJoinRequest() !== null)
|
if($update->getChatJoinRequest() !== null)
|
||||||
{
|
{
|
||||||
return EventType::CHAT_JOIN_REQUEST_EVENT;
|
return UpdateEventType::CHAT_JOIN_REQUEST_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($update->getChatMember() !== null)
|
if($update->getChatMember() !== null)
|
||||||
{
|
{
|
||||||
return EventType::CHAT_MEMBER_UPDATED;
|
return UpdateEventType::CHAT_MEMBER_UPDATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EventType::UPDATE_EVENT;
|
return UpdateEventType::UPDATE_EVENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
use TgBotLib\Events\ChatMemberUpdatedEvent;
|
use TgBotLib\Events\ChatMemberUpdatedEvent;
|
||||||
use TgBotLib\Events\RemovedChatBoostEvent;
|
use TgBotLib\Events\RemovedChatBoostEvent;
|
||||||
|
|
||||||
enum EventType : string
|
enum UpdateEventType : string
|
||||||
{
|
{
|
||||||
case UPDATE_EVENT = UpdateEvent::class;
|
case UPDATE_EVENT = UpdateEvent::class;
|
||||||
case REMOVED_CHAT_BOOST_EVENT = RemovedChatBoostEvent::class;
|
case REMOVED_CHAT_BOOST_EVENT = RemovedChatBoostEvent::class;
|
|
@ -3,7 +3,7 @@
|
||||||
namespace TgBotLib\Events;
|
namespace TgBotLib\Events;
|
||||||
|
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\ChatBoostUpdated;
|
use TgBotLib\Objects\ChatBoostUpdated;
|
||||||
|
|
||||||
abstract class ChatBoostEvent extends UpdateEvent
|
abstract class ChatBoostEvent extends UpdateEvent
|
||||||
|
@ -11,9 +11,9 @@
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function getEventType(): EventType
|
public static function getEventType(): UpdateEventType
|
||||||
{
|
{
|
||||||
return EventType::CHAT_BOOST_EVENT;
|
return UpdateEventType::CHAT_BOOST_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
|
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Bot;
|
use TgBotLib\Bot;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\ChatJoinRequest;
|
use TgBotLib\Objects\ChatJoinRequest;
|
||||||
|
|
||||||
abstract class ChatJoinRequestEvent extends UpdateEvent
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Bot;
|
use TgBotLib\Bot;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\ChatMemberUpdated;
|
use TgBotLib\Objects\ChatMemberUpdated;
|
||||||
|
|
||||||
abstract class ChatMemberUpdatedEvent extends UpdateEvent
|
abstract class ChatMemberUpdatedEvent extends UpdateEvent
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function getEventType(): EventType
|
public static function getEventType(): UpdateEventType
|
||||||
{
|
{
|
||||||
return EventType::CHAT_MEMBER_UPDATED;
|
return UpdateEventType::CHAT_MEMBER_UPDATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
namespace TgBotLib\Events;
|
namespace TgBotLib\Events;
|
||||||
|
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\ChatBoostRemoved;
|
use TgBotLib\Objects\ChatBoostRemoved;
|
||||||
|
|
||||||
abstract class RemovedChatBoostEvent extends UpdateEvent
|
abstract class RemovedChatBoostEvent extends UpdateEvent
|
||||||
|
@ -11,9 +11,9 @@
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public static function getEventType(): EventType
|
public static function getEventType(): UpdateEventType
|
||||||
{
|
{
|
||||||
return EventType::REMOVED_CHAT_BOOST_EVENT;
|
return UpdateEventType::REMOVED_CHAT_BOOST_EVENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use TgBotLib\Abstracts\UpdateEvent;
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
use TgBotLib\Classes\Utilities;
|
use TgBotLib\Classes\Utilities;
|
||||||
use TgBotLib\Enums\EventType;
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
use TgBotLib\Objects\Update;
|
use TgBotLib\Objects\Update;
|
||||||
|
|
||||||
class PollingBot extends Bot
|
class PollingBot extends Bot
|
||||||
|
|
Loading…
Add table
Reference in a new issue