From 41091710e469f40e56183ee7362a69f58a1a8bba Mon Sep 17 00:00:00 2001 From: AhJ Date: Fri, 5 Jan 2024 18:42:55 +0330 Subject: [PATCH] add poll object and its filters --- src/EventHandler/AbstractPoll.php | 98 +++++++++++++++++++ src/EventHandler/Filter/Filter.php | 66 ++++++++----- src/EventHandler/Filter/FilterPoll.php | 33 +++++++ .../Filter/Media/Poll/FilterMultiplePoll.php | 35 +++++++ .../Filter/Media/Poll/FilterQuizPoll.php | 35 +++++++ .../Filter/Media/Poll/FilterSinglePoll.php | 35 +++++++ src/EventHandler/Message.php | 22 +++-- src/EventHandler/Poll/MultiplePoll.php | 30 ++++++ src/EventHandler/Poll/PollAnswer.php | 63 ++++++++++++ src/EventHandler/Poll/QuizPoll.php | 60 ++++++++++++ src/EventHandler/Poll/SinglePoll.php | 30 ++++++ .../SimpleFilter/HasMultiplePoll.php | 22 +++++ src/EventHandler/SimpleFilter/HasPoll.php | 22 +++++ src/EventHandler/SimpleFilter/HasQuizPoll.php | 22 +++++ .../SimpleFilter/HasSinglePoll.php | 22 +++++ 15 files changed, 561 insertions(+), 34 deletions(-) create mode 100644 src/EventHandler/AbstractPoll.php create mode 100644 src/EventHandler/Filter/FilterPoll.php create mode 100644 src/EventHandler/Filter/Media/Poll/FilterMultiplePoll.php create mode 100644 src/EventHandler/Filter/Media/Poll/FilterQuizPoll.php create mode 100644 src/EventHandler/Filter/Media/Poll/FilterSinglePoll.php create mode 100644 src/EventHandler/Poll/MultiplePoll.php create mode 100644 src/EventHandler/Poll/PollAnswer.php create mode 100644 src/EventHandler/Poll/QuizPoll.php create mode 100644 src/EventHandler/Poll/SinglePoll.php create mode 100644 src/EventHandler/SimpleFilter/HasMultiplePoll.php create mode 100644 src/EventHandler/SimpleFilter/HasPoll.php create mode 100644 src/EventHandler/SimpleFilter/HasQuizPoll.php create mode 100644 src/EventHandler/SimpleFilter/HasSinglePoll.php diff --git a/src/EventHandler/AbstractPoll.php b/src/EventHandler/AbstractPoll.php new file mode 100644 index 000000000..f894d200f --- /dev/null +++ b/src/EventHandler/AbstractPoll.php @@ -0,0 +1,98 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler; + +use JsonSerializable; +use ReflectionClass; +use ReflectionProperty; +use danog\MadelineProto\EventHandler\Poll\QuizPoll; +use danog\MadelineProto\EventHandler\Poll\SinglePoll; +use danog\MadelineProto\EventHandler\Poll\PollAnswer; +use danog\MadelineProto\EventHandler\Poll\MultiplePoll; + +/** Poll */ +abstract class AbstractPoll implements JsonSerializable +{ + /** ID of the poll */ + public readonly int $id; + + /** Whether the poll is closed and doesn’t accept any more answers */ + public readonly bool $closed; + + /** The question of the poll */ + public readonly string $question; + + /** @var list The possible answers */ + public readonly array $answers; + + /** Amount of time in seconds the poll will be active after creation, 5-600 */ + public readonly ?int $closePeriod; + + /** Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future */ + public readonly ?int $closeDate; + + /** @var list IDs of the last users that recently voted in the poll */ + public readonly array $recentVoters; + + /** Total number of people that voted in the poll */ + public readonly int $totalVoters; + + /** @internal */ + public function __construct(array $rawPoll) + { + $this->id = $rawPoll['poll']['id']; + $this->closed = $rawPoll['poll']['closed']; + $this->question = $rawPoll['poll']['question']; + $this->closeDate = $rawPoll['poll']['close_date'] ?? null; + $this->closePeriod = $rawPoll['poll']['close_period'] ?? null; + $this->recentVoters = $rawPoll['poll']['public_voters'] ? $rawPoll['results']['recent_voters'] : []; + $this->totalVoters = $rawPoll['results']['total_voters']; + $this->answers = $this->getPollAnswers($rawPoll['poll']['answers'], $rawPoll['results']['results'] ?? []); + } + + public static function fromRawPoll(array $rawPoll) + { + if ($rawPoll['poll']['quiz']) + return new QuizPoll($rawPoll); + + if ($rawPoll['poll']['multiple_choice']) + return new MultiplePoll($rawPoll); + + return new SinglePoll($rawPoll); + } + + private function getPollAnswers(array $answers, array $result): array + { + $out = []; + foreach ($answers as $key => $value) { + $merge = array_merge($value, $result[$key] ?? []); + $out[] = new PollAnswer($merge); + } + return $out; + } + + /** @internal */ + public function jsonSerialize(): mixed + { + $res = ['_' => static::class]; + $refl = new ReflectionClass($this); + foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) { + $res[$prop->getName()] = $prop->getValue($this); + } + return $res; + } +} diff --git a/src/EventHandler/Filter/Filter.php b/src/EventHandler/Filter/Filter.php index 64369533a..178928389 100644 --- a/src/EventHandler/Filter/Filter.php +++ b/src/EventHandler/Filter/Filter.php @@ -17,52 +17,60 @@ namespace danog\MadelineProto\EventHandler\Filter; use AssertionError; +use ReflectionType; +use ReflectionNamedType; +use ReflectionUnionType; +use ReflectionIntersectionType; use danog\MadelineProto\EventHandler; -use danog\MadelineProto\EventHandler\Filter\Combinator\FiltersAnd; -use danog\MadelineProto\EventHandler\Filter\Combinator\FiltersOr; -use danog\MadelineProto\EventHandler\Filter\Media\FilterAudio; -use danog\MadelineProto\EventHandler\Filter\Media\FilterDocument; -use danog\MadelineProto\EventHandler\Filter\Media\FilterDocumentPhoto; +use danog\MadelineProto\EventHandler\Update; +use danog\MadelineProto\EventHandler\Message; +use danog\MadelineProto\EventHandler\Message\GroupMessage; +use danog\MadelineProto\EventHandler\Message\SecretMessage; +use danog\MadelineProto\EventHandler\Message\ChannelMessage; +use danog\MadelineProto\EventHandler\Message\PrivateMessage; +use danog\MadelineProto\EventHandler\Message\ServiceMessage; +use danog\MadelineProto\EventHandler\Filter\FilterPoll; +use danog\MadelineProto\EventHandler\Filter\Poll\FilterQuizPoll; +use danog\MadelineProto\EventHandler\Filter\Poll\FilterSinglePoll; +use danog\MadelineProto\EventHandler\Filter\Poll\FilterMultiplePoll; use danog\MadelineProto\EventHandler\Filter\Media\FilterGif; +use danog\MadelineProto\EventHandler\Filter\Media\FilterAudio; use danog\MadelineProto\EventHandler\Filter\Media\FilterPhoto; -use danog\MadelineProto\EventHandler\Filter\Media\FilterRoundVideo; -use danog\MadelineProto\EventHandler\Filter\Media\FilterSticker; use danog\MadelineProto\EventHandler\Filter\Media\FilterVideo; use danog\MadelineProto\EventHandler\Filter\Media\FilterVoice; -use danog\MadelineProto\EventHandler\Message; -use danog\MadelineProto\EventHandler\Message\ChannelMessage; -use danog\MadelineProto\EventHandler\Message\GroupMessage; -use danog\MadelineProto\EventHandler\Message\PrivateMessage; -use danog\MadelineProto\EventHandler\Message\SecretMessage; -use danog\MadelineProto\EventHandler\Message\ServiceMessage; +use danog\MadelineProto\EventHandler\Filter\Media\FilterSticker; +use danog\MadelineProto\EventHandler\Filter\Media\FilterDocument; +use danog\MadelineProto\EventHandler\Filter\Media\FilterRoundVideo; +use danog\MadelineProto\EventHandler\Filter\Media\FilterDocumentPhoto; use danog\MadelineProto\EventHandler\SimpleFilter\Ended; -use danog\MadelineProto\EventHandler\SimpleFilter\FromAdmin; -use danog\MadelineProto\EventHandler\SimpleFilter\FromAdminOrOutgoing; -use danog\MadelineProto\EventHandler\SimpleFilter\HasAudio; -use danog\MadelineProto\EventHandler\SimpleFilter\HasDocument; -use danog\MadelineProto\EventHandler\SimpleFilter\HasDocumentPhoto; +use danog\MadelineProto\EventHandler\SimpleFilter\Outgoing; +use danog\MadelineProto\EventHandler\SimpleFilter\Running; use danog\MadelineProto\EventHandler\SimpleFilter\HasGif; +use danog\MadelineProto\EventHandler\SimpleFilter\HasAudio; +use danog\MadelineProto\EventHandler\SimpleFilter\HasPhoto; use danog\MadelineProto\EventHandler\SimpleFilter\HasMedia; use danog\MadelineProto\EventHandler\SimpleFilter\HasNoMedia; -use danog\MadelineProto\EventHandler\SimpleFilter\HasPhoto; +use danog\MadelineProto\EventHandler\SimpleFilter\HasDocument; use danog\MadelineProto\EventHandler\SimpleFilter\HasRoundVideo; +use danog\MadelineProto\EventHandler\SimpleFilter\HasDocumentPhoto; +use danog\MadelineProto\EventHandler\SimpleFilter\HasPoll; +use danog\MadelineProto\EventHandler\SimpleFilter\HasQuizPoll; +use danog\MadelineProto\EventHandler\SimpleFilter\HasSinglePoll; +use danog\MadelineProto\EventHandler\SimpleFilter\HasMultiplePoll; use danog\MadelineProto\EventHandler\SimpleFilter\HasSticker; use danog\MadelineProto\EventHandler\SimpleFilter\HasVideo; use danog\MadelineProto\EventHandler\SimpleFilter\HasVoice; use danog\MadelineProto\EventHandler\SimpleFilter\HasTopic; use danog\MadelineProto\EventHandler\SimpleFilter\Incoming; use danog\MadelineProto\EventHandler\SimpleFilter\IsEdited; -use danog\MadelineProto\EventHandler\SimpleFilter\IsForwarded; use danog\MadelineProto\EventHandler\SimpleFilter\IsNotEdited; +use danog\MadelineProto\EventHandler\SimpleFilter\IsForwarded; use danog\MadelineProto\EventHandler\SimpleFilter\IsReply; use danog\MadelineProto\EventHandler\SimpleFilter\IsReplyToSelf; -use danog\MadelineProto\EventHandler\SimpleFilter\Outgoing; -use danog\MadelineProto\EventHandler\SimpleFilter\Running; -use danog\MadelineProto\EventHandler\Update; -use ReflectionIntersectionType; -use ReflectionNamedType; -use ReflectionType; -use ReflectionUnionType; +use danog\MadelineProto\EventHandler\SimpleFilter\FromAdmin; +use danog\MadelineProto\EventHandler\SimpleFilter\FromAdminOrOutgoing; +use danog\MadelineProto\EventHandler\Filter\Combinator\FiltersAnd; +use danog\MadelineProto\EventHandler\Filter\Combinator\FiltersOr; abstract class Filter { @@ -116,6 +124,10 @@ abstract class Filter HasVideo::class => new FilterVideo, HasVoice::class => new FilterVoice, HasTopic::class => new FilterTopic, + HasPoll::class => new FilterPoll, + HasQuizPoll::class => new FilterQuizPoll, + HasSinglePoll::class => new FilterSinglePoll, + HasMultiplePoll::class => new FilterMultiplePoll, Ended::class => new FilterEnded, Running::class => new FilterRunning, FromAdminOrOutgoing::class => new FiltersOr(new FilterFromAdmin, new FilterOutgoing), diff --git a/src/EventHandler/Filter/FilterPoll.php b/src/EventHandler/Filter/FilterPoll.php new file mode 100644 index 000000000..65c2d0b33 --- /dev/null +++ b/src/EventHandler/Filter/FilterPoll.php @@ -0,0 +1,33 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Filter; + +use Attribute; +use danog\MadelineProto\EventHandler\Update; +use danog\MadelineProto\EventHandler\Message; + +/** + * Allow only messages that contain a poll. + */ +#[Attribute(Attribute::TARGET_METHOD)] +final class FilterPoll extends Filter +{ + public function apply(Update $update): bool + { + return ($update instanceof Message && $update->poll !== null); + } +} diff --git a/src/EventHandler/Filter/Media/Poll/FilterMultiplePoll.php b/src/EventHandler/Filter/Media/Poll/FilterMultiplePoll.php new file mode 100644 index 000000000..7e98c166a --- /dev/null +++ b/src/EventHandler/Filter/Media/Poll/FilterMultiplePoll.php @@ -0,0 +1,35 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Filter\Poll; + +use Attribute; +use danog\MadelineProto\EventHandler\Update; +use danog\MadelineProto\EventHandler\Message; +use danog\MadelineProto\EventHandler\Filter\Filter; +use danog\MadelineProto\EventHandler\Poll\MultiplePoll; + +/** + * Allow only messages that contain a multiple poll. + */ +#[Attribute(Attribute::TARGET_METHOD)] +final class FilterMultiplePoll extends Filter +{ + public function apply(Update $update): bool + { + return ($update instanceof Message && $update->poll instanceof MultiplePoll); + } +} diff --git a/src/EventHandler/Filter/Media/Poll/FilterQuizPoll.php b/src/EventHandler/Filter/Media/Poll/FilterQuizPoll.php new file mode 100644 index 000000000..744485864 --- /dev/null +++ b/src/EventHandler/Filter/Media/Poll/FilterQuizPoll.php @@ -0,0 +1,35 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Filter\Poll; + +use Attribute; +use danog\MadelineProto\EventHandler\Update; +use danog\MadelineProto\EventHandler\Message; +use danog\MadelineProto\EventHandler\Filter\Filter; +use danog\MadelineProto\EventHandler\Poll\QuizPoll; + +/** + * Allow only messages that contain a quiz poll. + */ +#[Attribute(Attribute::TARGET_METHOD)] +final class FilterQuizPoll extends Filter +{ + public function apply(Update $update): bool + { + return ($update instanceof Message && $update->poll instanceof QuizPoll); + } +} diff --git a/src/EventHandler/Filter/Media/Poll/FilterSinglePoll.php b/src/EventHandler/Filter/Media/Poll/FilterSinglePoll.php new file mode 100644 index 000000000..260fb521d --- /dev/null +++ b/src/EventHandler/Filter/Media/Poll/FilterSinglePoll.php @@ -0,0 +1,35 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Filter\Poll; + +use Attribute; +use danog\MadelineProto\EventHandler\Update; +use danog\MadelineProto\EventHandler\Message; +use danog\MadelineProto\EventHandler\Filter\Filter; +use danog\MadelineProto\EventHandler\Poll\SinglePoll; + +/** + * Allow only messages that contain a single poll. + */ +#[Attribute(Attribute::TARGET_METHOD)] +final class FilterSinglePoll extends Filter +{ + public function apply(Update $update): bool + { + return ($update instanceof Message && $update->poll instanceof SinglePoll); + } +} diff --git a/src/EventHandler/Message.php b/src/EventHandler/Message.php index 89de2f457..ec9af4194 100644 --- a/src/EventHandler/Message.php +++ b/src/EventHandler/Message.php @@ -21,9 +21,10 @@ use danog\MadelineProto\StrTools; use danog\MadelineProto\ParseMode; use danog\MadelineProto\EventHandler\Media\Gif; use danog\MadelineProto\EventHandler\Media\Audio; -use danog\MadelineProto\EventHandler\Media\Voice; -use danog\MadelineProto\EventHandler\Media\Video; use danog\MadelineProto\EventHandler\Media\Photo; +use danog\MadelineProto\EventHandler\Media\Video; +use danog\MadelineProto\EventHandler\Media\Voice; +use danog\MadelineProto\EventHandler\AbstractPoll; use danog\MadelineProto\EventHandler\Media\Sticker; use danog\MadelineProto\EventHandler\Media\Document; use danog\MadelineProto\EventHandler\Media\RoundVideo; @@ -113,6 +114,9 @@ abstract class Message extends AbstractMessage */ public readonly ?int $groupedId; + /** The poll */ + public readonly ?AbstractPoll $poll; + /** @internal */ public function __construct( MTProto $API, @@ -138,10 +142,6 @@ abstract class Message extends AbstractMessage $this->viaBotId = $rawMessage['via_bot_id'] ?? (isset($rawMessage['via_bot_name']) ? $this->getClient()->getId($rawMessage['via_bot_name']) : null); - $this->keyboard = isset($rawMessage['reply_markup']) - ? Keyboard::fromRawReplyMarkup($rawMessage['reply_markup']) - : null; - if (isset($rawMessage['fwd_from'])) { $fwdFrom = $rawMessage['fwd_from']; @@ -165,10 +165,18 @@ abstract class Message extends AbstractMessage $this->psaType = null; $this->imported = false; } - + $this->media = isset($rawMessage['media']) ? $API->wrapMedia($rawMessage['media'], $this->protected) : null; + + $this->keyboard = isset($rawMessage['reply_markup']) + ? Keyboard::fromRawReplyMarkup($rawMessage['reply_markup']) + : null; + + $this->poll = ($rawMessage['media']['_'] ?? '') === 'messageMediaPoll' + ? AbstractPoll::fromRawPoll($rawMessage['media']) + : null; if ($this->commandType = CommandType::tryFrom($this->message[0] ?? '')) { $space = \strpos($this->message, ' ', 1) ?: \strlen($this->message); diff --git a/src/EventHandler/Poll/MultiplePoll.php b/src/EventHandler/Poll/MultiplePoll.php new file mode 100644 index 000000000..e2b3dcbb5 --- /dev/null +++ b/src/EventHandler/Poll/MultiplePoll.php @@ -0,0 +1,30 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Poll; + +use danog\MadelineProto\MTProto; +use danog\MadelineProto\EventHandler\AbstractPoll; + +/** Represents a poll with multiple options can be chosen as answer */ +final class MultiplePoll extends AbstractPoll +{ + /** @internal */ + public function __construct(array $rawPoll) + { + parent::__construct($rawPoll); + } +} \ No newline at end of file diff --git a/src/EventHandler/Poll/PollAnswer.php b/src/EventHandler/Poll/PollAnswer.php new file mode 100644 index 000000000..15919d58f --- /dev/null +++ b/src/EventHandler/Poll/PollAnswer.php @@ -0,0 +1,63 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Poll; + +use JsonSerializable; +use ReflectionClass; +use ReflectionProperty; +use danog\MadelineProto\TL\Types\Bytes; + +/** Represents a possible answer of a poll */ +final readonly class PollAnswer implements JsonSerializable +{ + /** Textual representation of the answer */ + public string $text; + + /** The param that has to be passed to [messages.sendVote](https://docs.madelineproto.xyz/API_docs/methods/messages.sendVote.html) */ + public string $option; + + /** Whether we have chosen this answer */ + public ?bool $chosen; + + /** For quizzes, whether the option we have chosen is correct */ + public ?bool $correct; + + /** How many users voted for this option */ + public ?int $voters; + + /** @internal */ + public function __construct(array $rawAnswer) + { + $this->text = $rawAnswer['text']; + $this->option = (string) $rawAnswer['option']; + $this->chosen = $rawAnswer['chosen'] ?? null; + $this->correct = $rawAnswer['correct'] ?? null; + $this->voters = $rawAnswer['voters'] ?? null; + } + + /** @internal */ + public function jsonSerialize(): mixed + { + $res = ['_' => static::class]; + $refl = new ReflectionClass($this); + foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) { + $res[$prop->getName()] = $prop->getValue($this); + } + $res['option'] = new Bytes($res['option']); + return $res; + } +} \ No newline at end of file diff --git a/src/EventHandler/Poll/QuizPoll.php b/src/EventHandler/Poll/QuizPoll.php new file mode 100644 index 000000000..3a99ad7ae --- /dev/null +++ b/src/EventHandler/Poll/QuizPoll.php @@ -0,0 +1,60 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Poll; + +use danog\MadelineProto\StrTools; +use danog\MadelineProto\EventHandler\AbstractPoll; +use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity; + +/** Represents a quiz (with wrong and correct answers, results shown in the return type) poll */ +final class QuizPoll extends AbstractPoll +{ + /** Explanation of quiz solution */ + public readonly ?string $solution; + + /** @var list Message [entities](https://core.telegram.org/api/entities) for styled text in quiz solution */ + public readonly array $entities; + + /** @internal */ + public function __construct(array $rawPoll) + { + parent::__construct($rawPoll); + $this->solution = $rawPoll['results']['solution'] ?? null; + $this->entities = MessageEntity::fromRawEntities($rawPoll['results']['solution_entites'] ?? []); + } + + protected readonly string $html; + protected readonly string $htmlTelegram; + + /** + * Get an HTML version of the solution. + * + * @psalm-suppress InaccessibleProperty + * + * @param bool $allowTelegramTags Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on... + */ + public function getHTML(bool $allowTelegramTags = false): string + { + if (!$this->entities) { + return StrTools::htmlEscape($this->solution); + } + if ($allowTelegramTags) { + return $this->htmlTelegram ??= StrTools::entitiesToHtml($this->solution, $this->entities, $allowTelegramTags); + } + return $this->html ??= StrTools::entitiesToHtml($this->solution, $this->entities, $allowTelegramTags); + } +} \ No newline at end of file diff --git a/src/EventHandler/Poll/SinglePoll.php b/src/EventHandler/Poll/SinglePoll.php new file mode 100644 index 000000000..5a986b79b --- /dev/null +++ b/src/EventHandler/Poll/SinglePoll.php @@ -0,0 +1,30 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\Poll; + +use danog\MadelineProto\MTProto; +use danog\MadelineProto\EventHandler\AbstractPoll; + +/** Represents a poll with a option can be chosen as answer*/ +final class SinglePoll extends AbstractPoll +{ + /** @internal */ + public function __construct(array $rawPoll) + { + parent::__construct($rawPoll); + } +} \ No newline at end of file diff --git a/src/EventHandler/SimpleFilter/HasMultiplePoll.php b/src/EventHandler/SimpleFilter/HasMultiplePoll.php new file mode 100644 index 000000000..8d27373db --- /dev/null +++ b/src/EventHandler/SimpleFilter/HasMultiplePoll.php @@ -0,0 +1,22 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\SimpleFilter; + +/** Allows only messages that contain a multiple poll */ +interface HasMultiplePoll +{ +} diff --git a/src/EventHandler/SimpleFilter/HasPoll.php b/src/EventHandler/SimpleFilter/HasPoll.php new file mode 100644 index 000000000..54a86e5ad --- /dev/null +++ b/src/EventHandler/SimpleFilter/HasPoll.php @@ -0,0 +1,22 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\SimpleFilter; + +/** Allows only messages that contain a poll */ +interface HasPoll +{ +} diff --git a/src/EventHandler/SimpleFilter/HasQuizPoll.php b/src/EventHandler/SimpleFilter/HasQuizPoll.php new file mode 100644 index 000000000..a8fdda256 --- /dev/null +++ b/src/EventHandler/SimpleFilter/HasQuizPoll.php @@ -0,0 +1,22 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\SimpleFilter; + +/** Allows only messages that contain a quiz poll */ +interface HasQuizPoll +{ +} diff --git a/src/EventHandler/SimpleFilter/HasSinglePoll.php b/src/EventHandler/SimpleFilter/HasSinglePoll.php new file mode 100644 index 000000000..6126f90bf --- /dev/null +++ b/src/EventHandler/SimpleFilter/HasSinglePoll.php @@ -0,0 +1,22 @@ +. + * + * @author Amir Hossein Jafari + * @copyright 2016-2023 Amir Hossein Jafari + * @license https://opensource.org/licenses/AGPL-3.0 AGPLv3 + * @link https://docs.madelineproto.xyz MadelineProto documentation + */ + +namespace danog\MadelineProto\EventHandler\SimpleFilter; + +/** Allows only messages that contain a single poll */ +interface HasSinglePoll +{ +}