From b8b1a87639273756d907bf2b18f798762a49f052 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 1 Nov 2024 18:09:14 -0400 Subject: [PATCH] Add ChatMemberUpdatedEvent handling --- src/TgBotLib/Classes/Utilities.php | 5 ++++ src/TgBotLib/Enums/EventType.php | 2 ++ .../Events/ChatMemberUpdatedEvent.php | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/TgBotLib/Events/ChatMemberUpdatedEvent.php diff --git a/src/TgBotLib/Classes/Utilities.php b/src/TgBotLib/Classes/Utilities.php index 64082af..73a74e5 100644 --- a/src/TgBotLib/Classes/Utilities.php +++ b/src/TgBotLib/Classes/Utilities.php @@ -76,6 +76,11 @@ return EventType::CHAT_JOIN_REQUEST_EVENT; } + if($update->getChatMember() !== null) + { + return EventType::CHAT_MEMBER_UPDATED; + } + return EventType::UPDATE_EVENT; } } \ No newline at end of file diff --git a/src/TgBotLib/Enums/EventType.php b/src/TgBotLib/Enums/EventType.php index 9f6ee87..1d56c62 100644 --- a/src/TgBotLib/Enums/EventType.php +++ b/src/TgBotLib/Enums/EventType.php @@ -5,6 +5,7 @@ use TgBotLib\Abstracts\UpdateEvent; use TgBotLib\Events\ChatBoostEvent; use TgBotLib\Events\ChatJoinRequestEvent; + use TgBotLib\Events\ChatMemberUpdatedEvent; use TgBotLib\Events\RemovedChatBoostEvent; enum EventType : string @@ -13,4 +14,5 @@ case REMOVED_CHAT_BOOST_EVENT = RemovedChatBoostEvent::class; case CHAT_BOOST_EVENT = ChatBoostEvent::class; case CHAT_JOIN_REQUEST_EVENT = ChatJoinRequestEvent::class; + case CHAT_MEMBER_UPDATED = ChatMemberUpdatedEvent::class; } diff --git a/src/TgBotLib/Events/ChatMemberUpdatedEvent.php b/src/TgBotLib/Events/ChatMemberUpdatedEvent.php new file mode 100644 index 0000000..6872bf5 --- /dev/null +++ b/src/TgBotLib/Events/ChatMemberUpdatedEvent.php @@ -0,0 +1,29 @@ +update->getChatMember(); + } + } \ No newline at end of file