From f331ab7edef8ec4271f3ee80f2c79576f6e513dd Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 4 Oct 2024 13:36:18 -0400 Subject: [PATCH] Added MessageReactionCountUpdated --- .../Objects/MessageReactionCountUpdated.php | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 src/TgBotLib/Objects/MessageReactionCountUpdated.php diff --git a/src/TgBotLib/Objects/MessageReactionCountUpdated.php b/src/TgBotLib/Objects/MessageReactionCountUpdated.php new file mode 100644 index 0000000..9705c57 --- /dev/null +++ b/src/TgBotLib/Objects/MessageReactionCountUpdated.php @@ -0,0 +1,88 @@ +chat; + } + + /** + * Unique message identifier inside the chat + * + * @return int + */ + public function getMessageId(): int + { + return $this->message_id; + } + + /** + * Date of the change in Unix time + * + * @return int + */ + public function getDate(): int + { + return $this->date; + } + + /** + * List of reactions that are present on the message + * + * @return ReactionCount[] + */ + public function getReactionCounts(): array + { + return $this->reaction_counts; + } + + /** + * @inheritDoc + */ + public function toArray(): ?array + { + return [ + 'chat' => $this->chat->toArray(), + 'message_id' => $this->message_id, + 'date' => $this->date, + 'reaction_counts' => array_map(fn(ReactionCount $reaction_count) => $reaction_count->toArray(), $this->reaction_counts) + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(?array $data): ?ObjectTypeInterface + { + if($data === null) + { + return null; + } + + $object = new self(); + $object->chat = Chat::fromArray($data['chat']); + $object->message_id = $data['message_id']; + $object->date = $data['date']; + $object->reaction_counts = array_map(fn($reaction_count) => ReactionCount::fromArray($reaction_count), $data['reaction_counts']); + + return $object; + } + } \ No newline at end of file