diff --git a/docs b/docs
index b4d2327f9..ab4b4782f 160000
--- a/docs
+++ b/docs
@@ -1 +1 @@
-Subproject commit b4d2327f911fc85c6bdb3170a583240153656f13
+Subproject commit ab4b4782f8582ca413bcd7c94eb4900c828fd970
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 106a72ebf..60587210e 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -803,6 +803,10 @@
totalVoters]]>
+
+
+
+
@@ -1792,6 +1796,12 @@
getIdInternal($rawPinned)]]>
+
+
+
+
+
+
@@ -1808,6 +1818,10 @@
text]]>
voters]]>
+
+
+
+
@@ -1817,8 +1831,16 @@
solution]]>
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/EventHandler/AbstractPoll.php b/src/EventHandler/AbstractPoll.php
index a7c348943..6cacc1e51 100644
--- a/src/EventHandler/AbstractPoll.php
+++ b/src/EventHandler/AbstractPoll.php
@@ -21,6 +21,7 @@
use danog\MadelineProto\EventHandler\Poll\PollAnswer;
use danog\MadelineProto\EventHandler\Poll\QuizPoll;
use danog\MadelineProto\EventHandler\Poll\SinglePoll;
+use danog\MadelineProto\StrTools;
use JsonSerializable;
use ReflectionClass;
use ReflectionProperty;
@@ -99,6 +100,27 @@ private static function getPollAnswers(array $answers, array $result): array
return $out;
}
+ protected readonly string $htmlQuestion;
+ protected readonly string $htmlQuestionTelegram;
+
+ /**
+ * Get an HTML version of the question.
+ *
+ * @psalm-suppress InaccessibleProperty
+ *
+ * @param bool $allowTelegramTags Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on...
+ */
+ public function getQuestionHTML(bool $allowTelegramTags = false): string
+ {
+ if (!$this->questionEntities) {
+ return StrTools::htmlEscape($this->question);
+ }
+ if ($allowTelegramTags) {
+ return $this->htmlQuestionTelegram ??= StrTools::entitiesToHtml($this->question, $this->questionEntities, $allowTelegramTags);
+ }
+ return $this->htmlQuestion ??= StrTools::entitiesToHtml($this->question, $this->questionEntities, $allowTelegramTags);
+ }
+
/** @internal */
public function jsonSerialize(): mixed
{
diff --git a/src/EventHandler/Poll/PollAnswer.php b/src/EventHandler/Poll/PollAnswer.php
index a23c1ca1f..c5a25f71e 100644
--- a/src/EventHandler/Poll/PollAnswer.php
+++ b/src/EventHandler/Poll/PollAnswer.php
@@ -17,6 +17,7 @@
namespace danog\MadelineProto\EventHandler\Poll;
use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity;
+use danog\MadelineProto\StrTools;
use danog\MadelineProto\TL\Types\Bytes;
use JsonSerializable;
use ReflectionClass;
@@ -58,6 +59,27 @@ public function __construct(array $rawAnswer)
$this->voters = $rawAnswer['voters'] ?? null;
}
+ protected readonly string $html;
+ protected readonly string $htmlTelegram;
+
+ /**
+ * Get an HTML version of the answer.
+ *
+ * @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->text);
+ }
+ if ($allowTelegramTags) {
+ return $this->htmlTelegram ??= StrTools::entitiesToHtml($this->text, $this->entities, $allowTelegramTags);
+ }
+ return $this->html ??= StrTools::entitiesToHtml($this->text, $this->entities, $allowTelegramTags);
+ }
+
/** @internal */
public function jsonSerialize(): mixed
{
diff --git a/src/EventHandler/Poll/QuizPoll.php b/src/EventHandler/Poll/QuizPoll.php
index accd06ea2..b86df9946 100644
--- a/src/EventHandler/Poll/QuizPoll.php
+++ b/src/EventHandler/Poll/QuizPoll.php
@@ -27,18 +27,18 @@ final class QuizPoll extends AbstractPoll
public readonly ?string $solution;
/** @var list Message [entities](https://core.telegram.org/api/entities) for styled text in quiz solution */
- public readonly array $entities;
+ public readonly array $solutionEntities;
/** @internal */
public function __construct(array $rawPoll)
{
parent::__construct($rawPoll);
$this->solution = $rawPoll['results']['solution'] ?? null;
- $this->entities = MessageEntity::fromRawEntities($rawPoll['results']['solution_entites'] ?? []);
+ $this->solutionEntities = MessageEntity::fromRawEntities($rawPoll['results']['solution_entites'] ?? []);
}
- protected readonly string $html;
- protected readonly string $htmlTelegram;
+ protected readonly string $htmlSolution;
+ protected readonly string $htmlSolutionTelegram;
/**
* Get an HTML version of the solution.
@@ -47,17 +47,17 @@ public function __construct(array $rawPoll)
*
* @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
+ public function getSolutionHTML(bool $allowTelegramTags = false): ?string
{
if ($this->solution === null) {
return null;
}
- if (!$this->entities) {
+ if (!$this->solutionEntities) {
return StrTools::htmlEscape($this->solution);
}
if ($allowTelegramTags) {
- return $this->htmlTelegram ??= StrTools::entitiesToHtml($this->solution, $this->entities, $allowTelegramTags);
+ return $this->htmlSolutionTelegram ??= StrTools::entitiesToHtml($this->solution, $this->solutionEntities, $allowTelegramTags);
}
- return $this->html ??= StrTools::entitiesToHtml($this->solution, $this->entities, $allowTelegramTags);
+ return $this->htmlSolution ??= StrTools::entitiesToHtml($this->solution, $this->solutionEntities, $allowTelegramTags);
}
}