Add support for edited channel post events

This commit is contained in:
netkas 2024-11-03 17:15:47 -05:00
parent 325e29a930
commit 041c2dc84c
3 changed files with 35 additions and 0 deletions

View file

@ -156,6 +156,11 @@
return UpdateEventType::BUSINESS_CONNECTION;
}
if($update->getEditedChannelPost() !== null)
{
return UpdateEventType::EDITED_CHANNEL_POST;
}
return UpdateEventType::UPDATE_EVENT;
}
}

View file

@ -12,6 +12,7 @@
use TgBotLib\Events\ChosenInlineResultEvent;
use TgBotLib\Events\DeletedBusinessMessagesEvent;
use TgBotLib\Events\EditedBusinessMessageEvent;
use TgBotLib\Events\EditedChannelPostEvent;
use TgBotLib\Events\InlineQueryEvent;
use TgBotLib\Events\MessageReactionCountEvent;
use TgBotLib\Events\MessageReactionEvent;
@ -45,4 +46,5 @@
case EDITED_BUSINESS_MESSAGE = EditedBusinessMessageEvent::class;
case BUSINESS_MESSAGE = BusinessMessageEvent::class;
case BUSINESS_CONNECTION = BusinessConnectionEvent::class;
case EDITED_CHANNEL_POST = EditedChannelPostEvent::class;
}

View file

@ -0,0 +1,28 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Message;
abstract class EditedChannelPostEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::EDITED_CHANNEL_POST;
}
/**
* Retrieves the edited channel post from the update.
*
* @return Message The edited channel post.
*/
protected function getEditedChannelPost(): Message
{
return $this->update->getEditedChannelPost();
}
}