Add support for message reaction event handling
This commit is contained in:
parent
ada256566e
commit
bcf23f3834
3 changed files with 38 additions and 0 deletions
|
@ -131,6 +131,11 @@
|
||||||
return UpdateEventType::MESSAGE_REACTION_COUNT;
|
return UpdateEventType::MESSAGE_REACTION_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($update->getMessageReaction() !== null)
|
||||||
|
{
|
||||||
|
return UpdateEventType::MESSAGE_REACTION;
|
||||||
|
}
|
||||||
|
|
||||||
return UpdateEventType::UPDATE_EVENT;
|
return UpdateEventType::UPDATE_EVENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
use TgBotLib\Events\ChosenInlineResultEvent;
|
use TgBotLib\Events\ChosenInlineResultEvent;
|
||||||
use TgBotLib\Events\InlineQueryEvent;
|
use TgBotLib\Events\InlineQueryEvent;
|
||||||
use TgBotLib\Events\MessageReactionCountEvent;
|
use TgBotLib\Events\MessageReactionCountEvent;
|
||||||
|
use TgBotLib\Events\MessageReactionEvent;
|
||||||
use TgBotLib\Events\MyChatMemberUpdatedEvent;
|
use TgBotLib\Events\MyChatMemberUpdatedEvent;
|
||||||
use TgBotLib\Events\PollAnswerEvent;
|
use TgBotLib\Events\PollAnswerEvent;
|
||||||
use TgBotLib\Events\PollEvent;
|
use TgBotLib\Events\PollEvent;
|
||||||
|
@ -36,4 +37,5 @@
|
||||||
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;
|
case MESSAGE_REACTION_COUNT = MessageReactionCountEvent::class;
|
||||||
|
case MESSAGE_REACTION = MessageReactionEvent::class;
|
||||||
}
|
}
|
||||||
|
|
31
src/TgBotLib/Events/MessageReactionEvent.php
Normal file
31
src/TgBotLib/Events/MessageReactionEvent.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Events;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\UpdateEvent;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\UpdateEventType;
|
||||||
|
use TgBotLib\Objects\MessageReactionUpdated;
|
||||||
|
|
||||||
|
abstract class MessageReactionEvent extends UpdateEvent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getEventType(): UpdateEventType
|
||||||
|
{
|
||||||
|
return UpdateEventType::MESSAGE_REACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reaction to a message was changed by a user. The bot must be an administrator in the chat and must
|
||||||
|
* explicitly specify "message_reaction" in the list of allowed_updates to receive these updates.
|
||||||
|
* The update isn't received for reactions set by bots.
|
||||||
|
*
|
||||||
|
* @return MessageReactionUpdated
|
||||||
|
*/
|
||||||
|
protected function getMessageReactionUpdated(): MessageReactionUpdated
|
||||||
|
{
|
||||||
|
return $this->update->getMessageReaction();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue