Add support for MyChatMemberUpdatedEvent

This commit is contained in:
netkas 2024-11-01 18:13:09 -04:00
parent 73d14179b1
commit 3ce87cabcb
3 changed files with 37 additions and 0 deletions

View file

@ -81,6 +81,11 @@
return UpdateEventType::CHAT_MEMBER_UPDATED;
}
if($update->getMyChatMember() !== null)
{
return UpdateEventType::MY_CHAT_MEMBER_UPDATED;
}
return UpdateEventType::UPDATE_EVENT;
}
}

View file

@ -6,6 +6,7 @@
use TgBotLib\Events\ChatBoostEvent;
use TgBotLib\Events\ChatJoinRequestEvent;
use TgBotLib\Events\ChatMemberUpdatedEvent;
use TgBotLib\Events\MyChatMemberUpdatedEvent;
use TgBotLib\Events\RemovedChatBoostEvent;
enum UpdateEventType : string
@ -15,4 +16,5 @@
case CHAT_BOOST_EVENT = ChatBoostEvent::class;
case CHAT_JOIN_REQUEST_EVENT = ChatJoinRequestEvent::class;
case CHAT_MEMBER_UPDATED = ChatMemberUpdatedEvent::class;
case MY_CHAT_MEMBER_UPDATED = MyChatMemberUpdatedEvent::class;
}

View file

@ -0,0 +1,30 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\ChatMemberUpdated;
abstract class MyChatMemberUpdatedEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::MY_CHAT_MEMBER_UPDATED;
}
/**
* The bot's chat member status was updated in a chat. For private chats,
* this update is received only when the bot is blocked or unblocked by the user.
*
* @return ChatMemberUpdated The updated chat member information.
*/
protected function getMyChatMemberUpdated(): ChatMemberUpdated
{
return $this->update->getMyChatMember();
}
}