Add support for message reaction count events

This commit is contained in:
netkas 2024-11-02 00:20:28 -04:00
parent ac431136de
commit ada256566e
3 changed files with 38 additions and 0 deletions

View file

@ -126,6 +126,11 @@
return UpdateEventType::INLINE_QUERY; return UpdateEventType::INLINE_QUERY;
} }
if($update->getMessageReactionCount() !== null)
{
return UpdateEventType::MESSAGE_REACTION_COUNT;
}
return UpdateEventType::UPDATE_EVENT; return UpdateEventType::UPDATE_EVENT;
} }
} }

View file

@ -9,6 +9,7 @@
use TgBotLib\Events\ChatMemberUpdatedEvent; use TgBotLib\Events\ChatMemberUpdatedEvent;
use TgBotLib\Events\ChosenInlineResultEvent; use TgBotLib\Events\ChosenInlineResultEvent;
use TgBotLib\Events\InlineQueryEvent; use TgBotLib\Events\InlineQueryEvent;
use TgBotLib\Events\MessageReactionCountEvent;
use TgBotLib\Events\MyChatMemberUpdatedEvent; use TgBotLib\Events\MyChatMemberUpdatedEvent;
use TgBotLib\Events\PollAnswerEvent; use TgBotLib\Events\PollAnswerEvent;
use TgBotLib\Events\PollEvent; use TgBotLib\Events\PollEvent;
@ -34,4 +35,5 @@
case CALLBACK_QUERY = CallbackQueryEvent::class; case CALLBACK_QUERY = CallbackQueryEvent::class;
case CHOSEN_INLINE_RESULT = ChosenInlineResultEvent::class; case CHOSEN_INLINE_RESULT = ChosenInlineResultEvent::class;
case INLINE_QUERY = InlineQueryEvent::class; case INLINE_QUERY = InlineQueryEvent::class;
case MESSAGE_REACTION_COUNT = MessageReactionCountEvent::class;
} }

View file

@ -0,0 +1,31 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Bot;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\MessageReactionCountUpdated;
abstract class MessageReactionCountEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::MESSAGE_REACTION_COUNT;
}
/**
* Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat
* and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates.
* The updates are grouped and can be sent with delay up to a few minutes.
*
* @return MessageReactionCountUpdated
*/
protected function getMessageReactionCount(): MessageReactionCountUpdated
{
return $this->update->getMessageReactionCount();
}
}