Add PollEvent to handle new poll updates
This commit is contained in:
parent
d56cc3dd22
commit
31550fc1dc
3 changed files with 36 additions and 0 deletions
|
@ -91,6 +91,11 @@
|
|||
return UpdateEventType::POLL_ANSWER;
|
||||
}
|
||||
|
||||
if($update->getPoll() !== null)
|
||||
{
|
||||
return UpdateEventType::POLL;
|
||||
}
|
||||
|
||||
return UpdateEventType::UPDATE_EVENT;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
use TgBotLib\Events\ChatMemberUpdatedEvent;
|
||||
use TgBotLib\Events\MyChatMemberUpdatedEvent;
|
||||
use TgBotLib\Events\PollAnswerEvent;
|
||||
use TgBotLib\Events\PollEvent;
|
||||
use TgBotLib\Events\RemovedChatBoostEvent;
|
||||
|
||||
enum UpdateEventType : string
|
||||
|
@ -19,4 +20,5 @@
|
|||
case CHAT_MEMBER_UPDATED = ChatMemberUpdatedEvent::class;
|
||||
case MY_CHAT_MEMBER_UPDATED = MyChatMemberUpdatedEvent::class;
|
||||
case POLL_ANSWER = PollAnswerEvent::class;
|
||||
case POLL = PollEvent::class;
|
||||
}
|
||||
|
|
29
src/TgBotLib/Events/PollEvent.php
Normal file
29
src/TgBotLib/Events/PollEvent.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Abstracts\UpdateEvent;
|
||||
use TgBotLib\Bot;
|
||||
use TgBotLib\Enums\UpdateEventType;
|
||||
use TgBotLib\Objects\Poll;
|
||||
|
||||
abstract class PollEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): UpdateEventType
|
||||
{
|
||||
return UpdateEventType::POLL;
|
||||
}
|
||||
|
||||
/**
|
||||
* New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot
|
||||
*
|
||||
* @return Poll
|
||||
*/
|
||||
protected function getPoll(): Poll
|
||||
{
|
||||
return $this->update->getPoll();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue