From c9f4f370527ea2c97500e46da13a6e28fb2e96ed Mon Sep 17 00:00:00 2001 From: al3x5dev Date: Fri, 24 Jul 2026 01:26:16 -0400 Subject: [PATCH 1/4] feat: update Telegram Bot API to version 10.2 --- src/Telegram/Entities/BotCommand.php | 1 + .../Entities/BotSubscriptionUpdated.php | 22 ++ src/Telegram/Entities/ChatFullInfo.php | 4 + src/Telegram/Entities/ChatJoinRequest.php | 1 + src/Telegram/Entities/Community.php | 19 ++ src/Telegram/Entities/CommunityChatAdded.php | 20 ++ .../Entities/CommunityChatRemoved.php | 17 ++ src/Telegram/Entities/InputMediaLink.php | 19 ++ src/Telegram/Entities/InputMediaVoiceNote.php | 25 ++ src/Telegram/Entities/InputMessageContent.php | 5 + .../Entities/InputPollOptionMedia.php | 4 + src/Telegram/Entities/InputRichBlock.php | 102 ++++++++ .../Entities/InputRichBlockAnchor.php | 19 ++ .../Entities/InputRichBlockAnimation.php | 23 ++ src/Telegram/Entities/InputRichBlockAudio.php | 23 ++ .../Entities/InputRichBlockBlockQuotation.php | 23 ++ .../Entities/InputRichBlockCollage.php | 23 ++ .../Entities/InputRichBlockDetails.php | 24 ++ .../Entities/InputRichBlockDivider.php | 18 ++ .../Entities/InputRichBlockFooter.php | 21 ++ src/Telegram/Entities/InputRichBlockList.php | 21 ++ .../Entities/InputRichBlockListItem.php | 24 ++ src/Telegram/Entities/InputRichBlockMap.php | 26 ++ .../InputRichBlockMathematicalExpression.php | 19 ++ .../Entities/InputRichBlockParagraph.php | 21 ++ src/Telegram/Entities/InputRichBlockPhoto.php | 23 ++ .../Entities/InputRichBlockPreformatted.php | 22 ++ .../Entities/InputRichBlockPullQuotation.php | 23 ++ .../Entities/InputRichBlockSectionHeading.php | 22 ++ .../Entities/InputRichBlockSlideshow.php | 23 ++ src/Telegram/Entities/InputRichBlockTable.php | 25 ++ .../Entities/InputRichBlockThinking.php | 21 ++ src/Telegram/Entities/InputRichBlockVideo.php | 23 ++ .../Entities/InputRichBlockVoiceNote.php | 23 ++ src/Telegram/Entities/InputRichMessage.php | 26 ++ .../Entities/InputRichMessageContent.php | 20 ++ .../Entities/InputRichMessageMedia.php | 21 ++ src/Telegram/Entities/Link.php | 18 ++ src/Telegram/Entities/Message.php | 9 + src/Telegram/Entities/PollMedia.php | 2 + src/Telegram/Entities/ReplyParameters.php | 2 +- src/Telegram/Entities/RichBlock.php | 102 ++++++++ src/Telegram/Entities/RichBlockAnchor.php | 19 ++ src/Telegram/Entities/RichBlockAnimation.php | 24 ++ src/Telegram/Entities/RichBlockAudio.php | 23 ++ .../Entities/RichBlockBlockQuotation.php | 23 ++ src/Telegram/Entities/RichBlockCaption.php | 22 ++ src/Telegram/Entities/RichBlockCollage.php | 23 ++ src/Telegram/Entities/RichBlockDetails.php | 24 ++ src/Telegram/Entities/RichBlockDivider.php | 18 ++ src/Telegram/Entities/RichBlockFooter.php | 21 ++ src/Telegram/Entities/RichBlockList.php | 21 ++ src/Telegram/Entities/RichBlockListItem.php | 25 ++ src/Telegram/Entities/RichBlockMap.php | 26 ++ .../RichBlockMathematicalExpression.php | 19 ++ src/Telegram/Entities/RichBlockParagraph.php | 21 ++ src/Telegram/Entities/RichBlockPhoto.php | 24 ++ .../Entities/RichBlockPreformatted.php | 22 ++ .../Entities/RichBlockPullQuotation.php | 23 ++ .../Entities/RichBlockSectionHeading.php | 22 ++ src/Telegram/Entities/RichBlockSlideshow.php | 23 ++ src/Telegram/Entities/RichBlockTable.php | 25 ++ src/Telegram/Entities/RichBlockTableCell.php | 25 ++ src/Telegram/Entities/RichBlockThinking.php | 21 ++ src/Telegram/Entities/RichBlockVideo.php | 24 ++ src/Telegram/Entities/RichBlockVoiceNote.php | 23 ++ src/Telegram/Entities/RichMessage.php | 21 ++ src/Telegram/Entities/RichText.php | 114 +++++++++ src/Telegram/Entities/RichTextAnchor.php | 19 ++ src/Telegram/Entities/RichTextAnchorLink.php | 22 ++ .../Entities/RichTextBankCardNumber.php | 22 ++ src/Telegram/Entities/RichTextBold.php | 21 ++ src/Telegram/Entities/RichTextBotCommand.php | 22 ++ src/Telegram/Entities/RichTextCashtag.php | 22 ++ src/Telegram/Entities/RichTextCode.php | 21 ++ src/Telegram/Entities/RichTextCustomEmoji.php | 20 ++ src/Telegram/Entities/RichTextDateTime.php | 23 ++ .../Entities/RichTextEmailAddress.php | 22 ++ src/Telegram/Entities/RichTextHashtag.php | 22 ++ src/Telegram/Entities/RichTextItalic.php | 21 ++ src/Telegram/Entities/RichTextMarked.php | 21 ++ .../RichTextMathematicalExpression.php | 19 ++ src/Telegram/Entities/RichTextMention.php | 22 ++ src/Telegram/Entities/RichTextPhoneNumber.php | 22 ++ src/Telegram/Entities/RichTextReference.php | 22 ++ .../Entities/RichTextReferenceLink.php | 22 ++ src/Telegram/Entities/RichTextSpoiler.php | 21 ++ .../Entities/RichTextStrikethrough.php | 21 ++ src/Telegram/Entities/RichTextSubscript.php | 21 ++ src/Telegram/Entities/RichTextSuperscript.php | 21 ++ src/Telegram/Entities/RichTextTextMention.php | 23 ++ src/Telegram/Entities/RichTextUnderline.php | 21 ++ src/Telegram/Entities/RichTextUrl.php | 22 ++ src/Telegram/Entities/Update.php | 2 + src/Telegram/Entities/User.php | 1 + src/Telegram/Methods.php | 223 ++++++++++++++++-- 96 files changed, 2343 insertions(+), 23 deletions(-) create mode 100644 src/Telegram/Entities/BotSubscriptionUpdated.php create mode 100644 src/Telegram/Entities/Community.php create mode 100644 src/Telegram/Entities/CommunityChatAdded.php create mode 100644 src/Telegram/Entities/CommunityChatRemoved.php create mode 100644 src/Telegram/Entities/InputMediaLink.php create mode 100644 src/Telegram/Entities/InputMediaVoiceNote.php create mode 100644 src/Telegram/Entities/InputRichBlock.php create mode 100644 src/Telegram/Entities/InputRichBlockAnchor.php create mode 100644 src/Telegram/Entities/InputRichBlockAnimation.php create mode 100644 src/Telegram/Entities/InputRichBlockAudio.php create mode 100644 src/Telegram/Entities/InputRichBlockBlockQuotation.php create mode 100644 src/Telegram/Entities/InputRichBlockCollage.php create mode 100644 src/Telegram/Entities/InputRichBlockDetails.php create mode 100644 src/Telegram/Entities/InputRichBlockDivider.php create mode 100644 src/Telegram/Entities/InputRichBlockFooter.php create mode 100644 src/Telegram/Entities/InputRichBlockList.php create mode 100644 src/Telegram/Entities/InputRichBlockListItem.php create mode 100644 src/Telegram/Entities/InputRichBlockMap.php create mode 100644 src/Telegram/Entities/InputRichBlockMathematicalExpression.php create mode 100644 src/Telegram/Entities/InputRichBlockParagraph.php create mode 100644 src/Telegram/Entities/InputRichBlockPhoto.php create mode 100644 src/Telegram/Entities/InputRichBlockPreformatted.php create mode 100644 src/Telegram/Entities/InputRichBlockPullQuotation.php create mode 100644 src/Telegram/Entities/InputRichBlockSectionHeading.php create mode 100644 src/Telegram/Entities/InputRichBlockSlideshow.php create mode 100644 src/Telegram/Entities/InputRichBlockTable.php create mode 100644 src/Telegram/Entities/InputRichBlockThinking.php create mode 100644 src/Telegram/Entities/InputRichBlockVideo.php create mode 100644 src/Telegram/Entities/InputRichBlockVoiceNote.php create mode 100644 src/Telegram/Entities/InputRichMessage.php create mode 100644 src/Telegram/Entities/InputRichMessageContent.php create mode 100644 src/Telegram/Entities/InputRichMessageMedia.php create mode 100644 src/Telegram/Entities/Link.php create mode 100644 src/Telegram/Entities/RichBlock.php create mode 100644 src/Telegram/Entities/RichBlockAnchor.php create mode 100644 src/Telegram/Entities/RichBlockAnimation.php create mode 100644 src/Telegram/Entities/RichBlockAudio.php create mode 100644 src/Telegram/Entities/RichBlockBlockQuotation.php create mode 100644 src/Telegram/Entities/RichBlockCaption.php create mode 100644 src/Telegram/Entities/RichBlockCollage.php create mode 100644 src/Telegram/Entities/RichBlockDetails.php create mode 100644 src/Telegram/Entities/RichBlockDivider.php create mode 100644 src/Telegram/Entities/RichBlockFooter.php create mode 100644 src/Telegram/Entities/RichBlockList.php create mode 100644 src/Telegram/Entities/RichBlockListItem.php create mode 100644 src/Telegram/Entities/RichBlockMap.php create mode 100644 src/Telegram/Entities/RichBlockMathematicalExpression.php create mode 100644 src/Telegram/Entities/RichBlockParagraph.php create mode 100644 src/Telegram/Entities/RichBlockPhoto.php create mode 100644 src/Telegram/Entities/RichBlockPreformatted.php create mode 100644 src/Telegram/Entities/RichBlockPullQuotation.php create mode 100644 src/Telegram/Entities/RichBlockSectionHeading.php create mode 100644 src/Telegram/Entities/RichBlockSlideshow.php create mode 100644 src/Telegram/Entities/RichBlockTable.php create mode 100644 src/Telegram/Entities/RichBlockTableCell.php create mode 100644 src/Telegram/Entities/RichBlockThinking.php create mode 100644 src/Telegram/Entities/RichBlockVideo.php create mode 100644 src/Telegram/Entities/RichBlockVoiceNote.php create mode 100644 src/Telegram/Entities/RichMessage.php create mode 100644 src/Telegram/Entities/RichText.php create mode 100644 src/Telegram/Entities/RichTextAnchor.php create mode 100644 src/Telegram/Entities/RichTextAnchorLink.php create mode 100644 src/Telegram/Entities/RichTextBankCardNumber.php create mode 100644 src/Telegram/Entities/RichTextBold.php create mode 100644 src/Telegram/Entities/RichTextBotCommand.php create mode 100644 src/Telegram/Entities/RichTextCashtag.php create mode 100644 src/Telegram/Entities/RichTextCode.php create mode 100644 src/Telegram/Entities/RichTextCustomEmoji.php create mode 100644 src/Telegram/Entities/RichTextDateTime.php create mode 100644 src/Telegram/Entities/RichTextEmailAddress.php create mode 100644 src/Telegram/Entities/RichTextHashtag.php create mode 100644 src/Telegram/Entities/RichTextItalic.php create mode 100644 src/Telegram/Entities/RichTextMarked.php create mode 100644 src/Telegram/Entities/RichTextMathematicalExpression.php create mode 100644 src/Telegram/Entities/RichTextMention.php create mode 100644 src/Telegram/Entities/RichTextPhoneNumber.php create mode 100644 src/Telegram/Entities/RichTextReference.php create mode 100644 src/Telegram/Entities/RichTextReferenceLink.php create mode 100644 src/Telegram/Entities/RichTextSpoiler.php create mode 100644 src/Telegram/Entities/RichTextStrikethrough.php create mode 100644 src/Telegram/Entities/RichTextSubscript.php create mode 100644 src/Telegram/Entities/RichTextSuperscript.php create mode 100644 src/Telegram/Entities/RichTextTextMention.php create mode 100644 src/Telegram/Entities/RichTextUnderline.php create mode 100644 src/Telegram/Entities/RichTextUrl.php diff --git a/src/Telegram/Entities/BotCommand.php b/src/Telegram/Entities/BotCommand.php index 5dc7e85..94ef104 100644 --- a/src/Telegram/Entities/BotCommand.php +++ b/src/Telegram/Entities/BotCommand.php @@ -8,6 +8,7 @@ * BotCommand Entity * @property string $command * @property string $description + * @property bool $is_ephemeral */ class BotCommand extends Entity { diff --git a/src/Telegram/Entities/BotSubscriptionUpdated.php b/src/Telegram/Entities/BotSubscriptionUpdated.php new file mode 100644 index 0000000..8a1c4f1 --- /dev/null +++ b/src/Telegram/Entities/BotSubscriptionUpdated.php @@ -0,0 +1,22 @@ + User::class, + ]; + } +} diff --git a/src/Telegram/Entities/ChatFullInfo.php b/src/Telegram/Entities/ChatFullInfo.php index d38e23d..75fa355 100644 --- a/src/Telegram/Entities/ChatFullInfo.php +++ b/src/Telegram/Entities/ChatFullInfo.php @@ -57,6 +57,8 @@ * @property Audio $first_profile_audio * @property UniqueGiftColors $unique_gift_colors * @property int $paid_message_star_count + * @property User $guard_bot + * @property Community $community */ class ChatFullInfo extends Entity { @@ -79,6 +81,8 @@ protected function setEntities(): array 'rating' => UserRating::class, 'first_profile_audio' => Audio::class, 'unique_gift_colors' => UniqueGiftColors::class, + 'guard_bot' => User::class, + 'community' => Community::class, ]; } } diff --git a/src/Telegram/Entities/ChatJoinRequest.php b/src/Telegram/Entities/ChatJoinRequest.php index c29822b..f02a92f 100644 --- a/src/Telegram/Entities/ChatJoinRequest.php +++ b/src/Telegram/Entities/ChatJoinRequest.php @@ -12,6 +12,7 @@ * @property int $date * @property string $bio * @property ChatInviteLink $invite_link + * @property string $query_id */ class ChatJoinRequest extends Entity { diff --git a/src/Telegram/Entities/Community.php b/src/Telegram/Entities/Community.php new file mode 100644 index 0000000..3a71ecd --- /dev/null +++ b/src/Telegram/Entities/Community.php @@ -0,0 +1,19 @@ + Community::class, + ]; + } +} diff --git a/src/Telegram/Entities/CommunityChatRemoved.php b/src/Telegram/Entities/CommunityChatRemoved.php new file mode 100644 index 0000000..0deefd3 --- /dev/null +++ b/src/Telegram/Entities/CommunityChatRemoved.php @@ -0,0 +1,17 @@ + [MessageEntity::class], + ]; + } +} diff --git a/src/Telegram/Entities/InputMessageContent.php b/src/Telegram/Entities/InputMessageContent.php index 6f96aa4..93bbe9e 100644 --- a/src/Telegram/Entities/InputMessageContent.php +++ b/src/Telegram/Entities/InputMessageContent.php @@ -39,6 +39,9 @@ public function resolve(): Entity ) { return new InputLocationMessageContent($this->properties); } + if ($this->hasProperty('html') || $this->hasProperty('markdown')) { + return new InputRichMessageContent($this->properties); + } throw new \InvalidArgumentException('Unknown InputMessageContent'); } @@ -54,6 +57,7 @@ public function resolve(): Entity * | payload | InputInvoiceMessageContent | * | latitude + longitude + title | InputVenueMessageContent | * | latitude + longitude | InputLocationMessageContent | + * | html / markdown | InputRichMessageContent | * @throws \InvalidArgumentException */ public static function create(array $data): Entity @@ -64,6 +68,7 @@ public static function create(array $data): Entity isset($data['payload']) => new InputInvoiceMessageContent($data), isset($data['latitude'], $data['longitude'], $data['title']) => new InputVenueMessageContent($data), isset($data['latitude'], $data['longitude']) => new InputLocationMessageContent($data), + isset($data['html']) || isset($data['markdown']) => new InputRichMessageContent($data), default => throw new \InvalidArgumentException('Unknown InputMessageContent: no valid property found'), }; } diff --git a/src/Telegram/Entities/InputPollOptionMedia.php b/src/Telegram/Entities/InputPollOptionMedia.php index 670cf97..57564f0 100644 --- a/src/Telegram/Entities/InputPollOptionMedia.php +++ b/src/Telegram/Entities/InputPollOptionMedia.php @@ -11,6 +11,7 @@ class InputPollOptionMedia extends Entity { public const TYPE_ANIMATION = 'animation'; + public const TYPE_LINK = 'link'; public const TYPE_LIVE_PHOTO = 'live_photo'; public const TYPE_LOCATION = 'location'; public const TYPE_PHOTO = 'photo'; @@ -26,6 +27,7 @@ public function resolve(): Entity { return match($this->type) { 'animation' => new InputMediaAnimation($this->properties), + 'link' => new InputMediaLink($this->properties), 'live_photo' => new InputMediaLivePhoto($this->properties), 'location' => new InputMediaLocation($this->properties), 'photo' => new InputMediaPhoto($this->properties), @@ -45,6 +47,7 @@ public function resolve(): Entity * | type= | Creates | * |-------|----------| * | animation | InputMediaAnimation | + * | link | InputMediaLink | * | live_photo | InputMediaLivePhoto | * | location | InputMediaLocation | * | photo | InputMediaPhoto | @@ -57,6 +60,7 @@ public static function create(array $data): Entity { return match($data['type'] ?? null) { self::TYPE_ANIMATION => new InputMediaAnimation($data), + self::TYPE_LINK => new InputMediaLink($data), self::TYPE_LIVE_PHOTO => new InputMediaLivePhoto($data), self::TYPE_LOCATION => new InputMediaLocation($data), self::TYPE_PHOTO => new InputMediaPhoto($data), diff --git a/src/Telegram/Entities/InputRichBlock.php b/src/Telegram/Entities/InputRichBlock.php new file mode 100644 index 0000000..7331b21 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlock.php @@ -0,0 +1,102 @@ +type) { + 'paragraph' => new InputRichBlockParagraph($this->properties), + 'section_heading' => new InputRichBlockSectionHeading($this->properties), + 'preformatted' => new InputRichBlockPreformatted($this->properties), + 'footer' => new InputRichBlockFooter($this->properties), + 'divider' => new InputRichBlockDivider($this->properties), + 'mathematical_expression' => new InputRichBlockMathematicalExpression($this->properties), + 'anchor' => new InputRichBlockAnchor($this->properties), + 'list' => new InputRichBlockList($this->properties), + 'block_quotation' => new InputRichBlockBlockQuotation($this->properties), + 'pull_quotation' => new InputRichBlockPullQuotation($this->properties), + 'collage' => new InputRichBlockCollage($this->properties), + 'slideshow' => new InputRichBlockSlideshow($this->properties), + 'table' => new InputRichBlockTable($this->properties), + 'details' => new InputRichBlockDetails($this->properties), + 'map' => new InputRichBlockMap($this->properties), + 'animation' => new InputRichBlockAnimation($this->properties), + 'audio' => new InputRichBlockAudio($this->properties), + 'photo' => new InputRichBlockPhoto($this->properties), + 'video' => new InputRichBlockVideo($this->properties), + 'voice_note' => new InputRichBlockVoiceNote($this->properties), + 'thinking' => new InputRichBlockThinking($this->properties), + default => throw new \InvalidArgumentException('Unknown InputRichBlock type: ' . $this->type), + }; + } + + /** + * Factory: creates the correct subclass based on type + * + * @param array $data Must contain 'type' key + * @return Entity + * @throws \InvalidArgumentException + */ + public static function create(array $data): Entity + { + return match($data['type'] ?? null) { + self::TYPE_PARAGRAPH => new InputRichBlockParagraph($data), + self::TYPE_SECTION_HEADING => new InputRichBlockSectionHeading($data), + self::TYPE_PREFORMATTED => new InputRichBlockPreformatted($data), + self::TYPE_FOOTER => new InputRichBlockFooter($data), + self::TYPE_DIVIDER => new InputRichBlockDivider($data), + self::TYPE_MATHEMATICAL_EXPRESSION => new InputRichBlockMathematicalExpression($data), + self::TYPE_ANCHOR => new InputRichBlockAnchor($data), + self::TYPE_LIST => new InputRichBlockList($data), + self::TYPE_BLOCK_QUOTATION => new InputRichBlockBlockQuotation($data), + self::TYPE_PULL_QUOTATION => new InputRichBlockPullQuotation($data), + self::TYPE_COLLAGE => new InputRichBlockCollage($data), + self::TYPE_SLIDESHOW => new InputRichBlockSlideshow($data), + self::TYPE_TABLE => new InputRichBlockTable($data), + self::TYPE_DETAILS => new InputRichBlockDetails($data), + self::TYPE_MAP => new InputRichBlockMap($data), + self::TYPE_ANIMATION => new InputRichBlockAnimation($data), + self::TYPE_AUDIO => new InputRichBlockAudio($data), + self::TYPE_PHOTO => new InputRichBlockPhoto($data), + self::TYPE_VIDEO => new InputRichBlockVideo($data), + self::TYPE_VOICE_NOTE => new InputRichBlockVoiceNote($data), + self::TYPE_THINKING => new InputRichBlockThinking($data), + default => throw new \InvalidArgumentException('Unknown InputRichBlock type: ' . ($data['type'] ?? 'null')), + }; + } + +} diff --git a/src/Telegram/Entities/InputRichBlockAnchor.php b/src/Telegram/Entities/InputRichBlockAnchor.php new file mode 100644 index 0000000..2e6f84b --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockAnchor.php @@ -0,0 +1,19 @@ + InputMediaAnimation::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockAudio.php b/src/Telegram/Entities/InputRichBlockAudio.php new file mode 100644 index 0000000..54a83e1 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockAudio.php @@ -0,0 +1,23 @@ + InputMediaAudio::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockBlockQuotation.php b/src/Telegram/Entities/InputRichBlockBlockQuotation.php new file mode 100644 index 0000000..8b9f1df --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockBlockQuotation.php @@ -0,0 +1,23 @@ + [InputRichBlock::class], + 'credit' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockCollage.php b/src/Telegram/Entities/InputRichBlockCollage.php new file mode 100644 index 0000000..d4b6263 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockCollage.php @@ -0,0 +1,23 @@ + [InputRichBlock::class], + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockDetails.php b/src/Telegram/Entities/InputRichBlockDetails.php new file mode 100644 index 0000000..ce64d59 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockDetails.php @@ -0,0 +1,24 @@ + RichText::class, + 'blocks' => [InputRichBlock::class], + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockDivider.php b/src/Telegram/Entities/InputRichBlockDivider.php new file mode 100644 index 0000000..0d84b19 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockDivider.php @@ -0,0 +1,18 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockList.php b/src/Telegram/Entities/InputRichBlockList.php new file mode 100644 index 0000000..5f46222 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockList.php @@ -0,0 +1,21 @@ + [InputRichBlockListItem::class], + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockListItem.php b/src/Telegram/Entities/InputRichBlockListItem.php new file mode 100644 index 0000000..4a6b092 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockListItem.php @@ -0,0 +1,24 @@ + [InputRichBlock::class], + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockMap.php b/src/Telegram/Entities/InputRichBlockMap.php new file mode 100644 index 0000000..00e8098 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockMap.php @@ -0,0 +1,26 @@ + Location::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockMathematicalExpression.php b/src/Telegram/Entities/InputRichBlockMathematicalExpression.php new file mode 100644 index 0000000..38540ca --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockMathematicalExpression.php @@ -0,0 +1,19 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockPhoto.php b/src/Telegram/Entities/InputRichBlockPhoto.php new file mode 100644 index 0000000..ce1d6bd --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockPhoto.php @@ -0,0 +1,23 @@ + InputMediaPhoto::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockPreformatted.php b/src/Telegram/Entities/InputRichBlockPreformatted.php new file mode 100644 index 0000000..ceeecd3 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockPreformatted.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockPullQuotation.php b/src/Telegram/Entities/InputRichBlockPullQuotation.php new file mode 100644 index 0000000..1457a08 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockPullQuotation.php @@ -0,0 +1,23 @@ + RichText::class, + 'credit' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockSectionHeading.php b/src/Telegram/Entities/InputRichBlockSectionHeading.php new file mode 100644 index 0000000..c8e49b7 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockSectionHeading.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockSlideshow.php b/src/Telegram/Entities/InputRichBlockSlideshow.php new file mode 100644 index 0000000..65d9ea8 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockSlideshow.php @@ -0,0 +1,23 @@ + [InputRichBlock::class], + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockTable.php b/src/Telegram/Entities/InputRichBlockTable.php new file mode 100644 index 0000000..45c65c0 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockTable.php @@ -0,0 +1,25 @@ + [RichBlockTableCell::class], + 'caption' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockThinking.php b/src/Telegram/Entities/InputRichBlockThinking.php new file mode 100644 index 0000000..08e601f --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockThinking.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockVideo.php b/src/Telegram/Entities/InputRichBlockVideo.php new file mode 100644 index 0000000..58ff727 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockVideo.php @@ -0,0 +1,23 @@ + InputMediaVideo::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichBlockVoiceNote.php b/src/Telegram/Entities/InputRichBlockVoiceNote.php new file mode 100644 index 0000000..cb1c4e7 --- /dev/null +++ b/src/Telegram/Entities/InputRichBlockVoiceNote.php @@ -0,0 +1,23 @@ + InputMediaVoiceNote::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichMessage.php b/src/Telegram/Entities/InputRichMessage.php new file mode 100644 index 0000000..930fe08 --- /dev/null +++ b/src/Telegram/Entities/InputRichMessage.php @@ -0,0 +1,26 @@ + [InputRichBlock::class], + 'media' => [InputRichMessageMedia::class], + ]; + } +} diff --git a/src/Telegram/Entities/InputRichMessageContent.php b/src/Telegram/Entities/InputRichMessageContent.php new file mode 100644 index 0000000..76b7b36 --- /dev/null +++ b/src/Telegram/Entities/InputRichMessageContent.php @@ -0,0 +1,20 @@ + InputRichMessage::class, + ]; + } +} diff --git a/src/Telegram/Entities/InputRichMessageMedia.php b/src/Telegram/Entities/InputRichMessageMedia.php new file mode 100644 index 0000000..fc2ebed --- /dev/null +++ b/src/Telegram/Entities/InputRichMessageMedia.php @@ -0,0 +1,21 @@ + InputMediaAnimation|InputMediaAudio|InputMediaPhoto|InputMediaVideo|InputMediaVoiceNote::class, + ]; + } +} diff --git a/src/Telegram/Entities/Link.php b/src/Telegram/Entities/Link.php new file mode 100644 index 0000000..2e70c6e --- /dev/null +++ b/src/Telegram/Entities/Link.php @@ -0,0 +1,18 @@ + User::class, 'sender_chat' => Chat::class, 'sender_business_bot' => User::class, + 'receiver_user' => User::class, 'chat' => Chat::class, 'forward_origin' => MessageOrigin::class, 'reply_to_message' => Message::class, @@ -143,6 +149,7 @@ protected function setEntities(): array 'entities' => [MessageEntity::class], 'link_preview_options' => LinkPreviewOptions::class, 'suggested_post_info' => SuggestedPostInfo::class, + 'rich_message' => RichMessage::class, 'animation' => Animation::class, 'audio' => Audio::class, 'document' => Document::class, @@ -184,6 +191,8 @@ protected function setEntities(): array 'chat_background_set' => ChatBackground::class, 'checklist_tasks_done' => ChecklistTasksDone::class, 'checklist_tasks_added' => ChecklistTasksAdded::class, + 'community_chat_added' => CommunityChatAdded::class, + 'community_chat_removed' => CommunityChatRemoved::class, 'direct_message_price_changed' => DirectMessagePriceChanged::class, 'forum_topic_created' => ForumTopicCreated::class, 'forum_topic_edited' => ForumTopicEdited::class, diff --git a/src/Telegram/Entities/PollMedia.php b/src/Telegram/Entities/PollMedia.php index 2cd5670..9f74051 100644 --- a/src/Telegram/Entities/PollMedia.php +++ b/src/Telegram/Entities/PollMedia.php @@ -9,6 +9,7 @@ * @property Animation $animation * @property Audio $audio * @property Document $document + * @property Link $link * @property LivePhoto $live_photo * @property Location $location * @property PhotoSize[] $photo @@ -25,6 +26,7 @@ protected function setEntities(): array 'animation' => Animation::class, 'audio' => Audio::class, 'document' => Document::class, + 'link' => Link::class, 'live_photo' => LivePhoto::class, 'location' => Location::class, 'photo' => [PhotoSize::class], diff --git a/src/Telegram/Entities/ReplyParameters.php b/src/Telegram/Entities/ReplyParameters.php index 191182c..ddf2cdc 100644 --- a/src/Telegram/Entities/ReplyParameters.php +++ b/src/Telegram/Entities/ReplyParameters.php @@ -8,6 +8,7 @@ * ReplyParameters Entity * @property int $message_id * @property int|string $chat_id + * @property int $ephemeral_message_id * @property bool $allow_sending_without_reply * @property string $quote * @property string $quote_parse_mode @@ -22,7 +23,6 @@ class ReplyParameters extends Entity protected function setEntities(): array { return [ - 'chat_id' => int|string::class, 'quote_entities' => [MessageEntity::class], ]; } diff --git a/src/Telegram/Entities/RichBlock.php b/src/Telegram/Entities/RichBlock.php new file mode 100644 index 0000000..de165e6 --- /dev/null +++ b/src/Telegram/Entities/RichBlock.php @@ -0,0 +1,102 @@ +type) { + 'paragraph' => new RichBlockParagraph($this->properties), + 'section_heading' => new RichBlockSectionHeading($this->properties), + 'preformatted' => new RichBlockPreformatted($this->properties), + 'footer' => new RichBlockFooter($this->properties), + 'divider' => new RichBlockDivider($this->properties), + 'mathematical_expression' => new RichBlockMathematicalExpression($this->properties), + 'anchor' => new RichBlockAnchor($this->properties), + 'list' => new RichBlockList($this->properties), + 'block_quotation' => new RichBlockBlockQuotation($this->properties), + 'pull_quotation' => new RichBlockPullQuotation($this->properties), + 'collage' => new RichBlockCollage($this->properties), + 'slideshow' => new RichBlockSlideshow($this->properties), + 'table' => new RichBlockTable($this->properties), + 'details' => new RichBlockDetails($this->properties), + 'map' => new RichBlockMap($this->properties), + 'animation' => new RichBlockAnimation($this->properties), + 'audio' => new RichBlockAudio($this->properties), + 'photo' => new RichBlockPhoto($this->properties), + 'video' => new RichBlockVideo($this->properties), + 'voice_note' => new RichBlockVoiceNote($this->properties), + 'thinking' => new RichBlockThinking($this->properties), + default => throw new \InvalidArgumentException('Unknown RichBlock type: ' . $this->type), + }; + } + + /** + * Factory: creates the correct subclass based on type + * + * @param array $data Must contain 'type' key + * @return Entity + * @throws \InvalidArgumentException + */ + public static function create(array $data): Entity + { + return match($data['type'] ?? null) { + self::TYPE_PARAGRAPH => new RichBlockParagraph($data), + self::TYPE_SECTION_HEADING => new RichBlockSectionHeading($data), + self::TYPE_PREFORMATTED => new RichBlockPreformatted($data), + self::TYPE_FOOTER => new RichBlockFooter($data), + self::TYPE_DIVIDER => new RichBlockDivider($data), + self::TYPE_MATHEMATICAL_EXPRESSION => new RichBlockMathematicalExpression($data), + self::TYPE_ANCHOR => new RichBlockAnchor($data), + self::TYPE_LIST => new RichBlockList($data), + self::TYPE_BLOCK_QUOTATION => new RichBlockBlockQuotation($data), + self::TYPE_PULL_QUOTATION => new RichBlockPullQuotation($data), + self::TYPE_COLLAGE => new RichBlockCollage($data), + self::TYPE_SLIDESHOW => new RichBlockSlideshow($data), + self::TYPE_TABLE => new RichBlockTable($data), + self::TYPE_DETAILS => new RichBlockDetails($data), + self::TYPE_MAP => new RichBlockMap($data), + self::TYPE_ANIMATION => new RichBlockAnimation($data), + self::TYPE_AUDIO => new RichBlockAudio($data), + self::TYPE_PHOTO => new RichBlockPhoto($data), + self::TYPE_VIDEO => new RichBlockVideo($data), + self::TYPE_VOICE_NOTE => new RichBlockVoiceNote($data), + self::TYPE_THINKING => new RichBlockThinking($data), + default => throw new \InvalidArgumentException('Unknown RichBlock type: ' . ($data['type'] ?? 'null')), + }; + } + +} diff --git a/src/Telegram/Entities/RichBlockAnchor.php b/src/Telegram/Entities/RichBlockAnchor.php new file mode 100644 index 0000000..8e26be0 --- /dev/null +++ b/src/Telegram/Entities/RichBlockAnchor.php @@ -0,0 +1,19 @@ + Animation::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockAudio.php b/src/Telegram/Entities/RichBlockAudio.php new file mode 100644 index 0000000..3d563ac --- /dev/null +++ b/src/Telegram/Entities/RichBlockAudio.php @@ -0,0 +1,23 @@ + Audio::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockBlockQuotation.php b/src/Telegram/Entities/RichBlockBlockQuotation.php new file mode 100644 index 0000000..6a6ba39 --- /dev/null +++ b/src/Telegram/Entities/RichBlockBlockQuotation.php @@ -0,0 +1,23 @@ + [RichBlock::class], + 'credit' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockCaption.php b/src/Telegram/Entities/RichBlockCaption.php new file mode 100644 index 0000000..017a7f3 --- /dev/null +++ b/src/Telegram/Entities/RichBlockCaption.php @@ -0,0 +1,22 @@ + RichText::class, + 'credit' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockCollage.php b/src/Telegram/Entities/RichBlockCollage.php new file mode 100644 index 0000000..8004f4e --- /dev/null +++ b/src/Telegram/Entities/RichBlockCollage.php @@ -0,0 +1,23 @@ + [RichBlock::class], + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockDetails.php b/src/Telegram/Entities/RichBlockDetails.php new file mode 100644 index 0000000..6ea93bd --- /dev/null +++ b/src/Telegram/Entities/RichBlockDetails.php @@ -0,0 +1,24 @@ + RichText::class, + 'blocks' => [RichBlock::class], + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockDivider.php b/src/Telegram/Entities/RichBlockDivider.php new file mode 100644 index 0000000..3351f70 --- /dev/null +++ b/src/Telegram/Entities/RichBlockDivider.php @@ -0,0 +1,18 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockList.php b/src/Telegram/Entities/RichBlockList.php new file mode 100644 index 0000000..d9b6ccf --- /dev/null +++ b/src/Telegram/Entities/RichBlockList.php @@ -0,0 +1,21 @@ + [RichBlockListItem::class], + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockListItem.php b/src/Telegram/Entities/RichBlockListItem.php new file mode 100644 index 0000000..103895e --- /dev/null +++ b/src/Telegram/Entities/RichBlockListItem.php @@ -0,0 +1,25 @@ + [RichBlock::class], + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockMap.php b/src/Telegram/Entities/RichBlockMap.php new file mode 100644 index 0000000..85ca4a6 --- /dev/null +++ b/src/Telegram/Entities/RichBlockMap.php @@ -0,0 +1,26 @@ + Location::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockMathematicalExpression.php b/src/Telegram/Entities/RichBlockMathematicalExpression.php new file mode 100644 index 0000000..1541f43 --- /dev/null +++ b/src/Telegram/Entities/RichBlockMathematicalExpression.php @@ -0,0 +1,19 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockPhoto.php b/src/Telegram/Entities/RichBlockPhoto.php new file mode 100644 index 0000000..b932ee6 --- /dev/null +++ b/src/Telegram/Entities/RichBlockPhoto.php @@ -0,0 +1,24 @@ + [PhotoSize::class], + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockPreformatted.php b/src/Telegram/Entities/RichBlockPreformatted.php new file mode 100644 index 0000000..8ce3e4d --- /dev/null +++ b/src/Telegram/Entities/RichBlockPreformatted.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockPullQuotation.php b/src/Telegram/Entities/RichBlockPullQuotation.php new file mode 100644 index 0000000..bf81b07 --- /dev/null +++ b/src/Telegram/Entities/RichBlockPullQuotation.php @@ -0,0 +1,23 @@ + RichText::class, + 'credit' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockSectionHeading.php b/src/Telegram/Entities/RichBlockSectionHeading.php new file mode 100644 index 0000000..52e5172 --- /dev/null +++ b/src/Telegram/Entities/RichBlockSectionHeading.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockSlideshow.php b/src/Telegram/Entities/RichBlockSlideshow.php new file mode 100644 index 0000000..3af237e --- /dev/null +++ b/src/Telegram/Entities/RichBlockSlideshow.php @@ -0,0 +1,23 @@ + [RichBlock::class], + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockTable.php b/src/Telegram/Entities/RichBlockTable.php new file mode 100644 index 0000000..64a49f5 --- /dev/null +++ b/src/Telegram/Entities/RichBlockTable.php @@ -0,0 +1,25 @@ + [RichBlockTableCell::class], + 'caption' => RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockTableCell.php b/src/Telegram/Entities/RichBlockTableCell.php new file mode 100644 index 0000000..f649272 --- /dev/null +++ b/src/Telegram/Entities/RichBlockTableCell.php @@ -0,0 +1,25 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockThinking.php b/src/Telegram/Entities/RichBlockThinking.php new file mode 100644 index 0000000..0a2bcdf --- /dev/null +++ b/src/Telegram/Entities/RichBlockThinking.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockVideo.php b/src/Telegram/Entities/RichBlockVideo.php new file mode 100644 index 0000000..72f88ba --- /dev/null +++ b/src/Telegram/Entities/RichBlockVideo.php @@ -0,0 +1,24 @@ + Video::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichBlockVoiceNote.php b/src/Telegram/Entities/RichBlockVoiceNote.php new file mode 100644 index 0000000..b04a051 --- /dev/null +++ b/src/Telegram/Entities/RichBlockVoiceNote.php @@ -0,0 +1,23 @@ + Voice::class, + 'caption' => RichBlockCaption::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichMessage.php b/src/Telegram/Entities/RichMessage.php new file mode 100644 index 0000000..cbe3f0d --- /dev/null +++ b/src/Telegram/Entities/RichMessage.php @@ -0,0 +1,21 @@ + [RichBlock::class], + ]; + } +} diff --git a/src/Telegram/Entities/RichText.php b/src/Telegram/Entities/RichText.php new file mode 100644 index 0000000..7d1fbb9 --- /dev/null +++ b/src/Telegram/Entities/RichText.php @@ -0,0 +1,114 @@ +type) { + 'bold' => new RichTextBold($this->properties), + 'italic' => new RichTextItalic($this->properties), + 'underline' => new RichTextUnderline($this->properties), + 'strikethrough' => new RichTextStrikethrough($this->properties), + 'spoiler' => new RichTextSpoiler($this->properties), + 'datetime' => new RichTextDateTime($this->properties), + 'text_mention' => new RichTextTextMention($this->properties), + 'subscript' => new RichTextSubscript($this->properties), + 'superscript' => new RichTextSuperscript($this->properties), + 'marked' => new RichTextMarked($this->properties), + 'code' => new RichTextCode($this->properties), + 'custom_emoji' => new RichTextCustomEmoji($this->properties), + 'mathematical_expression' => new RichTextMathematicalExpression($this->properties), + 'url' => new RichTextUrl($this->properties), + 'email_address' => new RichTextEmailAddress($this->properties), + 'phone_number' => new RichTextPhoneNumber($this->properties), + 'bank_card_number' => new RichTextBankCardNumber($this->properties), + 'mention' => new RichTextMention($this->properties), + 'hashtag' => new RichTextHashtag($this->properties), + 'cashtag' => new RichTextCashtag($this->properties), + 'bot_command' => new RichTextBotCommand($this->properties), + 'anchor' => new RichTextAnchor($this->properties), + 'anchor_link' => new RichTextAnchorLink($this->properties), + 'reference' => new RichTextReference($this->properties), + 'reference_link' => new RichTextReferenceLink($this->properties), + default => throw new \InvalidArgumentException('Unknown RichText type: ' . $this->type), + }; + } + + /** + * Factory: creates the correct subclass based on type + * + * @param array $data Must contain 'type' key + * @return Entity + * @throws \InvalidArgumentException + */ + public static function create(array $data): Entity + { + return match($data['type'] ?? null) { + self::TYPE_BOLD => new RichTextBold($data), + self::TYPE_ITALIC => new RichTextItalic($data), + self::TYPE_UNDERLINE => new RichTextUnderline($data), + self::TYPE_STRIKETHROUGH => new RichTextStrikethrough($data), + self::TYPE_SPOILER => new RichTextSpoiler($data), + self::TYPE_DATETIME => new RichTextDateTime($data), + self::TYPE_TEXT_MENTION => new RichTextTextMention($data), + self::TYPE_SUBSCRIPT => new RichTextSubscript($data), + self::TYPE_SUPERSCRIPT => new RichTextSuperscript($data), + self::TYPE_MARKED => new RichTextMarked($data), + self::TYPE_CODE => new RichTextCode($data), + self::TYPE_CUSTOM_EMOJI => new RichTextCustomEmoji($data), + self::TYPE_MATHEMATICAL_EXPRESSION => new RichTextMathematicalExpression($data), + self::TYPE_URL => new RichTextUrl($data), + self::TYPE_EMAIL_ADDRESS => new RichTextEmailAddress($data), + self::TYPE_PHONE_NUMBER => new RichTextPhoneNumber($data), + self::TYPE_BANK_CARD_NUMBER => new RichTextBankCardNumber($data), + self::TYPE_MENTION => new RichTextMention($data), + self::TYPE_HASHTAG => new RichTextHashtag($data), + self::TYPE_CASHTAG => new RichTextCashtag($data), + self::TYPE_BOT_COMMAND => new RichTextBotCommand($data), + self::TYPE_ANCHOR => new RichTextAnchor($data), + self::TYPE_ANCHOR_LINK => new RichTextAnchorLink($data), + self::TYPE_REFERENCE => new RichTextReference($data), + self::TYPE_REFERENCE_LINK => new RichTextReferenceLink($data), + default => throw new \InvalidArgumentException('Unknown RichText type: ' . ($data['type'] ?? 'null')), + }; + } + +} diff --git a/src/Telegram/Entities/RichTextAnchor.php b/src/Telegram/Entities/RichTextAnchor.php new file mode 100644 index 0000000..168cc82 --- /dev/null +++ b/src/Telegram/Entities/RichTextAnchor.php @@ -0,0 +1,19 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextBankCardNumber.php b/src/Telegram/Entities/RichTextBankCardNumber.php new file mode 100644 index 0000000..7471035 --- /dev/null +++ b/src/Telegram/Entities/RichTextBankCardNumber.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextBold.php b/src/Telegram/Entities/RichTextBold.php new file mode 100644 index 0000000..c6030a1 --- /dev/null +++ b/src/Telegram/Entities/RichTextBold.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextBotCommand.php b/src/Telegram/Entities/RichTextBotCommand.php new file mode 100644 index 0000000..9847579 --- /dev/null +++ b/src/Telegram/Entities/RichTextBotCommand.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextCashtag.php b/src/Telegram/Entities/RichTextCashtag.php new file mode 100644 index 0000000..3b669e1 --- /dev/null +++ b/src/Telegram/Entities/RichTextCashtag.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextCode.php b/src/Telegram/Entities/RichTextCode.php new file mode 100644 index 0000000..526a117 --- /dev/null +++ b/src/Telegram/Entities/RichTextCode.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextCustomEmoji.php b/src/Telegram/Entities/RichTextCustomEmoji.php new file mode 100644 index 0000000..6890814 --- /dev/null +++ b/src/Telegram/Entities/RichTextCustomEmoji.php @@ -0,0 +1,20 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextEmailAddress.php b/src/Telegram/Entities/RichTextEmailAddress.php new file mode 100644 index 0000000..4236db6 --- /dev/null +++ b/src/Telegram/Entities/RichTextEmailAddress.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextHashtag.php b/src/Telegram/Entities/RichTextHashtag.php new file mode 100644 index 0000000..43b6975 --- /dev/null +++ b/src/Telegram/Entities/RichTextHashtag.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextItalic.php b/src/Telegram/Entities/RichTextItalic.php new file mode 100644 index 0000000..efb8292 --- /dev/null +++ b/src/Telegram/Entities/RichTextItalic.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextMarked.php b/src/Telegram/Entities/RichTextMarked.php new file mode 100644 index 0000000..e8a0882 --- /dev/null +++ b/src/Telegram/Entities/RichTextMarked.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextMathematicalExpression.php b/src/Telegram/Entities/RichTextMathematicalExpression.php new file mode 100644 index 0000000..71467b9 --- /dev/null +++ b/src/Telegram/Entities/RichTextMathematicalExpression.php @@ -0,0 +1,19 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextPhoneNumber.php b/src/Telegram/Entities/RichTextPhoneNumber.php new file mode 100644 index 0000000..7e7af1e --- /dev/null +++ b/src/Telegram/Entities/RichTextPhoneNumber.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextReference.php b/src/Telegram/Entities/RichTextReference.php new file mode 100644 index 0000000..e570977 --- /dev/null +++ b/src/Telegram/Entities/RichTextReference.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextReferenceLink.php b/src/Telegram/Entities/RichTextReferenceLink.php new file mode 100644 index 0000000..5af7279 --- /dev/null +++ b/src/Telegram/Entities/RichTextReferenceLink.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextSpoiler.php b/src/Telegram/Entities/RichTextSpoiler.php new file mode 100644 index 0000000..b528ec3 --- /dev/null +++ b/src/Telegram/Entities/RichTextSpoiler.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextStrikethrough.php b/src/Telegram/Entities/RichTextStrikethrough.php new file mode 100644 index 0000000..f748270 --- /dev/null +++ b/src/Telegram/Entities/RichTextStrikethrough.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextSubscript.php b/src/Telegram/Entities/RichTextSubscript.php new file mode 100644 index 0000000..83053ff --- /dev/null +++ b/src/Telegram/Entities/RichTextSubscript.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextSuperscript.php b/src/Telegram/Entities/RichTextSuperscript.php new file mode 100644 index 0000000..20a54c8 --- /dev/null +++ b/src/Telegram/Entities/RichTextSuperscript.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextTextMention.php b/src/Telegram/Entities/RichTextTextMention.php new file mode 100644 index 0000000..10f0adc --- /dev/null +++ b/src/Telegram/Entities/RichTextTextMention.php @@ -0,0 +1,23 @@ + RichText::class, + 'user' => User::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextUnderline.php b/src/Telegram/Entities/RichTextUnderline.php new file mode 100644 index 0000000..5ff9d8a --- /dev/null +++ b/src/Telegram/Entities/RichTextUnderline.php @@ -0,0 +1,21 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/RichTextUrl.php b/src/Telegram/Entities/RichTextUrl.php new file mode 100644 index 0000000..1e8316b --- /dev/null +++ b/src/Telegram/Entities/RichTextUrl.php @@ -0,0 +1,22 @@ + RichText::class, + ]; + } +} diff --git a/src/Telegram/Entities/Update.php b/src/Telegram/Entities/Update.php index 7b2040a..fb4af9e 100644 --- a/src/Telegram/Entities/Update.php +++ b/src/Telegram/Entities/Update.php @@ -32,6 +32,7 @@ * @property ChatBoostUpdated $chat_boost * @property ChatBoostRemoved $removed_chat_boost * @property ManagedBotUpdated $managed_bot + * @property BotSubscriptionUpdated $subscription */ class Update extends Entity { @@ -64,6 +65,7 @@ protected function setEntities(): array 'chat_boost' => ChatBoostUpdated::class, 'removed_chat_boost' => ChatBoostRemoved::class, 'managed_bot' => ManagedBotUpdated::class, + 'subscription' => BotSubscriptionUpdated::class, ]; } /** diff --git a/src/Telegram/Entities/User.php b/src/Telegram/Entities/User.php index 7d12546..25d41fa 100644 --- a/src/Telegram/Entities/User.php +++ b/src/Telegram/Entities/User.php @@ -23,6 +23,7 @@ * @property bool $has_topics_enabled * @property bool $allows_users_to_create_topics * @property bool $can_manage_bots + * @property bool $supports_join_request_queries */ class User extends Entity { diff --git a/src/Telegram/Methods.php b/src/Telegram/Methods.php index a6bbbe8..5e03d22 100644 --- a/src/Telegram/Methods.php +++ b/src/Telegram/Methods.php @@ -27,6 +27,7 @@ use Al3x5\xBot\Telegram\Entities\MenuButton; use Al3x5\xBot\Telegram\Entities\ChatAdministratorRights; use Al3x5\xBot\Telegram\Entities\AcceptedGiftTypes; +use Al3x5\xBot\Telegram\Entities\BotAccessSettings; use Al3x5\xBot\Telegram\Entities\InputStoryContent; use Al3x5\xBot\Telegram\Entities\StoryArea; use Al3x5\xBot\Telegram\Entities\InputMedia; @@ -53,10 +54,15 @@ use Al3x5\xBot\Telegram\Entities\BotName; use Al3x5\xBot\Telegram\Entities\BotDescription; use Al3x5\xBot\Telegram\Entities\BotShortDescription; +use Al3x5\xBot\Telegram\Entities\InputPollMedia; +use Al3x5\xBot\Telegram\Entities\InputRichMessage; +use Al3x5\xBot\Telegram\Entities\KeyboardButton; use Al3x5\xBot\Telegram\Entities\StarAmount; use Al3x5\xBot\Telegram\Entities\Poll; use Al3x5\xBot\Telegram\Entities\StickerSet; use Al3x5\xBot\Telegram\Entities\PreparedInlineMessage; +use Al3x5\xBot\Telegram\Entities\PreparedKeyboardButton; +use Al3x5\xBot\Telegram\Entities\SentGuestMessage; use Al3x5\xBot\Telegram\Entities\UserProfileAudios; use Al3x5\xBot\Telegram\Entities\SentWebAppMessage; use Al3x5\xBot\Telegram\Entities\StarTransactions; @@ -165,6 +171,8 @@ public function close(): bool * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param string $text * @param string $parse_mode * @param MessageEntity[] $entities @@ -178,7 +186,7 @@ public function close(): bool * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendMessage(int|string $chat_id, string $text, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $parse_mode = null, ?array $entities = null, ?LinkPreviewOptions $link_preview_options = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendMessage(int|string $chat_id, string $text, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $parse_mode = null, ?array $entities = null, ?LinkPreviewOptions $link_preview_options = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -207,7 +215,7 @@ public function forwardMessage(int|string $chat_id, int|string $from_chat_id, in } /** - * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an array of MessageId of the sent messages is returned. + * Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. On success, an Array of MessageId of the sent messages is returned. * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id @@ -225,7 +233,7 @@ public function forwardMessages(int|string $chat_id, int|string $from_chat_id, a } /** - * Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. + * Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_ids is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success. * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id @@ -253,7 +261,7 @@ public function copyMessage(int|string $chat_id, int|string $from_chat_id, int $ } /** - * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an array of MessageId of the sent messages is returned. + * Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_ids is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages. On success, an Array of MessageId of the sent messages is returned. * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id @@ -277,6 +285,8 @@ public function copyMessages(int|string $chat_id, int|string $from_chat_id, arra * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $photo * @param string $caption * @param string $parse_mode @@ -292,7 +302,7 @@ public function copyMessages(int|string $chat_id, int|string $from_chat_id, arra * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendPhoto(int|string $chat_id, InputFile|string $photo, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendPhoto(int|string $chat_id, InputFile|string $photo, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -305,6 +315,8 @@ public function sendPhoto(int|string $chat_id, InputFile|string $photo, ?string * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $live_photo * @param InputFile|string $photo * @param string $caption @@ -321,7 +333,7 @@ public function sendPhoto(int|string $chat_id, InputFile|string $photo, ?string * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendLivePhoto(int|string $chat_id, InputFile|string $live_photo, InputFile|string $photo, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendLivePhoto(int|string $chat_id, InputFile|string $live_photo, InputFile|string $photo, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -335,6 +347,8 @@ public function sendLivePhoto(int|string $chat_id, InputFile|string $live_photo, * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $audio * @param string $caption * @param string $parse_mode @@ -352,7 +366,7 @@ public function sendLivePhoto(int|string $chat_id, InputFile|string $live_photo, * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendAudio(int|string $chat_id, InputFile|string $audio, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?int $duration = null, ?string $performer = null, ?string $title = null, InputFile|string|null $thumbnail = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendAudio(int|string $chat_id, InputFile|string $audio, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?int $duration = null, ?string $performer = null, ?string $title = null, InputFile|string|null $thumbnail = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -365,6 +379,8 @@ public function sendAudio(int|string $chat_id, InputFile|string $audio, ?string * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $document * @param InputFile|string $thumbnail * @param string $caption @@ -380,7 +396,7 @@ public function sendAudio(int|string $chat_id, InputFile|string $audio, ?string * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendDocument(int|string $chat_id, InputFile|string $document, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, InputFile|string|null $thumbnail = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $disable_content_type_detection = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendDocument(int|string $chat_id, InputFile|string $document, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, InputFile|string|null $thumbnail = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $disable_content_type_detection = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -393,6 +409,8 @@ public function sendDocument(int|string $chat_id, InputFile|string $document, ?s * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $video * @param int $duration * @param int $width @@ -415,7 +433,7 @@ public function sendDocument(int|string $chat_id, InputFile|string $document, ?s * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendVideo(int|string $chat_id, InputFile|string $video, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $duration = null, ?int $width = null, ?int $height = null, InputFile|string|null $thumbnail = null, InputFile|string|null $cover = null, ?int $start_timestamp = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $supports_streaming = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendVideo(int|string $chat_id, InputFile|string $video, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?int $duration = null, ?int $width = null, ?int $height = null, InputFile|string|null $thumbnail = null, InputFile|string|null $cover = null, ?int $start_timestamp = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $supports_streaming = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -428,6 +446,8 @@ public function sendVideo(int|string $chat_id, InputFile|string $video, ?string * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $animation * @param int $duration * @param int $width @@ -447,7 +467,7 @@ public function sendVideo(int|string $chat_id, InputFile|string $video, ?string * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendAnimation(int|string $chat_id, InputFile|string $animation, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $duration = null, ?int $width = null, ?int $height = null, InputFile|string|null $thumbnail = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendAnimation(int|string $chat_id, InputFile|string $animation, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?int $duration = null, ?int $width = null, ?int $height = null, InputFile|string|null $thumbnail = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?bool $show_caption_above_media = null, ?bool $has_spoiler = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -460,6 +480,8 @@ public function sendAnimation(int|string $chat_id, InputFile|string $animation, * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $voice * @param string $caption * @param string $parse_mode @@ -474,7 +496,7 @@ public function sendAnimation(int|string $chat_id, InputFile|string $animation, * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendVoice(int|string $chat_id, InputFile|string $voice, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?int $duration = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendVoice(int|string $chat_id, InputFile|string $voice, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?int $duration = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -487,6 +509,8 @@ public function sendVoice(int|string $chat_id, InputFile|string $voice, ?string * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $video_note * @param int $duration * @param int $length @@ -500,7 +524,7 @@ public function sendVoice(int|string $chat_id, InputFile|string $voice, ?string * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendVideoNote(int|string $chat_id, InputFile|string $video_note, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $duration = null, ?int $length = null, InputFile|string|null $thumbnail = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendVideoNote(int|string $chat_id, InputFile|string $video_note, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?int $duration = null, ?int $length = null, InputFile|string|null $thumbnail = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -536,7 +560,7 @@ public function sendPaidMedia(int|string $chat_id, int $star_count, array $media } /** - * Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Message objects that were sent is returned. + * Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an Array of Message objects that were sent is returned. * @param string $business_connection_id * @param int|string $chat_id * @param int $message_thread_id @@ -562,6 +586,8 @@ public function sendMediaGroup(int|string $chat_id, array $media, ?string $busin * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param float $latitude * @param float $longitude * @param float $horizontal_accuracy @@ -577,7 +603,7 @@ public function sendMediaGroup(int|string $chat_id, array $media, ?string $busin * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendLocation(int|string $chat_id, float $latitude, float $longitude, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?float $horizontal_accuracy = null, ?int $live_period = null, ?int $heading = null, ?int $proximity_alert_radius = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendLocation(int|string $chat_id, float $latitude, float $longitude, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?float $horizontal_accuracy = null, ?int $live_period = null, ?int $heading = null, ?int $proximity_alert_radius = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -590,6 +616,8 @@ public function sendLocation(int|string $chat_id, float $latitude, float $longit * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param float $latitude * @param float $longitude * @param string $title @@ -607,7 +635,7 @@ public function sendLocation(int|string $chat_id, float $latitude, float $longit * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendVenue(int|string $chat_id, float $latitude, float $longitude, string $title, string $address, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $foursquare_id = null, ?string $foursquare_type = null, ?string $google_place_id = null, ?string $google_place_type = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendVenue(int|string $chat_id, float $latitude, float $longitude, string $title, string $address, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $foursquare_id = null, ?string $foursquare_type = null, ?string $google_place_id = null, ?string $google_place_type = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -620,6 +648,8 @@ public function sendVenue(int|string $chat_id, float $latitude, float $longitude * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param string $phone_number * @param string $first_name * @param string $last_name @@ -633,7 +663,7 @@ public function sendVenue(int|string $chat_id, float $latitude, float $longitude * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendContact(int|string $chat_id, string $phone_number, string $first_name, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $last_name = null, ?string $vcard = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendContact(int|string $chat_id, string $phone_number, string $first_name, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $last_name = null, ?string $vcard = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -1086,6 +1116,32 @@ public function declineChatJoinRequest(int|string $chat_id, int $user_id): bool return $this->sender(__FUNCTION__, $args); } + /** + * Use this method to process a received chat join request query. Returns True on success. + * @param string $chat_join_request_query_id + * @param string $result + * @return bool + */ + public function answerChatJoinRequestQuery(string $chat_join_request_query_id, string $result): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + + /** + * Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome. Call answerChatJoinRequestQuery to resolve the join request query based on the user interaction with the Mini App. Returns True on success. + * @param string $chat_join_request_query_id + * @param string $web_app_url + * @return bool + */ + public function sendChatJoinRequestWebApp(string $chat_join_request_query_id, string $web_app_url): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + /** * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success. * @param int|string $chat_id @@ -1216,7 +1272,7 @@ public function getChatAdministrators(int|string $chat_id, ?bool $return_bots = } /** - * Use this method to get the number of members in a chat. Returns Int on success. + * Use this method to get the number of members in a chat. Returns Integer on success. * @param int|string $chat_id * @return int */ @@ -1241,7 +1297,7 @@ public function getChatMember(int|string $chat_id, int $user_id): ChatMember } /** - * Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an array of Message objects is returned. + * Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an Array of Message objects is returned. * @param int $user_id * @param int $limit * @return Message[] @@ -2184,7 +2240,7 @@ public function savePreparedKeyboardButton(int $user_id, KeyboardButton $button) } /** - * Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * Use this method to edit text, rich and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. * @param string $business_connection_id * @param int|string $chat_id * @param int $message_id @@ -2193,10 +2249,11 @@ public function savePreparedKeyboardButton(int $user_id, KeyboardButton $button) * @param string $parse_mode * @param MessageEntity[] $entities * @param LinkPreviewOptions $link_preview_options + * @param InputRichMessage $rich_message * @param InlineKeyboardMarkup $reply_markup * @return Message|bool */ - public function editMessageText(string $text, ?string $business_connection_id = null, int|string|null $chat_id = null, ?int $message_id = null, ?string $inline_message_id = null, ?string $parse_mode = null, ?array $entities = null, ?LinkPreviewOptions $link_preview_options = null, ?InlineKeyboardMarkup $reply_markup = null): Message|bool + public function editMessageText(?string $business_connection_id = null, int|string|null $chat_id = null, ?int $message_id = null, ?string $inline_message_id = null, ?string $text = null, ?string $parse_mode = null, ?array $entities = null, ?LinkPreviewOptions $link_preview_options = null, ?InputRichMessage $rich_message = null, ?InlineKeyboardMarkup $reply_markup = null): Message|bool { $args = get_defined_vars(); unset($args['this']); @@ -2224,7 +2281,7 @@ public function editMessageCaption(?string $business_connection_id = null, int|s } /** - * Use this method to edit animation, audio, document, live photo, photo, or video messages, or to add media to text messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. + * Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. * @param string $business_connection_id * @param int|string $chat_id * @param int $message_id @@ -2325,6 +2382,74 @@ public function stopPoll(int|string $chat_id, int $message_id, ?string $business return $this->sender(__FUNCTION__, $args); } + /** + * Use this method to edit an ephemeral text message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. + * @param int|string $chat_id + * @param int $receiver_user_id + * @param int $ephemeral_message_id + * @param string $text + * @param string $parse_mode + * @param MessageEntity[] $entities + * @param LinkPreviewOptions $link_preview_options + * @param InlineKeyboardMarkup $reply_markup + * @return bool + */ + public function editEphemeralMessageText(int|string $chat_id, int $receiver_user_id, int $ephemeral_message_id, string $text, ?string $parse_mode = null, ?array $entities = null, ?LinkPreviewOptions $link_preview_options = null, ?InlineKeyboardMarkup $reply_markup = null): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + + /** + * Use this method to edit the media of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. + * @param int|string $chat_id + * @param int $receiver_user_id + * @param int $ephemeral_message_id + * @param InputMedia $media + * @param InlineKeyboardMarkup $reply_markup + * @return bool + */ + public function editEphemeralMessageMedia(int|string $chat_id, int $receiver_user_id, int $ephemeral_message_id, InputMedia $media, ?InlineKeyboardMarkup $reply_markup = null): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + + /** + * Use this method to edit the caption of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. + * @param int|string $chat_id + * @param int $receiver_user_id + * @param int $ephemeral_message_id + * @param string $caption + * @param string $parse_mode + * @param MessageEntity[] $caption_entities + * @param InlineKeyboardMarkup $reply_markup + * @return bool + */ + public function editEphemeralMessageCaption(int|string $chat_id, int $receiver_user_id, int $ephemeral_message_id, ?string $caption = null, ?string $parse_mode = null, ?array $caption_entities = null, ?InlineKeyboardMarkup $reply_markup = null): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + + /** + * Use this method to edit only the reply markup of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned. + * @param int|string $chat_id + * @param int $receiver_user_id + * @param int $ephemeral_message_id + * @param InlineKeyboardMarkup $reply_markup + * @return bool + */ + public function editEphemeralMessageReplyMarkup(int|string $chat_id, int $receiver_user_id, int $ephemeral_message_id, ?InlineKeyboardMarkup $reply_markup = null): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + /** * Use this method to approve a suggested post in a direct messages chat. The bot must have the 'can_post_messages' administrator right in the corresponding channel chat. Returns True on success. * @param int $chat_id @@ -2379,6 +2504,20 @@ public function deleteMessages(int|string $chat_id, array $message_ids): bool return $this->sender(__FUNCTION__, $args); } + /** + * Use this method to delete an ephemeral message. Note that it is not guaranteed that the user will receive the message deletion event, especially if they are offline. Returns True on success. + * @param int|string $chat_id + * @param int $receiver_user_id + * @param int $ephemeral_message_id + * @return bool + */ + public function deleteEphemeralMessage(int|string $chat_id, int $receiver_user_id, int $ephemeral_message_id): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + /** * Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the 'can_delete_messages' administrator right in the chat. Returns True on success. * @param int|string $chat_id @@ -2414,6 +2553,8 @@ public function deleteAllMessageReactions(int|string $chat_id, ?int $user_id = n * @param int|string $chat_id * @param int $message_thread_id * @param int $direct_messages_topic_id + * @param int $receiver_user_id + * @param string $callback_query_id * @param InputFile|string $sticker * @param string $emoji * @param bool $disable_notification @@ -2425,7 +2566,7 @@ public function deleteAllMessageReactions(int|string $chat_id, ?int $user_id = n * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup * @return Message */ - public function sendSticker(int|string $chat_id, InputFile|string $sticker, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?string $emoji = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + public function sendSticker(int|string $chat_id, InputFile|string $sticker, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?int $receiver_user_id = null, ?string $callback_query_id = null, ?string $emoji = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message { $args = get_defined_vars(); unset($args['this']); @@ -2633,6 +2774,44 @@ public function deleteStickerSet(string $name): bool return $this->sender(__FUNCTION__, $args); } + /** + * Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent Message is returned. + * @param string $business_connection_id + * @param int|string $chat_id + * @param int $message_thread_id + * @param int $direct_messages_topic_id + * @param InputRichMessage $rich_message + * @param bool $disable_notification + * @param bool $protect_content + * @param bool $allow_paid_broadcast + * @param string $message_effect_id + * @param SuggestedPostParameters $suggested_post_parameters + * @param ReplyParameters $reply_parameters + * @param InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply $reply_markup + * @return Message + */ + public function sendRichMessage(int|string $chat_id, InputRichMessage $rich_message, ?string $business_connection_id = null, ?int $message_thread_id = null, ?int $direct_messages_topic_id = null, ?bool $disable_notification = null, ?bool $protect_content = null, ?bool $allow_paid_broadcast = null, ?string $message_effect_id = null, ?SuggestedPostParameters $suggested_post_parameters = null, ?ReplyParameters $reply_parameters = null, InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $reply_markup = null): Message + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + + /** + * Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendRichMessage with the complete message to persist it in the user's chat. Returns True on success. + * @param int $chat_id + * @param int $message_thread_id + * @param int $draft_id + * @param InputRichMessage $rich_message + * @return bool + */ + public function sendRichMessageDraft(int $chat_id, int $draft_id, InputRichMessage $rich_message, ?int $message_thread_id = null): bool + { + $args = get_defined_vars(); + unset($args['this']); + return $this->sender(__FUNCTION__, $args); + } + /** * Use this method to send answers to an inline query. On success, True is returned.No more than 50 results per query are allowed. * @param string $inline_query_id From 7b69410431848bbf921f583229ae1515da559ef3 Mon Sep 17 00:00:00 2001 From: al3x5dev Date: Tue, 28 Jul 2026 00:51:19 -0400 Subject: [PATCH 2/4] refactor: RichText* now extend RichText; add RichMessage builder; move keyboards to subdir; drop FormatHelper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix inheritance: 25 RichText subclasses now extend `RichText` instead of `Entity`, preventing PHP type coercion to string in `string|RichText|array` union hints - Add `type` field to `InputRichBlockTable` in `Table::build()` (was missing, causing Telegram "Can't find field 'type'" error) - Add `Factories/RichMessage.php` — fluent builder with `block()`, `html()`, `markdown()`, `rtl()`, `build()` methods - Add `Factories/Rich/Block.php` — factory for all 20 rich block types (paragraph, heading, table, photo, video, etc.) - Add `Factories/Rich/Table.php` — table builder with `header()`, `body()`, `footer()`, `bordered()`, `striped()`, `caption()` chain - Add `Text.php` — replaces `FormatHelper` with string helpers (`bold()`, `italic()`, etc.) and rich object methods (`richBold()`, `richItalic()`, etc.) - Move keyboard factories to `Factories/Keyboard/` (Inline, Reply, InlineButton, ReplyButton) with namespaced classes; update `Keyboard` facade - Delete `FormatHelper.php` and its test - Update constants in `InputRichBlock.php` and `RichBlock.php` to match Telegram API 7.0+: `heading`, `pre`, `blockquote`, `pullquote` - Add `tests/Unit/TextTest.php`; update `KeyboardTest.php` and docs --- composer.json | 1 - docs/format.md | 36 +- docs/middlewares.md | 6 +- src/Telegram/Entities/InputRichBlock.php | 18 +- src/Telegram/Entities/RichBlock.php | 18 +- src/Telegram/Entities/RichText.php | 4 +- src/Telegram/Entities/RichTextAnchor.php | 2 +- src/Telegram/Entities/RichTextAnchorLink.php | 2 +- .../Entities/RichTextBankCardNumber.php | 2 +- src/Telegram/Entities/RichTextBold.php | 2 +- src/Telegram/Entities/RichTextBotCommand.php | 2 +- src/Telegram/Entities/RichTextCashtag.php | 2 +- src/Telegram/Entities/RichTextCode.php | 2 +- src/Telegram/Entities/RichTextCustomEmoji.php | 2 +- src/Telegram/Entities/RichTextDateTime.php | 2 +- .../Entities/RichTextEmailAddress.php | 2 +- src/Telegram/Entities/RichTextHashtag.php | 2 +- src/Telegram/Entities/RichTextItalic.php | 2 +- src/Telegram/Entities/RichTextMarked.php | 2 +- .../RichTextMathematicalExpression.php | 2 +- src/Telegram/Entities/RichTextMention.php | 2 +- src/Telegram/Entities/RichTextPhoneNumber.php | 2 +- src/Telegram/Entities/RichTextReference.php | 2 +- .../Entities/RichTextReferenceLink.php | 2 +- src/Telegram/Entities/RichTextSpoiler.php | 2 +- .../Entities/RichTextStrikethrough.php | 2 +- src/Telegram/Entities/RichTextSubscript.php | 2 +- src/Telegram/Entities/RichTextSuperscript.php | 2 +- src/Telegram/Entities/RichTextTextMention.php | 2 +- src/Telegram/Entities/RichTextUnderline.php | 2 +- src/Telegram/Entities/RichTextUrl.php | 2 +- src/Telegram/Factories/Keyboard.php | 2 + .../Factories/{ => Keyboard}/Inline.php | 3 +- .../Factories/{ => Keyboard}/InlineButton.php | 4 +- .../Factories/{ => Keyboard}/Reply.php | 3 +- .../Factories/{ => Keyboard}/ReplyButton.php | 4 +- src/Telegram/Factories/Rich/Block.php | 363 ++++++++++++++++++ src/Telegram/Factories/Rich/Table.php | 114 ++++++ src/Telegram/Factories/RichMessage.php | 51 +++ src/Telegram/FormatHelper.php | 163 -------- src/Telegram/Text.php | 241 ++++++++++++ tests/Unit/KeyboardTest.php | 8 +- .../{FormatHelperTest.php => TextTest.php} | 61 ++- 43 files changed, 890 insertions(+), 260 deletions(-) rename src/Telegram/Factories/{ => Keyboard}/Inline.php (73%) rename src/Telegram/Factories/{ => Keyboard}/InlineButton.php (93%) rename src/Telegram/Factories/{ => Keyboard}/Reply.php (91%) rename src/Telegram/Factories/{ => Keyboard}/ReplyButton.php (91%) create mode 100644 src/Telegram/Factories/Rich/Block.php create mode 100644 src/Telegram/Factories/Rich/Table.php create mode 100644 src/Telegram/Factories/RichMessage.php delete mode 100644 src/Telegram/FormatHelper.php create mode 100644 src/Telegram/Text.php rename tests/Unit/{FormatHelperTest.php => TextTest.php} (54%) diff --git a/composer.json b/composer.json index f8d2651..be2a600 100755 --- a/composer.json +++ b/composer.json @@ -39,7 +39,6 @@ "psr-4": { "Al3x5\\xBot\\": "src/", "Bot\\": "bot/" - }, "files": [ "src/helpers.php" diff --git a/docs/format.md b/docs/format.md index 1deedb3..356e628 100644 --- a/docs/format.md +++ b/docs/format.md @@ -1,16 +1,16 @@ -# FormatHelper +# Text -The `FormatHelper` class provides static methods for applying different formats to text in Telegram messages. These formats include bold, italics, underlines, strikethrough, spoilers, links, user mentions, custom emoji, code blocks, and quotes. This class is useful for formatting messages sent through a Telegram bot, improving their presentation and readability. +The `Text` class provides static methods for applying different formats to text in Telegram messages. These formats include bold, italics, underlines, strikethrough, spoilers, links, user mentions, custom emoji, code blocks, and quotes. This class is useful for formatting messages sent through a Telegram bot, improving their presentation and readability. > [!WARNING] -> `FormatHelper` generates the formatting according to the configuration value of `parse_mode` (default is `'HTML'`). +> `Text` generates the formatting according to the configuration value of `parse_mode` (default is `'HTML'`). > > If you override `parse_mode` in a method's parameters (e.g., `reply($msg, ['parse_mode' => 'MarkdownV2'])`), -> the text formatted by `FormatHelper` will *NOT* be automatically adapted—it will continue to use the configuration's formatting. +> the text formatted by `Text` will *NOT* be automatically adapted—it will continue to use the configuration's formatting. > > In that case, you are responsible for ensuring that the text format matches the `parse_mode` you are sending. > -> **Using `FormatHelper` is not recommended when the message's `parse_mode` differs from the globally configured one.** +> **Using `Text` is not recommended when the message's `parse_mode` differs from the globally configured one.** ## Methods @@ -19,7 +19,7 @@ The `FormatHelper` class provides static methods for applying different formats Formats the provided text in bold. ```php -$this->reply(FormatHelper::bold('This text will be bold')); +$this->reply(Text::bold('This text will be bold')); // Output: This text will be bold ``` @@ -28,7 +28,7 @@ $this->reply(FormatHelper::bold('This text will be bold')); Formats the provided text in italics. ```php -$this->reply(FormatHelper::italic('This text will be italic')); +$this->reply(Text::italic('This text will be italic')); // Output: This text will be italic ``` @@ -37,7 +37,7 @@ $this->reply(FormatHelper::italic('This text will be italic')); Formats the provided text as underlined. ```php -$this->reply(FormatHelper::underline('This text will be underlined')); +$this->reply(Text::underline('This text will be underlined')); // Output: This text will be underlined ``` @@ -46,7 +46,7 @@ $this->reply(FormatHelper::underline('This text will be underlined')); Formats the provided text as a strikethrough. ```php -$this->reply(FormatHelper::strikethrough('This text will be strikethrough')); +$this->reply(Text::strikethrough('This text will be strikethrough')); // Output: This text will be strikethrough ``` @@ -55,7 +55,7 @@ $this->reply(FormatHelper::strikethrough('This text will be strikethrough')); Formats the provided text as a spoiler. ```php -$this->reply(FormatHelper::spoiler('This text will be a spoiler')); +$this->reply(Text::spoiler('This text will be a spoiler')); // Output: This text will be a spoiler ``` @@ -64,7 +64,7 @@ $this->reply(FormatHelper::spoiler('This text will be a spoiler')); Formats the provided text as a link. ```php -$this->reply(FormatHelper::link('Click here', 'https://example.com')); +$this->reply(Text::link('Click here', 'https://example.com')); // Output: Click here ``` @@ -73,7 +73,7 @@ $this->reply(FormatHelper::link('Click here', 'https://example.com')); Formats the provided text as a user mention. ```php -$this->reply(FormatHelper::mention('@user', 123456789)); +$this->reply(Text::mention('@user', 123456789)); // Output: @user ``` @@ -82,7 +82,7 @@ $this->reply(FormatHelper::mention('@user', 123456789)); Formats the provided text as a custom emoji. ```php -$this->reply(FormatHelper::emoji('😊', '1234567890')); +$this->reply(Text::emoji('😊', '1234567890')); // Output: 😊 ``` @@ -91,7 +91,7 @@ $this->reply(FormatHelper::emoji('😊', '1234567890')); Formats the provided text as inline code. ```php -$this->reply(FormatHelper::inlineCode('inline code')); +$this->reply(Text::inlineCode('inline code')); // Output: inline code ``` @@ -100,7 +100,7 @@ $this->reply(FormatHelper::inlineCode('inline code')); Formats the provided text as a code block. ```php -$this->reply(FormatHelper::codeBlock('block code', 'php')); +$this->reply(Text::codeBlock('block code', 'php')); // Output:
block code
``` @@ -116,7 +116,7 @@ Formats a Unix timestamp for display. Supports multiple format options: - `r`: Relative time from current moment ```php -$this->reply(FormatHelper::time(1710691200, 't')); +$this->reply(Text::time(1710691200, 't')); // Output: fecha ``` @@ -125,7 +125,7 @@ $this->reply(FormatHelper::time(1710691200, 't')); Formats the provided text as a blockquote. ```php -$this->reply(FormatHelper::blockQuote('This is a blockquote')); +$this->reply(Text::blockQuote('This is a blockquote')); // Output:
This is a blockquote
``` @@ -134,6 +134,6 @@ $this->reply(FormatHelper::blockQuote('This is a blockquote')); Formats the provided text as an expandable blockquote. ```php -$this->reply(FormatHelper::expandableBlockQuote('This is an expandable blockquote')); +$this->reply(Text::expandableBlockQuote('This is an expandable blockquote')); // Output:
This is an expandable blockquote
``` \ No newline at end of file diff --git a/docs/middlewares.md b/docs/middlewares.md index 16dee8c..f3f0d08 100644 --- a/docs/middlewares.md +++ b/docs/middlewares.md @@ -210,7 +210,7 @@ Example: namespace Bot\Middlewares; -use Al3x5\xBot\Telegram\FormatHelper; +use Al3x5\xBot\Telegram\Text; use Al3x5\xBot\Telegram\Actions\Middlewares; class AdminMiddleware extends Middlewares @@ -220,7 +220,7 @@ class AdminMiddleware extends Middlewares if (!$this->isAdmin()) { return $this->abort( '🚫 No eres bienvenido aquí ' . - FormatHelper::mention( + Text::mention( $this->update->message->from->first_name, $this->update->message->from->id ) @@ -229,7 +229,7 @@ class AdminMiddleware extends Middlewares $this->reply( '✅ Bienvenido ' . - FormatHelper::mention( + Text::mention( $this->update->message->from->first_name, $this->update->message->from->id ) diff --git a/src/Telegram/Entities/InputRichBlock.php b/src/Telegram/Entities/InputRichBlock.php index 7331b21..0f7baa5 100644 --- a/src/Telegram/Entities/InputRichBlock.php +++ b/src/Telegram/Entities/InputRichBlock.php @@ -11,15 +11,15 @@ class InputRichBlock extends Entity { public const TYPE_PARAGRAPH = 'paragraph'; - public const TYPE_SECTION_HEADING = 'section_heading'; - public const TYPE_PREFORMATTED = 'preformatted'; + public const TYPE_HEADING = 'heading'; + public const TYPE_PREFORMATTED = 'pre'; public const TYPE_FOOTER = 'footer'; public const TYPE_DIVIDER = 'divider'; public const TYPE_MATHEMATICAL_EXPRESSION = 'mathematical_expression'; public const TYPE_ANCHOR = 'anchor'; public const TYPE_LIST = 'list'; - public const TYPE_BLOCK_QUOTATION = 'block_quotation'; - public const TYPE_PULL_QUOTATION = 'pull_quotation'; + public const TYPE_BLOCK_QUOTATION = 'blockquote'; + public const TYPE_PULL_QUOTATION = 'pullquote'; public const TYPE_COLLAGE = 'collage'; public const TYPE_SLIDESHOW = 'slideshow'; public const TYPE_TABLE = 'table'; @@ -40,15 +40,15 @@ public function resolve(): Entity { return match($this->type) { 'paragraph' => new InputRichBlockParagraph($this->properties), - 'section_heading' => new InputRichBlockSectionHeading($this->properties), - 'preformatted' => new InputRichBlockPreformatted($this->properties), + 'heading' => new InputRichBlockSectionHeading($this->properties), + 'pre' => new InputRichBlockPreformatted($this->properties), 'footer' => new InputRichBlockFooter($this->properties), 'divider' => new InputRichBlockDivider($this->properties), 'mathematical_expression' => new InputRichBlockMathematicalExpression($this->properties), 'anchor' => new InputRichBlockAnchor($this->properties), 'list' => new InputRichBlockList($this->properties), - 'block_quotation' => new InputRichBlockBlockQuotation($this->properties), - 'pull_quotation' => new InputRichBlockPullQuotation($this->properties), + 'blockquote' => new InputRichBlockBlockQuotation($this->properties), + 'pullquote' => new InputRichBlockPullQuotation($this->properties), 'collage' => new InputRichBlockCollage($this->properties), 'slideshow' => new InputRichBlockSlideshow($this->properties), 'table' => new InputRichBlockTable($this->properties), @@ -75,7 +75,7 @@ public static function create(array $data): Entity { return match($data['type'] ?? null) { self::TYPE_PARAGRAPH => new InputRichBlockParagraph($data), - self::TYPE_SECTION_HEADING => new InputRichBlockSectionHeading($data), + self::TYPE_HEADING => new InputRichBlockSectionHeading($data), self::TYPE_PREFORMATTED => new InputRichBlockPreformatted($data), self::TYPE_FOOTER => new InputRichBlockFooter($data), self::TYPE_DIVIDER => new InputRichBlockDivider($data), diff --git a/src/Telegram/Entities/RichBlock.php b/src/Telegram/Entities/RichBlock.php index de165e6..186c39a 100644 --- a/src/Telegram/Entities/RichBlock.php +++ b/src/Telegram/Entities/RichBlock.php @@ -11,15 +11,15 @@ class RichBlock extends Entity { public const TYPE_PARAGRAPH = 'paragraph'; - public const TYPE_SECTION_HEADING = 'section_heading'; - public const TYPE_PREFORMATTED = 'preformatted'; + public const TYPE_HEADING = 'heading'; + public const TYPE_PREFORMATTED = 'pre'; public const TYPE_FOOTER = 'footer'; public const TYPE_DIVIDER = 'divider'; public const TYPE_MATHEMATICAL_EXPRESSION = 'mathematical_expression'; public const TYPE_ANCHOR = 'anchor'; public const TYPE_LIST = 'list'; - public const TYPE_BLOCK_QUOTATION = 'block_quotation'; - public const TYPE_PULL_QUOTATION = 'pull_quotation'; + public const TYPE_BLOCK_QUOTATION = 'blockquote'; + public const TYPE_PULL_QUOTATION = 'pullquote'; public const TYPE_COLLAGE = 'collage'; public const TYPE_SLIDESHOW = 'slideshow'; public const TYPE_TABLE = 'table'; @@ -40,15 +40,15 @@ public function resolve(): Entity { return match($this->type) { 'paragraph' => new RichBlockParagraph($this->properties), - 'section_heading' => new RichBlockSectionHeading($this->properties), - 'preformatted' => new RichBlockPreformatted($this->properties), + 'heading' => new RichBlockSectionHeading($this->properties), + 'pre' => new RichBlockPreformatted($this->properties), 'footer' => new RichBlockFooter($this->properties), 'divider' => new RichBlockDivider($this->properties), 'mathematical_expression' => new RichBlockMathematicalExpression($this->properties), 'anchor' => new RichBlockAnchor($this->properties), 'list' => new RichBlockList($this->properties), - 'block_quotation' => new RichBlockBlockQuotation($this->properties), - 'pull_quotation' => new RichBlockPullQuotation($this->properties), + 'blockquote' => new RichBlockBlockQuotation($this->properties), + 'pullquote' => new RichBlockPullQuotation($this->properties), 'collage' => new RichBlockCollage($this->properties), 'slideshow' => new RichBlockSlideshow($this->properties), 'table' => new RichBlockTable($this->properties), @@ -75,7 +75,7 @@ public static function create(array $data): Entity { return match($data['type'] ?? null) { self::TYPE_PARAGRAPH => new RichBlockParagraph($data), - self::TYPE_SECTION_HEADING => new RichBlockSectionHeading($data), + self::TYPE_HEADING => new RichBlockSectionHeading($data), self::TYPE_PREFORMATTED => new RichBlockPreformatted($data), self::TYPE_FOOTER => new RichBlockFooter($data), self::TYPE_DIVIDER => new RichBlockDivider($data), diff --git a/src/Telegram/Entities/RichText.php b/src/Telegram/Entities/RichText.php index 7d1fbb9..9f2b92f 100644 --- a/src/Telegram/Entities/RichText.php +++ b/src/Telegram/Entities/RichText.php @@ -15,7 +15,7 @@ class RichText extends Entity public const TYPE_UNDERLINE = 'underline'; public const TYPE_STRIKETHROUGH = 'strikethrough'; public const TYPE_SPOILER = 'spoiler'; - public const TYPE_DATETIME = 'datetime'; + public const TYPE_DATETIME = 'date_time'; public const TYPE_TEXT_MENTION = 'text_mention'; public const TYPE_SUBSCRIPT = 'subscript'; public const TYPE_SUPERSCRIPT = 'superscript'; @@ -48,7 +48,7 @@ public function resolve(): Entity 'underline' => new RichTextUnderline($this->properties), 'strikethrough' => new RichTextStrikethrough($this->properties), 'spoiler' => new RichTextSpoiler($this->properties), - 'datetime' => new RichTextDateTime($this->properties), + 'date_time' => new RichTextDateTime($this->properties), 'text_mention' => new RichTextTextMention($this->properties), 'subscript' => new RichTextSubscript($this->properties), 'superscript' => new RichTextSuperscript($this->properties), diff --git a/src/Telegram/Entities/RichTextAnchor.php b/src/Telegram/Entities/RichTextAnchor.php index 168cc82..3f4b678 100644 --- a/src/Telegram/Entities/RichTextAnchor.php +++ b/src/Telegram/Entities/RichTextAnchor.php @@ -9,7 +9,7 @@ * @property string $type * @property string $name */ -class RichTextAnchor extends Entity +class RichTextAnchor extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextAnchorLink.php b/src/Telegram/Entities/RichTextAnchorLink.php index 0394494..8aaa437 100644 --- a/src/Telegram/Entities/RichTextAnchorLink.php +++ b/src/Telegram/Entities/RichTextAnchorLink.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $anchor_name */ -class RichTextAnchorLink extends Entity +class RichTextAnchorLink extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextBankCardNumber.php b/src/Telegram/Entities/RichTextBankCardNumber.php index 7471035..dc4e325 100644 --- a/src/Telegram/Entities/RichTextBankCardNumber.php +++ b/src/Telegram/Entities/RichTextBankCardNumber.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $bank_card_number */ -class RichTextBankCardNumber extends Entity +class RichTextBankCardNumber extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextBold.php b/src/Telegram/Entities/RichTextBold.php index c6030a1..36bd676 100644 --- a/src/Telegram/Entities/RichTextBold.php +++ b/src/Telegram/Entities/RichTextBold.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextBold extends Entity +class RichTextBold extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextBotCommand.php b/src/Telegram/Entities/RichTextBotCommand.php index 9847579..8bd225e 100644 --- a/src/Telegram/Entities/RichTextBotCommand.php +++ b/src/Telegram/Entities/RichTextBotCommand.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $bot_command */ -class RichTextBotCommand extends Entity +class RichTextBotCommand extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextCashtag.php b/src/Telegram/Entities/RichTextCashtag.php index 3b669e1..7c9f0ab 100644 --- a/src/Telegram/Entities/RichTextCashtag.php +++ b/src/Telegram/Entities/RichTextCashtag.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $cashtag */ -class RichTextCashtag extends Entity +class RichTextCashtag extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextCode.php b/src/Telegram/Entities/RichTextCode.php index 526a117..f8ab095 100644 --- a/src/Telegram/Entities/RichTextCode.php +++ b/src/Telegram/Entities/RichTextCode.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextCode extends Entity +class RichTextCode extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextCustomEmoji.php b/src/Telegram/Entities/RichTextCustomEmoji.php index 6890814..076a3a7 100644 --- a/src/Telegram/Entities/RichTextCustomEmoji.php +++ b/src/Telegram/Entities/RichTextCustomEmoji.php @@ -10,7 +10,7 @@ * @property string $custom_emoji_id * @property string $alternative_text */ -class RichTextCustomEmoji extends Entity +class RichTextCustomEmoji extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextDateTime.php b/src/Telegram/Entities/RichTextDateTime.php index f3e64f8..7760a7b 100644 --- a/src/Telegram/Entities/RichTextDateTime.php +++ b/src/Telegram/Entities/RichTextDateTime.php @@ -11,7 +11,7 @@ * @property int $unix_time * @property string $date_time_format */ -class RichTextDateTime extends Entity +class RichTextDateTime extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextEmailAddress.php b/src/Telegram/Entities/RichTextEmailAddress.php index 4236db6..28958da 100644 --- a/src/Telegram/Entities/RichTextEmailAddress.php +++ b/src/Telegram/Entities/RichTextEmailAddress.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $email_address */ -class RichTextEmailAddress extends Entity +class RichTextEmailAddress extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextHashtag.php b/src/Telegram/Entities/RichTextHashtag.php index 43b6975..b5249dc 100644 --- a/src/Telegram/Entities/RichTextHashtag.php +++ b/src/Telegram/Entities/RichTextHashtag.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $hashtag */ -class RichTextHashtag extends Entity +class RichTextHashtag extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextItalic.php b/src/Telegram/Entities/RichTextItalic.php index efb8292..c3155a8 100644 --- a/src/Telegram/Entities/RichTextItalic.php +++ b/src/Telegram/Entities/RichTextItalic.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextItalic extends Entity +class RichTextItalic extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextMarked.php b/src/Telegram/Entities/RichTextMarked.php index e8a0882..9a24be0 100644 --- a/src/Telegram/Entities/RichTextMarked.php +++ b/src/Telegram/Entities/RichTextMarked.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextMarked extends Entity +class RichTextMarked extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextMathematicalExpression.php b/src/Telegram/Entities/RichTextMathematicalExpression.php index 71467b9..a91fba2 100644 --- a/src/Telegram/Entities/RichTextMathematicalExpression.php +++ b/src/Telegram/Entities/RichTextMathematicalExpression.php @@ -9,7 +9,7 @@ * @property string $type * @property string $expression */ -class RichTextMathematicalExpression extends Entity +class RichTextMathematicalExpression extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextMention.php b/src/Telegram/Entities/RichTextMention.php index 7e0c92b..7fa18e7 100644 --- a/src/Telegram/Entities/RichTextMention.php +++ b/src/Telegram/Entities/RichTextMention.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $username */ -class RichTextMention extends Entity +class RichTextMention extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextPhoneNumber.php b/src/Telegram/Entities/RichTextPhoneNumber.php index 7e7af1e..2f00666 100644 --- a/src/Telegram/Entities/RichTextPhoneNumber.php +++ b/src/Telegram/Entities/RichTextPhoneNumber.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $phone_number */ -class RichTextPhoneNumber extends Entity +class RichTextPhoneNumber extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextReference.php b/src/Telegram/Entities/RichTextReference.php index e570977..5b9fddc 100644 --- a/src/Telegram/Entities/RichTextReference.php +++ b/src/Telegram/Entities/RichTextReference.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $name */ -class RichTextReference extends Entity +class RichTextReference extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextReferenceLink.php b/src/Telegram/Entities/RichTextReferenceLink.php index 5af7279..ed14bd7 100644 --- a/src/Telegram/Entities/RichTextReferenceLink.php +++ b/src/Telegram/Entities/RichTextReferenceLink.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $reference_name */ -class RichTextReferenceLink extends Entity +class RichTextReferenceLink extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextSpoiler.php b/src/Telegram/Entities/RichTextSpoiler.php index b528ec3..5889141 100644 --- a/src/Telegram/Entities/RichTextSpoiler.php +++ b/src/Telegram/Entities/RichTextSpoiler.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextSpoiler extends Entity +class RichTextSpoiler extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextStrikethrough.php b/src/Telegram/Entities/RichTextStrikethrough.php index f748270..06be993 100644 --- a/src/Telegram/Entities/RichTextStrikethrough.php +++ b/src/Telegram/Entities/RichTextStrikethrough.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextStrikethrough extends Entity +class RichTextStrikethrough extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextSubscript.php b/src/Telegram/Entities/RichTextSubscript.php index 83053ff..e023ff7 100644 --- a/src/Telegram/Entities/RichTextSubscript.php +++ b/src/Telegram/Entities/RichTextSubscript.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextSubscript extends Entity +class RichTextSubscript extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextSuperscript.php b/src/Telegram/Entities/RichTextSuperscript.php index 20a54c8..2c05ebf 100644 --- a/src/Telegram/Entities/RichTextSuperscript.php +++ b/src/Telegram/Entities/RichTextSuperscript.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextSuperscript extends Entity +class RichTextSuperscript extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextTextMention.php b/src/Telegram/Entities/RichTextTextMention.php index 10f0adc..3eb7572 100644 --- a/src/Telegram/Entities/RichTextTextMention.php +++ b/src/Telegram/Entities/RichTextTextMention.php @@ -10,7 +10,7 @@ * @property RichText $text * @property User $user */ -class RichTextTextMention extends Entity +class RichTextTextMention extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextUnderline.php b/src/Telegram/Entities/RichTextUnderline.php index 5ff9d8a..213c85c 100644 --- a/src/Telegram/Entities/RichTextUnderline.php +++ b/src/Telegram/Entities/RichTextUnderline.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichTextUnderline extends Entity +class RichTextUnderline extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichTextUrl.php b/src/Telegram/Entities/RichTextUrl.php index 1e8316b..1e0f8fb 100644 --- a/src/Telegram/Entities/RichTextUrl.php +++ b/src/Telegram/Entities/RichTextUrl.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $url */ -class RichTextUrl extends Entity +class RichTextUrl extends RichText { protected function setEntities(): array diff --git a/src/Telegram/Factories/Keyboard.php b/src/Telegram/Factories/Keyboard.php index c49413d..0bb9604 100644 --- a/src/Telegram/Factories/Keyboard.php +++ b/src/Telegram/Factories/Keyboard.php @@ -4,6 +4,8 @@ use Al3x5\xBot\Telegram\Entities\ForceReply; use Al3x5\xBot\Telegram\Entities\ReplyKeyboardRemove; +use Al3x5\xBot\Telegram\Factories\Keyboard\Inline; +use Al3x5\xBot\Telegram\Factories\Keyboard\Reply; class Keyboard { diff --git a/src/Telegram/Factories/Inline.php b/src/Telegram/Factories/Keyboard/Inline.php similarity index 73% rename from src/Telegram/Factories/Inline.php rename to src/Telegram/Factories/Keyboard/Inline.php index 72d95ae..3f33d9e 100644 --- a/src/Telegram/Factories/Inline.php +++ b/src/Telegram/Factories/Keyboard/Inline.php @@ -1,9 +1,8 @@ InputRichBlock::TYPE_PARAGRAPH, + 'text' => $text, + ]); + } + + public static function heading(string|RichText|array $text, int $size = 1): InputRichBlockSectionHeading + { + return new InputRichBlockSectionHeading([ + 'type' => InputRichBlock::TYPE_HEADING, + 'text' => $text, + 'size' => $size, + ]); + } + + public static function preformatted(string|RichText|array $text, string $language = ''): InputRichBlockPreformatted + { + $data = [ + 'type' => InputRichBlock::TYPE_PREFORMATTED, + 'text' => $text, + ]; + if ($language !== '') { + $data['language'] = $language; + } + return new InputRichBlockPreformatted($data); + } + + public static function footer(string|RichText|array $text): InputRichBlockFooter + { + return new InputRichBlockFooter([ + 'type' => InputRichBlock::TYPE_FOOTER, + 'text' => $text, + ]); + } + + public static function divider(): InputRichBlockDivider + { + return new InputRichBlockDivider([ + 'type' => InputRichBlock::TYPE_DIVIDER, + ]); + } + + public static function thinking(string|RichText|array $text): InputRichBlockThinking + { + return new InputRichBlockThinking([ + 'type' => InputRichBlock::TYPE_THINKING, + 'text' => $text, + ]); + } + + public static function blockQuote(array $blocks, string|RichText|null $credit = null): InputRichBlockBlockQuotation + { + $data = [ + 'type' => InputRichBlock::TYPE_BLOCK_QUOTATION, + 'blocks' => $blocks, + ]; + if ($credit !== null) { + $data['credit'] = $credit; + } + return new InputRichBlockBlockQuotation($data); + } + + public static function pullQuote(string|RichText|array $text, string|RichText|null $credit = null): InputRichBlockPullQuotation + { + $data = [ + 'type' => InputRichBlock::TYPE_PULL_QUOTATION, + 'text' => $text, + ]; + if ($credit !== null) { + $data['credit'] = $credit; + } + return new InputRichBlockPullQuotation($data); + } + + public static function photo( + string $media, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockPhoto { + $data = [ + 'type' => InputRichBlock::TYPE_PHOTO, + 'photo' => new InputMediaPhoto([ + 'type' => 'photo', + 'media' => $media, + ]), + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockPhoto($data); + } + + public static function video( + string $media, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockVideo { + $data = [ + 'type' => InputRichBlock::TYPE_VIDEO, + 'video' => new InputMediaVideo([ + 'type' => 'video', + 'media' => $media, + ]), + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockVideo($data); + } + + public static function audio( + string $media, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockAudio { + $data = [ + 'type' => InputRichBlock::TYPE_AUDIO, + 'audio' => new InputMediaAudio([ + 'type' => 'audio', + 'media' => $media, + ]), + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockAudio($data); + } + + public static function animation( + string $media, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockAnimation { + $data = [ + 'type' => InputRichBlock::TYPE_ANIMATION, + 'animation' => new InputMediaAnimation([ + 'type' => 'animation', + 'media' => $media, + ]), + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockAnimation($data); + } + + public static function voiceNote( + string $media, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockVoiceNote { + $data = [ + 'type' => InputRichBlock::TYPE_VOICE_NOTE, + 'voice_note' => new InputMediaVoiceNote([ + 'type' => 'voice', + 'media' => $media, + ]), + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockVoiceNote($data); + } + + public static function table(): Table + { + return new Table(); + } + + public static function list(array $items): InputRichBlockList + { + $listItems = []; + foreach ($items as $item) { + if ($item instanceof InputRichBlock) { + $listItems[] = new InputRichBlockListItem([ + 'blocks' => [$item], + ]); + } elseif (is_array($item)) { + $listItems[] = new InputRichBlockListItem([ + 'blocks' => $item, + ]); + } + } + return new InputRichBlockList([ + 'type' => InputRichBlock::TYPE_LIST, + 'items' => $listItems, + ]); + } + + public static function details( + string|RichText|array $summary, + array $blocks, + bool $is_open = false + ): InputRichBlockDetails { + return new InputRichBlockDetails([ + 'type' => InputRichBlock::TYPE_DETAILS, + 'summary' => $summary, + 'blocks' => $blocks, + 'is_open' => $is_open, + ]); + } + + public static function collage( + array $blocks, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockCollage { + $data = [ + 'type' => InputRichBlock::TYPE_COLLAGE, + 'blocks' => $blocks, + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockCollage($data); + } + + public static function slideshow( + array $blocks, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockSlideshow { + $data = [ + 'type' => InputRichBlock::TYPE_SLIDESHOW, + 'blocks' => $blocks, + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockSlideshow($data); + } + + public static function map( + array $location, + int $zoom = 15, + int $width = 300, + int $height = 200, + string|RichText|null $caption = null, + string|RichText|null $credit = null + ): InputRichBlockMap { + $data = [ + 'type' => InputRichBlock::TYPE_MAP, + 'location' => $location, + 'zoom' => $zoom, + 'width' => $width, + 'height' => $height, + ]; + if ($caption !== null || $credit !== null) { + $captionData = []; + if ($caption !== null) { + $captionData['text'] = $caption; + } + if ($credit !== null) { + $captionData['credit'] = $credit; + } + $data['caption'] = new RichBlockCaption($captionData); + } + return new InputRichBlockMap($data); + } + + public static function math(string $expression): InputRichBlockMathematicalExpression + { + return new InputRichBlockMathematicalExpression([ + 'type' => InputRichBlock::TYPE_MATHEMATICAL_EXPRESSION, + 'expression' => $expression, + ]); + } + + public static function anchor(string $name): InputRichBlockAnchor + { + return new InputRichBlockAnchor([ + 'type' => InputRichBlock::TYPE_ANCHOR, + 'name' => $name, + ]); + } +} diff --git a/src/Telegram/Factories/Rich/Table.php b/src/Telegram/Factories/Rich/Table.php new file mode 100644 index 0000000..bb6b2ef --- /dev/null +++ b/src/Telegram/Factories/Rich/Table.php @@ -0,0 +1,114 @@ +header = $cells; + return $this; + } + + public function body(array $rows): self + { + $this->rows = $rows; + return $this; + } + + public function footer(array $cells): self + { + $this->footer = $cells; + return $this; + } + + public function bordered(bool $v = true): self + { + $this->options['is_bordered'] = $v; + return $this; + } + + public function striped(bool $v = true): self + { + $this->options['is_striped'] = $v; + return $this; + } + + public function caption(string|RichText|array $caption): self + { + $this->options['caption'] = $caption; + return $this; + } + + public function build(): InputRichBlockTable + { + $cells = []; + + if ($this->header) { + $cells[] = array_map(fn($c) => $this->resolveCell($c, true), $this->header); + } + + foreach ($this->rows as $row) { + $cells[] = array_map(fn($c) => $this->resolveCell($c, false), $row); + } + + if ($this->footer) { + $cells[] = array_map(fn($c) => $this->resolveCell($c, false), $this->footer); + } + + $table = new InputRichBlockTable([]); + $table->type = InputRichBlock::TYPE_TABLE; + $table->cells = $cells; + + if (isset($this->options['is_bordered'])) { + $table->is_bordered = $this->options['is_bordered']; + } + if (isset($this->options['is_striped'])) { + $table->is_striped = $this->options['is_striped']; + } + if (isset($this->options['caption'])) { + $table->caption = $this->options['caption']; + } + + return $table; + } + + private function resolveCell(mixed $cell, bool $isHeader): RichBlockTableCell + { + if ($cell instanceof RichBlockTableCell) { + return $cell; + } + + if (is_array($cell)) { + if (!isset($cell['text'])) { + $cell['text'] = ''; + } + if (!isset($cell['is_header'])) { + $cell['is_header'] = $isHeader; + } + return new RichBlockTableCell($cell); + } + + if ($cell instanceof RichText) { + return new RichBlockTableCell([ + 'text' => $cell, + 'is_header' => $isHeader, + ]); + } + + return new RichBlockTableCell([ + 'text' => (string) $cell, + 'is_header' => $isHeader, + ]); + } +} diff --git a/src/Telegram/Factories/RichMessage.php b/src/Telegram/Factories/RichMessage.php new file mode 100644 index 0000000..47f7aea --- /dev/null +++ b/src/Telegram/Factories/RichMessage.php @@ -0,0 +1,51 @@ +blocks[] = $block; + return $this; + } + + public function html(string $html): self + { + $this->options['html'] = $html; + return $this; + } + + public function markdown(string $markdown): self + { + $this->options['markdown'] = $markdown; + return $this; + } + + public function rtl(bool $v = true): self + { + $this->options['is_rtl'] = $v; + return $this; + } + + public function build(): InputRichMessage + { + $msg = new InputRichMessage([]); + $msg->blocks = $this->blocks; // ← asigna directo (usa __set) + foreach ($this->options as $k => $v) { + $msg->{$k} = $v; + } + return $msg; + } +} diff --git a/src/Telegram/FormatHelper.php b/src/Telegram/FormatHelper.php deleted file mode 100644 index 257445e..0000000 --- a/src/Telegram/FormatHelper.php +++ /dev/null @@ -1,163 +0,0 @@ -$text" : "*$text*"; - } - - /** - * Formato: Cursiva - */ - public static function italic(string $text): string - { - return self::isHtml() ? "$text" : '_' . $text . '_'; - } - - /** - * Formato: Subrayado - */ - public static function underline(string $text): string - { - return self::isHtml() ? "$text" : '__' . $text . '__'; - } - - /** - * Formato: Tachado - */ - public static function strikethrough(string $text): string - { - return self::isHtml() ? "$text" : "~$text~"; - } - - /** - * Formato: Spoiler - */ - public static function spoiler(string $text): string - { - return self::isHtml() ? "$text" : "||$text||"; - } - - /** - * Formato: Enlace - */ - public static function link(string $text, string $url): string - { - if (!self::isHtml()) { - return "[$text]($url)"; - } - $text = self::sanitize($text, 'link'); - return "$text"; - } - - /** - * Formato: Mención de usuario - */ - public static function mention(string $text, int $userId): string - { - return self::link($text, "tg://user?id=$userId"); - } - - /** - * Formato: Emoji personalizado - */ - public static function emoji(string $emoji, string $emojiId): string - { - if (!self::isHtml()) { - return $emoji; - } - self::sanitize($emoji); - return "$emoji"; - } - - /** - * Formato: Código en línea - */ - public static function inlineCode(string $text): string - { - if (!self::isHtml()) { - return "`$text`"; - } - $text = self::sanitize($text); - return "$text"; - } - - /** - * Formato: Bloque de código - */ - public static function codeBlock(string $text, string $language = ''): string - { - if (!self::isHtml()) { - return "```$language\n$text\n```"; - } - $text = self::sanitize($text); - return $language - ? "
$text
" - : "
$text
"; - } - - /** - * Formato: Cita en bloque - */ - public static function blockQuote(string $text): string - { - return self::isHtml() ? "
$text
" : "> $text"; - } - - /** - * Formato: Cita expandible - */ - public static function expandableBlockQuote(string $text): string - { - return self::isHtml() ? "
$text
" : ">$text"; - } - - /** - * Formato: Tiempo/Timestamp - * - * @param int $unix Timestamp unix - * @param string $format Formato: 'wDT', 't', 'r', o vacío - * - * r: Muestra la hora en relación con la hora actual. No se puede combinar - * con ningún otro carácter de control. - * w: Muestra el día de la semana en el idioma del usuario. - * d: Muestra la fecha en formato abreviado (por ejemplo, “17.03.22”). - * D: Muestra la fecha en formato largo (por ejemplo, “17 de marzo de 2022”). - * t: Muestra la hora en formato abreviado (por ejemplo, “22:45”). - * T: Muestra la hora en formato largo (por ejemplo, “22:45:00”). - - */ - public static function time(int $unix, string $format = ''): string - { - if (!self::isHtml()) { - // MarkdownV2: ![texto](tg://time?unix=XXX&format=Y) - $url = "tg://time?unix=$unix" . ($format ? "&format=$format" : ''); - return "![fecha]($url)"; - } - // HTML: texto - return $format - ? "fecha" - : "fecha"; - } - - /** - * Sanear texto - */ - private static function sanitize(string $text): string - { - return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); - } - - private static function isHtml(): bool - { - return Config::get('parse_mode') == 'HTML'; - } -} diff --git a/src/Telegram/Text.php b/src/Telegram/Text.php new file mode 100644 index 0000000..76461c1 --- /dev/null +++ b/src/Telegram/Text.php @@ -0,0 +1,241 @@ +$text" : "*$text*"; + } + + public static function italic(string $text): string + { + return self::isHtml() ? "$text" : '_' . $text . '_'; + } + + public static function underline(string $text): string + { + return self::isHtml() ? "$text" : '__' . $text . '__'; + } + + public static function strikethrough(string $text): string + { + return self::isHtml() ? "$text" : "~$text~"; + } + + public static function spoiler(string $text): string + { + return self::isHtml() ? "$text" : "||$text||"; + } + + public static function link(string $text, string $url): string + { + if (!self::isHtml()) { + return "[$text]($url)"; + } + $text = self::sanitize($text, 'link'); + return "$text"; + } + + public static function mention(string $text, int $userId): string + { + return self::link($text, "tg://user?id=$userId"); + } + + public static function emoji(string $emoji, string $emojiId): string + { + if (!self::isHtml()) { + return $emoji; + } + self::sanitize($emoji); + return "$emoji"; + } + + public static function inlineCode(string $text): string + { + if (!self::isHtml()) { + return "`$text`"; + } + $text = self::sanitize($text); + return "$text"; + } + + public static function codeBlock(string $text, string $language = ''): string + { + if (!self::isHtml()) { + return "```$language\n$text\n```"; + } + $text = self::sanitize($text); + return $language + ? "
$text
" + : "
$text
"; + } + + public static function blockQuote(string $text): string + { + return self::isHtml() ? "
$text
" : "> $text"; + } + + public static function expandableBlockQuote(string $text): string + { + return self::isHtml() ? "
$text
" : ">$text"; + } + + public static function time(int $unix, string $format = ''): string + { + if (!self::isHtml()) { + $url = "tg://time?unix=$unix" . ($format ? "&format=$format" : ''); + return "![fecha]($url)"; + } + return $format + ? "fecha" + : "fecha"; + } + + private static function sanitize(string $text): string + { + return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); + } + + private static function isHtml(): bool + { + return Config::get('parse_mode') == 'HTML'; + } + + private static function richText(string|RichText $text): string|RichText + { + return $text instanceof RichText ? $text : $text; + } + + public static function richBold(string|RichText $text): RichTextBold + { + return new RichTextBold(['type' => 'bold', 'text' => self::richText($text)]); + } + + public static function richItalic(string|RichText $text): RichTextItalic + { + return new RichTextItalic(['type' => 'italic', 'text' => self::richText($text)]); + } + + public static function richUnderline(string|RichText $text): RichTextUnderline + { + return new RichTextUnderline(['type' => 'underline', 'text' => self::richText($text)]); + } + + public static function richStrikethrough(string|RichText $text): RichTextStrikethrough + { + return new RichTextStrikethrough(['type' => 'strikethrough', 'text' => self::richText($text)]); + } + + public static function richSpoiler(string|RichText $text): RichTextSpoiler + { + return new RichTextSpoiler(['type' => 'spoiler', 'text' => self::richText($text)]); + } + + public static function richCode(string|RichText $text): RichTextCode + { + return new RichTextCode(['type' => 'code', 'text' => self::richText($text)]); + } + + public static function richUrl(string|RichText $text, string $url): RichTextUrl + { + return new RichTextUrl(['type' => 'url', 'text' => self::richText($text), 'url' => $url]); + } + + public static function richEmail(string|RichText $text): RichTextEmailAddress + { + return new RichTextEmailAddress(['type' => 'email_address', 'text' => self::richText($text)]); + } + + public static function richPhone(string|RichText $text): RichTextPhoneNumber + { + return new RichTextPhoneNumber(['type' => 'phone_number', 'text' => self::richText($text)]); + } + + public static function richMention(string|RichText $text, string $username): RichTextMention + { + return new RichTextMention(['type' => 'mention', 'text' => self::richText($text), 'username' => $username]); + } + + public static function richTextMention(string|RichText $text, User|int $user): RichTextTextMention + { + $userData = $user instanceof User ? $user : new User(['id' => $user, 'is_bot' => false, 'first_name' => '']); + return new RichTextTextMention(['type' => 'text_mention', 'text' => self::richText($text), 'user' => $userData]); + } + + public static function richCustomEmoji(string $emoji, string $id): RichTextCustomEmoji + { + return new RichTextCustomEmoji(['type' => 'custom_emoji', 'custom_emoji_id' => $id, 'alternative_text' => $emoji]); + } + + public static function richSubscript(string|RichText $text): RichTextSubscript + { + return new RichTextSubscript(['type' => 'subscript', 'text' => self::richText($text)]); + } + + public static function richSuperscript(string|RichText $text): RichTextSuperscript + { + return new RichTextSuperscript(['type' => 'superscript', 'text' => self::richText($text)]); + } + + public static function richMarked(string|RichText $text): RichTextMarked + { + return new RichTextMarked(['type' => 'marked', 'text' => self::richText($text)]); + } + + public static function richDatetime(int $unix): RichTextDateTime + { + return new RichTextDateTime(['type' => 'datetime', 'unix' => $unix]); + } + + public static function richMath(string $expression): RichTextMathematicalExpression + { + return new RichTextMathematicalExpression(['type' => 'mathematical_expression', 'expression' => $expression]); + } + + public static function richAnchor(string $name): RichTextAnchor + { + return new RichTextAnchor(['type' => 'anchor', 'name' => $name]); + } + + public static function richAnchorLink(string|RichText $text, string $anchor): RichTextAnchorLink + { + return new RichTextAnchorLink(['type' => 'anchor_link', 'text' => self::richText($text), 'anchor' => $anchor]); + } + + public static function richReference(string|RichText $text, string $reference): RichTextReference + { + return new RichTextReference(['type' => 'reference', 'text' => self::richText($text), 'reference' => $reference]); + } + + public static function richReferenceLink(string|RichText $text, string $reference): RichTextReferenceLink + { + return new RichTextReferenceLink(['type' => 'reference_link', 'text' => self::richText($text), 'reference' => $reference]); + } +} diff --git a/tests/Unit/KeyboardTest.php b/tests/Unit/KeyboardTest.php index 0b1683b..a56688c 100644 --- a/tests/Unit/KeyboardTest.php +++ b/tests/Unit/KeyboardTest.php @@ -3,8 +3,8 @@ namespace Al3x5\xBot\Tests\Unit; use Al3x5\xBot\Telegram\Factories\Keyboard; -use Al3x5\xBot\Telegram\Factories\InlineButton; -use Al3x5\xBot\Telegram\Factories\ReplyButton; +use Al3x5\xBot\Telegram\Factories\Keyboard\InlineButton; +use Al3x5\xBot\Telegram\Factories\Keyboard\ReplyButton; use Al3x5\xBot\Telegram\Entities\InlineKeyboardMarkup; use Al3x5\xBot\Telegram\Entities\ReplyKeyboardMarkup; use Al3x5\xBot\Telegram\Entities\ReplyKeyboardRemove; @@ -19,14 +19,14 @@ public function testInlineReturnsInlineKeyboardInstance(): void { $keyboard = Keyboard::inline(); - $this->assertInstanceOf(\Al3x5\xBot\Telegram\Factories\Inline::class, $keyboard); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Factories\Keyboard\Inline::class, $keyboard); } public function testReplyReturnsReplyKeyboardInstance(): void { $keyboard = Keyboard::reply(); - $this->assertInstanceOf(\Al3x5\xBot\Telegram\Factories\Reply::class, $keyboard); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Factories\Keyboard\Reply::class, $keyboard); } public function testRemoveReturnsReplyKeyboardRemove(): void diff --git a/tests/Unit/FormatHelperTest.php b/tests/Unit/TextTest.php similarity index 54% rename from tests/Unit/FormatHelperTest.php rename to tests/Unit/TextTest.php index fcd93c0..89b6a9e 100644 --- a/tests/Unit/FormatHelperTest.php +++ b/tests/Unit/TextTest.php @@ -3,10 +3,10 @@ namespace Al3x5\xBot\Tests\Unit; use Al3x5\xBot\Config; -use Al3x5\xBot\Telegram\FormatHelper; +use Al3x5\xBot\Telegram\Text; use PHPUnit\Framework\TestCase; -class FormatHelperTest extends TestCase +class TextTest extends TestCase { public static function setUpBeforeClass(): void { @@ -25,79 +25,108 @@ public static function setUpBeforeClass(): void public function testBold(): void { - $result = FormatHelper::bold('Hello'); + $result = Text::bold('Hello'); $this->assertEquals('Hello', $result); } public function testItalic(): void { - $result = FormatHelper::italic('Hello'); + $result = Text::italic('Hello'); $this->assertEquals('Hello', $result); } public function testUnderline(): void { - $result = FormatHelper::underline('Hello'); + $result = Text::underline('Hello'); $this->assertEquals('Hello', $result); } public function testStrikethrough(): void { - $result = FormatHelper::strikethrough('Hello'); + $result = Text::strikethrough('Hello'); $this->assertEquals('Hello', $result); } public function testSpoiler(): void { - $result = FormatHelper::spoiler('Hello'); + $result = Text::spoiler('Hello'); $this->assertEquals('Hello', $result); } public function testLink(): void { - $result = FormatHelper::link('Click here', 'https://example.com'); + $result = Text::link('Click here', 'https://example.com'); $this->assertEquals('Click here', $result); } public function testMention(): void { - $result = FormatHelper::mention('John', 123456); + $result = Text::mention('John', 123456); $this->assertEquals('John', $result); } public function testEmoji(): void { - $result = FormatHelper::emoji('😀', '123456789'); + $result = Text::emoji('😀', '123456789'); $this->assertEquals('😀', $result); } public function testInlineCode(): void { - $result = FormatHelper::inlineCode('code'); + $result = Text::inlineCode('code'); $this->assertEquals('code', $result); } public function testCodeBlockWithoutLanguage(): void { - $result = FormatHelper::codeBlock('code'); + $result = Text::codeBlock('code'); $this->assertEquals('
code
', $result); } public function testCodeBlockWithLanguage(): void { - $result = FormatHelper::codeBlock('code', 'php'); + $result = Text::codeBlock('code', 'php'); $this->assertEquals('
code
', $result); } public function testBlockQuote(): void { - $result = FormatHelper::blockQuote('Quote'); + $result = Text::blockQuote('Quote'); $this->assertEquals('
Quote
', $result); } public function testExpandableBlockQuote(): void { - $result = FormatHelper::expandableBlockQuote('Quote'); + $result = Text::expandableBlockQuote('Quote'); $this->assertEquals('
Quote
', $result); } -} \ No newline at end of file + + public function testRichBoldReturnsRichTextBold(): void + { + $result = Text::richBold('hello'); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Entities\RichTextBold::class, $result); + $this->assertEquals('bold', $result->getType()); + } + + public function testRichItalicReturnsRichTextItalic(): void + { + $result = Text::richItalic('hello'); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Entities\RichTextItalic::class, $result); + $this->assertEquals('italic', $result->getType()); + } + + public function testRichUrlReturnsRichTextUrl(): void + { + $result = Text::richUrl('click', 'https://example.com'); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Entities\RichTextUrl::class, $result); + $this->assertEquals('url', $result->getType()); + $this->assertEquals('https://example.com', $result->getUrl()); + } + + public function testRichCodeReturnsRichTextCode(): void + { + $result = Text::richCode('echo hello'); + $this->assertInstanceOf(\Al3x5\xBot\Telegram\Entities\RichTextCode::class, $result); + $this->assertEquals('code', $result->getType()); + } +} From f6a3090f17436ec904573e9cb1bf35f661ba1411 Mon Sep 17 00:00:00 2001 From: al3x5dev Date: Tue, 28 Jul 2026 01:08:10 -0400 Subject: [PATCH 3/4] fix: correct entity inheritance for all polymorphic Telegram types - Regenerate all entity subclasses via updated devkit so they extend their correct base type (RichText*, InputRichBlock*, RichBlock*, BackgroundType*, ChatMember*, MessageOrigin*, InlineQueryResult*, InputMedia*, etc.) instead of Entity directly - This prevents PHP type coercion in union hints (e.g. string|RichText|array was silently converting RichTextBold to its JSON string representation) - Bump version to 4.6.0 --- src/Bot.php | 2 +- src/Telegram/Entities/BackgroundFillFreeformGradient.php | 2 +- src/Telegram/Entities/BackgroundFillGradient.php | 2 +- src/Telegram/Entities/BackgroundFillSolid.php | 2 +- src/Telegram/Entities/BackgroundTypeChatTheme.php | 2 +- src/Telegram/Entities/BackgroundTypeFill.php | 2 +- src/Telegram/Entities/BackgroundTypePattern.php | 2 +- src/Telegram/Entities/BackgroundTypeWallpaper.php | 2 +- .../Entities/BotCommandScopeAllChatAdministrators.php | 2 +- src/Telegram/Entities/BotCommandScopeAllGroupChats.php | 2 +- src/Telegram/Entities/BotCommandScopeAllPrivateChats.php | 2 +- src/Telegram/Entities/BotCommandScopeChat.php | 6 ++---- src/Telegram/Entities/BotCommandScopeChatAdministrators.php | 6 ++---- src/Telegram/Entities/BotCommandScopeChatMember.php | 6 ++---- src/Telegram/Entities/BotCommandScopeDefault.php | 2 +- src/Telegram/Entities/ChatBoostSourceGiftCode.php | 2 +- src/Telegram/Entities/ChatBoostSourceGiveaway.php | 2 +- src/Telegram/Entities/ChatBoostSourcePremium.php | 2 +- src/Telegram/Entities/ChatMemberAdministrator.php | 2 +- src/Telegram/Entities/ChatMemberBanned.php | 2 +- src/Telegram/Entities/ChatMemberLeft.php | 2 +- src/Telegram/Entities/ChatMemberMember.php | 2 +- src/Telegram/Entities/ChatMemberOwner.php | 2 +- src/Telegram/Entities/ChatMemberRestricted.php | 2 +- src/Telegram/Entities/InaccessibleMessage.php | 2 +- src/Telegram/Entities/InlineQueryResultArticle.php | 2 +- src/Telegram/Entities/InlineQueryResultAudio.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedAudio.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedDocument.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedGif.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedMpeg4Gif.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedPhoto.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedSticker.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedVideo.php | 2 +- src/Telegram/Entities/InlineQueryResultCachedVoice.php | 2 +- src/Telegram/Entities/InlineQueryResultContact.php | 2 +- src/Telegram/Entities/InlineQueryResultDocument.php | 2 +- src/Telegram/Entities/InlineQueryResultGame.php | 2 +- src/Telegram/Entities/InlineQueryResultGif.php | 2 +- src/Telegram/Entities/InlineQueryResultLocation.php | 2 +- src/Telegram/Entities/InlineQueryResultMpeg4Gif.php | 2 +- src/Telegram/Entities/InlineQueryResultPhoto.php | 2 +- src/Telegram/Entities/InlineQueryResultVenue.php | 2 +- src/Telegram/Entities/InlineQueryResultVideo.php | 2 +- src/Telegram/Entities/InlineQueryResultVoice.php | 2 +- src/Telegram/Entities/InputContactMessageContent.php | 2 +- src/Telegram/Entities/InputInvoiceMessageContent.php | 2 +- src/Telegram/Entities/InputLocationMessageContent.php | 2 +- src/Telegram/Entities/InputMediaAnimation.php | 2 +- src/Telegram/Entities/InputMediaAudio.php | 2 +- src/Telegram/Entities/InputMediaDocument.php | 2 +- src/Telegram/Entities/InputMediaLink.php | 2 +- src/Telegram/Entities/InputMediaLivePhoto.php | 2 +- src/Telegram/Entities/InputMediaLocation.php | 2 +- src/Telegram/Entities/InputMediaPhoto.php | 2 +- src/Telegram/Entities/InputMediaSticker.php | 2 +- src/Telegram/Entities/InputMediaVenue.php | 2 +- src/Telegram/Entities/InputMediaVideo.php | 2 +- src/Telegram/Entities/InputPaidMediaLivePhoto.php | 2 +- src/Telegram/Entities/InputPaidMediaPhoto.php | 2 +- src/Telegram/Entities/InputPaidMediaVideo.php | 2 +- src/Telegram/Entities/InputProfilePhotoAnimated.php | 2 +- src/Telegram/Entities/InputProfilePhotoStatic.php | 2 +- src/Telegram/Entities/InputRichBlockAnchor.php | 2 +- src/Telegram/Entities/InputRichBlockAnimation.php | 2 +- src/Telegram/Entities/InputRichBlockAudio.php | 2 +- src/Telegram/Entities/InputRichBlockBlockQuotation.php | 2 +- src/Telegram/Entities/InputRichBlockCollage.php | 2 +- src/Telegram/Entities/InputRichBlockDetails.php | 2 +- src/Telegram/Entities/InputRichBlockDivider.php | 2 +- src/Telegram/Entities/InputRichBlockFooter.php | 2 +- src/Telegram/Entities/InputRichBlockList.php | 2 +- src/Telegram/Entities/InputRichBlockMap.php | 2 +- .../Entities/InputRichBlockMathematicalExpression.php | 2 +- src/Telegram/Entities/InputRichBlockParagraph.php | 2 +- src/Telegram/Entities/InputRichBlockPhoto.php | 2 +- src/Telegram/Entities/InputRichBlockPreformatted.php | 2 +- src/Telegram/Entities/InputRichBlockPullQuotation.php | 2 +- src/Telegram/Entities/InputRichBlockSectionHeading.php | 2 +- src/Telegram/Entities/InputRichBlockSlideshow.php | 2 +- src/Telegram/Entities/InputRichBlockTable.php | 2 +- src/Telegram/Entities/InputRichBlockThinking.php | 2 +- src/Telegram/Entities/InputRichBlockVideo.php | 2 +- src/Telegram/Entities/InputRichBlockVoiceNote.php | 2 +- src/Telegram/Entities/InputRichMessageContent.php | 2 +- src/Telegram/Entities/InputRichMessageMedia.php | 2 +- src/Telegram/Entities/InputStoryContentPhoto.php | 2 +- src/Telegram/Entities/InputStoryContentVideo.php | 2 +- src/Telegram/Entities/InputTextMessageContent.php | 2 +- src/Telegram/Entities/InputVenueMessageContent.php | 2 +- src/Telegram/Entities/MenuButtonCommands.php | 2 +- src/Telegram/Entities/MenuButtonDefault.php | 2 +- src/Telegram/Entities/MenuButtonWebApp.php | 2 +- src/Telegram/Entities/Message.php | 2 +- src/Telegram/Entities/MessageOriginChannel.php | 2 +- src/Telegram/Entities/MessageOriginChat.php | 2 +- src/Telegram/Entities/MessageOriginHiddenUser.php | 2 +- src/Telegram/Entities/MessageOriginUser.php | 2 +- src/Telegram/Entities/OwnedGiftRegular.php | 2 +- src/Telegram/Entities/OwnedGiftUnique.php | 2 +- src/Telegram/Entities/PaidMediaLivePhoto.php | 2 +- src/Telegram/Entities/PaidMediaPhoto.php | 2 +- src/Telegram/Entities/PaidMediaPreview.php | 2 +- src/Telegram/Entities/PaidMediaVideo.php | 2 +- src/Telegram/Entities/PassportElementErrorDataField.php | 2 +- src/Telegram/Entities/PassportElementErrorFile.php | 2 +- src/Telegram/Entities/PassportElementErrorFiles.php | 2 +- src/Telegram/Entities/PassportElementErrorFrontSide.php | 2 +- src/Telegram/Entities/PassportElementErrorReverseSide.php | 2 +- src/Telegram/Entities/PassportElementErrorSelfie.php | 2 +- .../Entities/PassportElementErrorTranslationFile.php | 2 +- .../Entities/PassportElementErrorTranslationFiles.php | 2 +- src/Telegram/Entities/PassportElementErrorUnspecified.php | 2 +- src/Telegram/Entities/ReactionTypeCustomEmoji.php | 2 +- src/Telegram/Entities/ReactionTypeEmoji.php | 2 +- src/Telegram/Entities/ReactionTypePaid.php | 2 +- src/Telegram/Entities/RevenueWithdrawalStateFailed.php | 2 +- src/Telegram/Entities/RevenueWithdrawalStatePending.php | 2 +- src/Telegram/Entities/RevenueWithdrawalStateSucceeded.php | 2 +- src/Telegram/Entities/RichBlockAnchor.php | 2 +- src/Telegram/Entities/RichBlockAnimation.php | 2 +- src/Telegram/Entities/RichBlockAudio.php | 2 +- src/Telegram/Entities/RichBlockBlockQuotation.php | 2 +- src/Telegram/Entities/RichBlockCollage.php | 2 +- src/Telegram/Entities/RichBlockDetails.php | 2 +- src/Telegram/Entities/RichBlockDivider.php | 2 +- src/Telegram/Entities/RichBlockFooter.php | 2 +- src/Telegram/Entities/RichBlockList.php | 2 +- src/Telegram/Entities/RichBlockMap.php | 2 +- src/Telegram/Entities/RichBlockMathematicalExpression.php | 2 +- src/Telegram/Entities/RichBlockParagraph.php | 2 +- src/Telegram/Entities/RichBlockPhoto.php | 2 +- src/Telegram/Entities/RichBlockPreformatted.php | 2 +- src/Telegram/Entities/RichBlockPullQuotation.php | 2 +- src/Telegram/Entities/RichBlockSectionHeading.php | 2 +- src/Telegram/Entities/RichBlockSlideshow.php | 2 +- src/Telegram/Entities/RichBlockTable.php | 2 +- src/Telegram/Entities/RichBlockThinking.php | 2 +- src/Telegram/Entities/RichBlockVideo.php | 2 +- src/Telegram/Entities/RichBlockVoiceNote.php | 2 +- src/Telegram/Entities/StoryAreaTypeLink.php | 2 +- src/Telegram/Entities/StoryAreaTypeLocation.php | 2 +- src/Telegram/Entities/StoryAreaTypeSuggestedReaction.php | 2 +- src/Telegram/Entities/StoryAreaTypeUniqueGift.php | 2 +- src/Telegram/Entities/StoryAreaTypeWeather.php | 2 +- .../Entities/TransactionPartnerAffiliateProgram.php | 2 +- src/Telegram/Entities/TransactionPartnerChat.php | 2 +- src/Telegram/Entities/TransactionPartnerFragment.php | 2 +- src/Telegram/Entities/TransactionPartnerOther.php | 2 +- src/Telegram/Entities/TransactionPartnerTelegramAds.php | 2 +- src/Telegram/Entities/TransactionPartnerTelegramApi.php | 2 +- src/Telegram/Entities/TransactionPartnerUser.php | 2 +- 152 files changed, 155 insertions(+), 161 deletions(-) diff --git a/src/Bot.php b/src/Bot.php index 5cf1df2..14ba3c4 100644 --- a/src/Bot.php +++ b/src/Bot.php @@ -18,7 +18,7 @@ class Bot { public const NAME = 'xBot'; - public const VERSION = '4.5.0'; + public const VERSION = '4.6.0'; public ?Update $update = null; diff --git a/src/Telegram/Entities/BackgroundFillFreeformGradient.php b/src/Telegram/Entities/BackgroundFillFreeformGradient.php index ae6c5bf..dbb31a9 100644 --- a/src/Telegram/Entities/BackgroundFillFreeformGradient.php +++ b/src/Telegram/Entities/BackgroundFillFreeformGradient.php @@ -9,7 +9,7 @@ * @property string $type * @property array $colors */ -class BackgroundFillFreeformGradient extends Entity +class BackgroundFillFreeformGradient extends BackgroundFill { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundFillGradient.php b/src/Telegram/Entities/BackgroundFillGradient.php index 5e129c0..2f857fd 100644 --- a/src/Telegram/Entities/BackgroundFillGradient.php +++ b/src/Telegram/Entities/BackgroundFillGradient.php @@ -11,7 +11,7 @@ * @property int $bottom_color * @property int $rotation_angle */ -class BackgroundFillGradient extends Entity +class BackgroundFillGradient extends BackgroundFill { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundFillSolid.php b/src/Telegram/Entities/BackgroundFillSolid.php index affde4d..5cb65a0 100644 --- a/src/Telegram/Entities/BackgroundFillSolid.php +++ b/src/Telegram/Entities/BackgroundFillSolid.php @@ -9,7 +9,7 @@ * @property string $type * @property int $color */ -class BackgroundFillSolid extends Entity +class BackgroundFillSolid extends BackgroundFill { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundTypeChatTheme.php b/src/Telegram/Entities/BackgroundTypeChatTheme.php index 7d1d73b..9372ec3 100644 --- a/src/Telegram/Entities/BackgroundTypeChatTheme.php +++ b/src/Telegram/Entities/BackgroundTypeChatTheme.php @@ -9,7 +9,7 @@ * @property string $type * @property string $theme_name */ -class BackgroundTypeChatTheme extends Entity +class BackgroundTypeChatTheme extends BackgroundType { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundTypeFill.php b/src/Telegram/Entities/BackgroundTypeFill.php index 4c2bf87..501ea31 100644 --- a/src/Telegram/Entities/BackgroundTypeFill.php +++ b/src/Telegram/Entities/BackgroundTypeFill.php @@ -10,7 +10,7 @@ * @property BackgroundFill $fill * @property int $dark_theme_dimming */ -class BackgroundTypeFill extends Entity +class BackgroundTypeFill extends BackgroundType { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundTypePattern.php b/src/Telegram/Entities/BackgroundTypePattern.php index bfab0d5..71e7052 100644 --- a/src/Telegram/Entities/BackgroundTypePattern.php +++ b/src/Telegram/Entities/BackgroundTypePattern.php @@ -13,7 +13,7 @@ * @property bool $is_inverted * @property bool $is_moving */ -class BackgroundTypePattern extends Entity +class BackgroundTypePattern extends BackgroundType { protected function setEntities(): array diff --git a/src/Telegram/Entities/BackgroundTypeWallpaper.php b/src/Telegram/Entities/BackgroundTypeWallpaper.php index f74f19d..89519be 100644 --- a/src/Telegram/Entities/BackgroundTypeWallpaper.php +++ b/src/Telegram/Entities/BackgroundTypeWallpaper.php @@ -12,7 +12,7 @@ * @property bool $is_blurred * @property bool $is_moving */ -class BackgroundTypeWallpaper extends Entity +class BackgroundTypeWallpaper extends BackgroundType { protected function setEntities(): array diff --git a/src/Telegram/Entities/BotCommandScopeAllChatAdministrators.php b/src/Telegram/Entities/BotCommandScopeAllChatAdministrators.php index 97a193a..0fd0e2d 100644 --- a/src/Telegram/Entities/BotCommandScopeAllChatAdministrators.php +++ b/src/Telegram/Entities/BotCommandScopeAllChatAdministrators.php @@ -8,7 +8,7 @@ * BotCommandScopeAllChatAdministrators Entity * @property string $type */ -class BotCommandScopeAllChatAdministrators extends Entity +class BotCommandScopeAllChatAdministrators extends BotCommandScope { protected function setEntities(): array diff --git a/src/Telegram/Entities/BotCommandScopeAllGroupChats.php b/src/Telegram/Entities/BotCommandScopeAllGroupChats.php index 3de97e0..d7190ac 100644 --- a/src/Telegram/Entities/BotCommandScopeAllGroupChats.php +++ b/src/Telegram/Entities/BotCommandScopeAllGroupChats.php @@ -8,7 +8,7 @@ * BotCommandScopeAllGroupChats Entity * @property string $type */ -class BotCommandScopeAllGroupChats extends Entity +class BotCommandScopeAllGroupChats extends BotCommandScope { protected function setEntities(): array diff --git a/src/Telegram/Entities/BotCommandScopeAllPrivateChats.php b/src/Telegram/Entities/BotCommandScopeAllPrivateChats.php index f6c6f63..70b5162 100644 --- a/src/Telegram/Entities/BotCommandScopeAllPrivateChats.php +++ b/src/Telegram/Entities/BotCommandScopeAllPrivateChats.php @@ -8,7 +8,7 @@ * BotCommandScopeAllPrivateChats Entity * @property string $type */ -class BotCommandScopeAllPrivateChats extends Entity +class BotCommandScopeAllPrivateChats extends BotCommandScope { protected function setEntities(): array diff --git a/src/Telegram/Entities/BotCommandScopeChat.php b/src/Telegram/Entities/BotCommandScopeChat.php index 18909d0..3f8c653 100644 --- a/src/Telegram/Entities/BotCommandScopeChat.php +++ b/src/Telegram/Entities/BotCommandScopeChat.php @@ -9,13 +9,11 @@ * @property string $type * @property int|string $chat_id */ -class BotCommandScopeChat extends Entity +class BotCommandScopeChat extends BotCommandScope { protected function setEntities(): array { - return [ - 'chat_id' => int|string::class, - ]; + return []; } } diff --git a/src/Telegram/Entities/BotCommandScopeChatAdministrators.php b/src/Telegram/Entities/BotCommandScopeChatAdministrators.php index 589b5b4..1fec114 100644 --- a/src/Telegram/Entities/BotCommandScopeChatAdministrators.php +++ b/src/Telegram/Entities/BotCommandScopeChatAdministrators.php @@ -9,13 +9,11 @@ * @property string $type * @property int|string $chat_id */ -class BotCommandScopeChatAdministrators extends Entity +class BotCommandScopeChatAdministrators extends BotCommandScope { protected function setEntities(): array { - return [ - 'chat_id' => int|string::class, - ]; + return []; } } diff --git a/src/Telegram/Entities/BotCommandScopeChatMember.php b/src/Telegram/Entities/BotCommandScopeChatMember.php index b048eb2..c4b742d 100644 --- a/src/Telegram/Entities/BotCommandScopeChatMember.php +++ b/src/Telegram/Entities/BotCommandScopeChatMember.php @@ -10,13 +10,11 @@ * @property int|string $chat_id * @property int $user_id */ -class BotCommandScopeChatMember extends Entity +class BotCommandScopeChatMember extends BotCommandScope { protected function setEntities(): array { - return [ - 'chat_id' => int|string::class, - ]; + return []; } } diff --git a/src/Telegram/Entities/BotCommandScopeDefault.php b/src/Telegram/Entities/BotCommandScopeDefault.php index 40c8037..27ef50b 100644 --- a/src/Telegram/Entities/BotCommandScopeDefault.php +++ b/src/Telegram/Entities/BotCommandScopeDefault.php @@ -8,7 +8,7 @@ * BotCommandScopeDefault Entity * @property string $type */ -class BotCommandScopeDefault extends Entity +class BotCommandScopeDefault extends BotCommandScope { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatBoostSourceGiftCode.php b/src/Telegram/Entities/ChatBoostSourceGiftCode.php index 77cdab3..259e42f 100644 --- a/src/Telegram/Entities/ChatBoostSourceGiftCode.php +++ b/src/Telegram/Entities/ChatBoostSourceGiftCode.php @@ -9,7 +9,7 @@ * @property string $source * @property User $user */ -class ChatBoostSourceGiftCode extends Entity +class ChatBoostSourceGiftCode extends ChatBoostSource { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatBoostSourceGiveaway.php b/src/Telegram/Entities/ChatBoostSourceGiveaway.php index c5299c7..df7fad9 100644 --- a/src/Telegram/Entities/ChatBoostSourceGiveaway.php +++ b/src/Telegram/Entities/ChatBoostSourceGiveaway.php @@ -12,7 +12,7 @@ * @property int $prize_star_count * @property bool $is_unclaimed */ -class ChatBoostSourceGiveaway extends Entity +class ChatBoostSourceGiveaway extends ChatBoostSource { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatBoostSourcePremium.php b/src/Telegram/Entities/ChatBoostSourcePremium.php index 423974f..aae578c 100644 --- a/src/Telegram/Entities/ChatBoostSourcePremium.php +++ b/src/Telegram/Entities/ChatBoostSourcePremium.php @@ -9,7 +9,7 @@ * @property string $source * @property User $user */ -class ChatBoostSourcePremium extends Entity +class ChatBoostSourcePremium extends ChatBoostSource { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberAdministrator.php b/src/Telegram/Entities/ChatMemberAdministrator.php index 63fa61b..811b7e7 100644 --- a/src/Telegram/Entities/ChatMemberAdministrator.php +++ b/src/Telegram/Entities/ChatMemberAdministrator.php @@ -28,7 +28,7 @@ * @property bool $can_manage_tags * @property string $custom_title */ -class ChatMemberAdministrator extends Entity +class ChatMemberAdministrator extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberBanned.php b/src/Telegram/Entities/ChatMemberBanned.php index 4b8a167..8d36ef8 100644 --- a/src/Telegram/Entities/ChatMemberBanned.php +++ b/src/Telegram/Entities/ChatMemberBanned.php @@ -10,7 +10,7 @@ * @property User $user * @property int $until_date */ -class ChatMemberBanned extends Entity +class ChatMemberBanned extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberLeft.php b/src/Telegram/Entities/ChatMemberLeft.php index 6eaf95d..8b69c9c 100644 --- a/src/Telegram/Entities/ChatMemberLeft.php +++ b/src/Telegram/Entities/ChatMemberLeft.php @@ -9,7 +9,7 @@ * @property string $status * @property User $user */ -class ChatMemberLeft extends Entity +class ChatMemberLeft extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberMember.php b/src/Telegram/Entities/ChatMemberMember.php index 8aa66dc..c230c6c 100644 --- a/src/Telegram/Entities/ChatMemberMember.php +++ b/src/Telegram/Entities/ChatMemberMember.php @@ -11,7 +11,7 @@ * @property User $user * @property int $until_date */ -class ChatMemberMember extends Entity +class ChatMemberMember extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberOwner.php b/src/Telegram/Entities/ChatMemberOwner.php index f08fbd6..8c9733c 100644 --- a/src/Telegram/Entities/ChatMemberOwner.php +++ b/src/Telegram/Entities/ChatMemberOwner.php @@ -11,7 +11,7 @@ * @property bool $is_anonymous * @property string $custom_title */ -class ChatMemberOwner extends Entity +class ChatMemberOwner extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/ChatMemberRestricted.php b/src/Telegram/Entities/ChatMemberRestricted.php index e21aab1..c75331b 100644 --- a/src/Telegram/Entities/ChatMemberRestricted.php +++ b/src/Telegram/Entities/ChatMemberRestricted.php @@ -28,7 +28,7 @@ * @property bool $can_manage_topics * @property int $until_date */ -class ChatMemberRestricted extends Entity +class ChatMemberRestricted extends ChatMember { protected function setEntities(): array diff --git a/src/Telegram/Entities/InaccessibleMessage.php b/src/Telegram/Entities/InaccessibleMessage.php index d733069..6f86b9f 100644 --- a/src/Telegram/Entities/InaccessibleMessage.php +++ b/src/Telegram/Entities/InaccessibleMessage.php @@ -10,7 +10,7 @@ * @property int $message_id * @property int $date */ -class InaccessibleMessage extends Entity +class InaccessibleMessage extends MaybeInaccessibleMessage { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultArticle.php b/src/Telegram/Entities/InlineQueryResultArticle.php index 2c95f81..e612e44 100644 --- a/src/Telegram/Entities/InlineQueryResultArticle.php +++ b/src/Telegram/Entities/InlineQueryResultArticle.php @@ -17,7 +17,7 @@ * @property int $thumbnail_width * @property int $thumbnail_height */ -class InlineQueryResultArticle extends Entity +class InlineQueryResultArticle extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultAudio.php b/src/Telegram/Entities/InlineQueryResultAudio.php index 882b3e9..46faef1 100644 --- a/src/Telegram/Entities/InlineQueryResultAudio.php +++ b/src/Telegram/Entities/InlineQueryResultAudio.php @@ -18,7 +18,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultAudio extends Entity +class InlineQueryResultAudio extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedAudio.php b/src/Telegram/Entities/InlineQueryResultCachedAudio.php index 3f3d66d..2b35100 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedAudio.php +++ b/src/Telegram/Entities/InlineQueryResultCachedAudio.php @@ -15,7 +15,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedAudio extends Entity +class InlineQueryResultCachedAudio extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedDocument.php b/src/Telegram/Entities/InlineQueryResultCachedDocument.php index c0ef936..61fa05f 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedDocument.php +++ b/src/Telegram/Entities/InlineQueryResultCachedDocument.php @@ -17,7 +17,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedDocument extends Entity +class InlineQueryResultCachedDocument extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedGif.php b/src/Telegram/Entities/InlineQueryResultCachedGif.php index e006b9e..d8f5ad5 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedGif.php +++ b/src/Telegram/Entities/InlineQueryResultCachedGif.php @@ -17,7 +17,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedGif extends Entity +class InlineQueryResultCachedGif extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedMpeg4Gif.php b/src/Telegram/Entities/InlineQueryResultCachedMpeg4Gif.php index 65d298a..49d41ae 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedMpeg4Gif.php +++ b/src/Telegram/Entities/InlineQueryResultCachedMpeg4Gif.php @@ -17,7 +17,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedMpeg4Gif extends Entity +class InlineQueryResultCachedMpeg4Gif extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedPhoto.php b/src/Telegram/Entities/InlineQueryResultCachedPhoto.php index cf6ce75..f14e9b7 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedPhoto.php +++ b/src/Telegram/Entities/InlineQueryResultCachedPhoto.php @@ -18,7 +18,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedPhoto extends Entity +class InlineQueryResultCachedPhoto extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedSticker.php b/src/Telegram/Entities/InlineQueryResultCachedSticker.php index f637cc0..3fd5816 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedSticker.php +++ b/src/Telegram/Entities/InlineQueryResultCachedSticker.php @@ -12,7 +12,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedSticker extends Entity +class InlineQueryResultCachedSticker extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedVideo.php b/src/Telegram/Entities/InlineQueryResultCachedVideo.php index 139b62d..6c1c6f9 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedVideo.php +++ b/src/Telegram/Entities/InlineQueryResultCachedVideo.php @@ -18,7 +18,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedVideo extends Entity +class InlineQueryResultCachedVideo extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultCachedVoice.php b/src/Telegram/Entities/InlineQueryResultCachedVoice.php index e5ca228..4aa9e2a 100644 --- a/src/Telegram/Entities/InlineQueryResultCachedVoice.php +++ b/src/Telegram/Entities/InlineQueryResultCachedVoice.php @@ -16,7 +16,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultCachedVoice extends Entity +class InlineQueryResultCachedVoice extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultContact.php b/src/Telegram/Entities/InlineQueryResultContact.php index 5841430..e2fc245 100644 --- a/src/Telegram/Entities/InlineQueryResultContact.php +++ b/src/Telegram/Entities/InlineQueryResultContact.php @@ -18,7 +18,7 @@ * @property int $thumbnail_width * @property int $thumbnail_height */ -class InlineQueryResultContact extends Entity +class InlineQueryResultContact extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultDocument.php b/src/Telegram/Entities/InlineQueryResultDocument.php index ac164a7..9159782 100644 --- a/src/Telegram/Entities/InlineQueryResultDocument.php +++ b/src/Telegram/Entities/InlineQueryResultDocument.php @@ -21,7 +21,7 @@ * @property int $thumbnail_width * @property int $thumbnail_height */ -class InlineQueryResultDocument extends Entity +class InlineQueryResultDocument extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultGame.php b/src/Telegram/Entities/InlineQueryResultGame.php index ffa867d..ad322ba 100644 --- a/src/Telegram/Entities/InlineQueryResultGame.php +++ b/src/Telegram/Entities/InlineQueryResultGame.php @@ -11,7 +11,7 @@ * @property string $game_short_name * @property InlineKeyboardMarkup $reply_markup */ -class InlineQueryResultGame extends Entity +class InlineQueryResultGame extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultGif.php b/src/Telegram/Entities/InlineQueryResultGif.php index e62b9d7..67370c9 100644 --- a/src/Telegram/Entities/InlineQueryResultGif.php +++ b/src/Telegram/Entities/InlineQueryResultGif.php @@ -22,7 +22,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultGif extends Entity +class InlineQueryResultGif extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultLocation.php b/src/Telegram/Entities/InlineQueryResultLocation.php index 9a65a47..45d9833 100644 --- a/src/Telegram/Entities/InlineQueryResultLocation.php +++ b/src/Telegram/Entities/InlineQueryResultLocation.php @@ -21,7 +21,7 @@ * @property int $thumbnail_width * @property int $thumbnail_height */ -class InlineQueryResultLocation extends Entity +class InlineQueryResultLocation extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultMpeg4Gif.php b/src/Telegram/Entities/InlineQueryResultMpeg4Gif.php index a5bc3e5..75f7ba8 100644 --- a/src/Telegram/Entities/InlineQueryResultMpeg4Gif.php +++ b/src/Telegram/Entities/InlineQueryResultMpeg4Gif.php @@ -22,7 +22,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultMpeg4Gif extends Entity +class InlineQueryResultMpeg4Gif extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultPhoto.php b/src/Telegram/Entities/InlineQueryResultPhoto.php index ad20692..9f91a27 100644 --- a/src/Telegram/Entities/InlineQueryResultPhoto.php +++ b/src/Telegram/Entities/InlineQueryResultPhoto.php @@ -21,7 +21,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultPhoto extends Entity +class InlineQueryResultPhoto extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultVenue.php b/src/Telegram/Entities/InlineQueryResultVenue.php index 4113459..3c2e797 100644 --- a/src/Telegram/Entities/InlineQueryResultVenue.php +++ b/src/Telegram/Entities/InlineQueryResultVenue.php @@ -22,7 +22,7 @@ * @property int $thumbnail_width * @property int $thumbnail_height */ -class InlineQueryResultVenue extends Entity +class InlineQueryResultVenue extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultVideo.php b/src/Telegram/Entities/InlineQueryResultVideo.php index 523b3d5..3e4964f 100644 --- a/src/Telegram/Entities/InlineQueryResultVideo.php +++ b/src/Telegram/Entities/InlineQueryResultVideo.php @@ -23,7 +23,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultVideo extends Entity +class InlineQueryResultVideo extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InlineQueryResultVoice.php b/src/Telegram/Entities/InlineQueryResultVoice.php index b13f4c3..190c673 100644 --- a/src/Telegram/Entities/InlineQueryResultVoice.php +++ b/src/Telegram/Entities/InlineQueryResultVoice.php @@ -17,7 +17,7 @@ * @property InlineKeyboardMarkup $reply_markup * @property InputMessageContent $input_message_content */ -class InlineQueryResultVoice extends Entity +class InlineQueryResultVoice extends InlineQueryResult { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputContactMessageContent.php b/src/Telegram/Entities/InputContactMessageContent.php index 9d133aa..c7a24b0 100644 --- a/src/Telegram/Entities/InputContactMessageContent.php +++ b/src/Telegram/Entities/InputContactMessageContent.php @@ -11,7 +11,7 @@ * @property string $last_name * @property string $vcard */ -class InputContactMessageContent extends Entity +class InputContactMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputInvoiceMessageContent.php b/src/Telegram/Entities/InputInvoiceMessageContent.php index 9279419..07bce64 100644 --- a/src/Telegram/Entities/InputInvoiceMessageContent.php +++ b/src/Telegram/Entities/InputInvoiceMessageContent.php @@ -27,7 +27,7 @@ * @property bool $send_email_to_provider * @property bool $is_flexible */ -class InputInvoiceMessageContent extends Entity +class InputInvoiceMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputLocationMessageContent.php b/src/Telegram/Entities/InputLocationMessageContent.php index 55ebd3c..32b1b94 100644 --- a/src/Telegram/Entities/InputLocationMessageContent.php +++ b/src/Telegram/Entities/InputLocationMessageContent.php @@ -13,7 +13,7 @@ * @property int $heading * @property int $proximity_alert_radius */ -class InputLocationMessageContent extends Entity +class InputLocationMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaAnimation.php b/src/Telegram/Entities/InputMediaAnimation.php index c3af22f..c9314af 100644 --- a/src/Telegram/Entities/InputMediaAnimation.php +++ b/src/Telegram/Entities/InputMediaAnimation.php @@ -18,7 +18,7 @@ * @property int $duration * @property bool $has_spoiler */ -class InputMediaAnimation extends Entity +class InputMediaAnimation extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaAudio.php b/src/Telegram/Entities/InputMediaAudio.php index ae3f1fe..bdb767a 100644 --- a/src/Telegram/Entities/InputMediaAudio.php +++ b/src/Telegram/Entities/InputMediaAudio.php @@ -16,7 +16,7 @@ * @property string $performer * @property string $title */ -class InputMediaAudio extends Entity +class InputMediaAudio extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaDocument.php b/src/Telegram/Entities/InputMediaDocument.php index 64097a3..e55ac67 100644 --- a/src/Telegram/Entities/InputMediaDocument.php +++ b/src/Telegram/Entities/InputMediaDocument.php @@ -14,7 +14,7 @@ * @property MessageEntity[] $caption_entities * @property bool $disable_content_type_detection */ -class InputMediaDocument extends Entity +class InputMediaDocument extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaLink.php b/src/Telegram/Entities/InputMediaLink.php index cf52ee7..8185c52 100644 --- a/src/Telegram/Entities/InputMediaLink.php +++ b/src/Telegram/Entities/InputMediaLink.php @@ -9,7 +9,7 @@ * @property string $type * @property string $url */ -class InputMediaLink extends Entity +class InputMediaLink extends InputPollOptionMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaLivePhoto.php b/src/Telegram/Entities/InputMediaLivePhoto.php index 4c0b9ed..b7b3dd0 100644 --- a/src/Telegram/Entities/InputMediaLivePhoto.php +++ b/src/Telegram/Entities/InputMediaLivePhoto.php @@ -15,7 +15,7 @@ * @property bool $show_caption_above_media * @property bool $has_spoiler */ -class InputMediaLivePhoto extends Entity +class InputMediaLivePhoto extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaLocation.php b/src/Telegram/Entities/InputMediaLocation.php index e57d5f1..d90562b 100644 --- a/src/Telegram/Entities/InputMediaLocation.php +++ b/src/Telegram/Entities/InputMediaLocation.php @@ -11,7 +11,7 @@ * @property float $longitude * @property float $horizontal_accuracy */ -class InputMediaLocation extends Entity +class InputMediaLocation extends InputPollOptionMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaPhoto.php b/src/Telegram/Entities/InputMediaPhoto.php index bb0faac..a939798 100644 --- a/src/Telegram/Entities/InputMediaPhoto.php +++ b/src/Telegram/Entities/InputMediaPhoto.php @@ -14,7 +14,7 @@ * @property bool $show_caption_above_media * @property bool $has_spoiler */ -class InputMediaPhoto extends Entity +class InputMediaPhoto extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaSticker.php b/src/Telegram/Entities/InputMediaSticker.php index 175160b..340a82c 100644 --- a/src/Telegram/Entities/InputMediaSticker.php +++ b/src/Telegram/Entities/InputMediaSticker.php @@ -10,7 +10,7 @@ * @property string $media * @property string $emoji */ -class InputMediaSticker extends Entity +class InputMediaSticker extends InputPollOptionMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaVenue.php b/src/Telegram/Entities/InputMediaVenue.php index 50e1e62..70a392b 100644 --- a/src/Telegram/Entities/InputMediaVenue.php +++ b/src/Telegram/Entities/InputMediaVenue.php @@ -16,7 +16,7 @@ * @property string $google_place_id * @property string $google_place_type */ -class InputMediaVenue extends Entity +class InputMediaVenue extends InputPollOptionMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputMediaVideo.php b/src/Telegram/Entities/InputMediaVideo.php index 4246687..4c390fa 100644 --- a/src/Telegram/Entities/InputMediaVideo.php +++ b/src/Telegram/Entities/InputMediaVideo.php @@ -21,7 +21,7 @@ * @property bool $supports_streaming * @property bool $has_spoiler */ -class InputMediaVideo extends Entity +class InputMediaVideo extends InputMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputPaidMediaLivePhoto.php b/src/Telegram/Entities/InputPaidMediaLivePhoto.php index 7de8021..58c8f10 100644 --- a/src/Telegram/Entities/InputPaidMediaLivePhoto.php +++ b/src/Telegram/Entities/InputPaidMediaLivePhoto.php @@ -10,7 +10,7 @@ * @property string $media * @property string $photo */ -class InputPaidMediaLivePhoto extends Entity +class InputPaidMediaLivePhoto extends InputPaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputPaidMediaPhoto.php b/src/Telegram/Entities/InputPaidMediaPhoto.php index 64b1a27..f28768a 100644 --- a/src/Telegram/Entities/InputPaidMediaPhoto.php +++ b/src/Telegram/Entities/InputPaidMediaPhoto.php @@ -9,7 +9,7 @@ * @property string $type * @property string $media */ -class InputPaidMediaPhoto extends Entity +class InputPaidMediaPhoto extends InputPaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputPaidMediaVideo.php b/src/Telegram/Entities/InputPaidMediaVideo.php index be46141..f302e34 100644 --- a/src/Telegram/Entities/InputPaidMediaVideo.php +++ b/src/Telegram/Entities/InputPaidMediaVideo.php @@ -16,7 +16,7 @@ * @property int $duration * @property bool $supports_streaming */ -class InputPaidMediaVideo extends Entity +class InputPaidMediaVideo extends InputPaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputProfilePhotoAnimated.php b/src/Telegram/Entities/InputProfilePhotoAnimated.php index cb2adcd..6911935 100644 --- a/src/Telegram/Entities/InputProfilePhotoAnimated.php +++ b/src/Telegram/Entities/InputProfilePhotoAnimated.php @@ -10,7 +10,7 @@ * @property string $animation * @property float $main_frame_timestamp */ -class InputProfilePhotoAnimated extends Entity +class InputProfilePhotoAnimated extends InputProfilePhoto { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputProfilePhotoStatic.php b/src/Telegram/Entities/InputProfilePhotoStatic.php index b72c32f..91ce485 100644 --- a/src/Telegram/Entities/InputProfilePhotoStatic.php +++ b/src/Telegram/Entities/InputProfilePhotoStatic.php @@ -9,7 +9,7 @@ * @property string $type * @property string $photo */ -class InputProfilePhotoStatic extends Entity +class InputProfilePhotoStatic extends InputProfilePhoto { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockAnchor.php b/src/Telegram/Entities/InputRichBlockAnchor.php index 2e6f84b..5f71848 100644 --- a/src/Telegram/Entities/InputRichBlockAnchor.php +++ b/src/Telegram/Entities/InputRichBlockAnchor.php @@ -9,7 +9,7 @@ * @property string $type * @property string $name */ -class InputRichBlockAnchor extends Entity +class InputRichBlockAnchor extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockAnimation.php b/src/Telegram/Entities/InputRichBlockAnimation.php index e210f54..dac7f80 100644 --- a/src/Telegram/Entities/InputRichBlockAnimation.php +++ b/src/Telegram/Entities/InputRichBlockAnimation.php @@ -10,7 +10,7 @@ * @property InputMediaAnimation $animation * @property RichBlockCaption $caption */ -class InputRichBlockAnimation extends Entity +class InputRichBlockAnimation extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockAudio.php b/src/Telegram/Entities/InputRichBlockAudio.php index 54a83e1..299e5d7 100644 --- a/src/Telegram/Entities/InputRichBlockAudio.php +++ b/src/Telegram/Entities/InputRichBlockAudio.php @@ -10,7 +10,7 @@ * @property InputMediaAudio $audio * @property RichBlockCaption $caption */ -class InputRichBlockAudio extends Entity +class InputRichBlockAudio extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockBlockQuotation.php b/src/Telegram/Entities/InputRichBlockBlockQuotation.php index 8b9f1df..b0a21e4 100644 --- a/src/Telegram/Entities/InputRichBlockBlockQuotation.php +++ b/src/Telegram/Entities/InputRichBlockBlockQuotation.php @@ -10,7 +10,7 @@ * @property InputRichBlock[] $blocks * @property RichText $credit */ -class InputRichBlockBlockQuotation extends Entity +class InputRichBlockBlockQuotation extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockCollage.php b/src/Telegram/Entities/InputRichBlockCollage.php index d4b6263..8935c75 100644 --- a/src/Telegram/Entities/InputRichBlockCollage.php +++ b/src/Telegram/Entities/InputRichBlockCollage.php @@ -10,7 +10,7 @@ * @property InputRichBlock[] $blocks * @property RichBlockCaption $caption */ -class InputRichBlockCollage extends Entity +class InputRichBlockCollage extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockDetails.php b/src/Telegram/Entities/InputRichBlockDetails.php index ce64d59..ac079b4 100644 --- a/src/Telegram/Entities/InputRichBlockDetails.php +++ b/src/Telegram/Entities/InputRichBlockDetails.php @@ -11,7 +11,7 @@ * @property InputRichBlock[] $blocks * @property bool $is_open */ -class InputRichBlockDetails extends Entity +class InputRichBlockDetails extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockDivider.php b/src/Telegram/Entities/InputRichBlockDivider.php index 0d84b19..3ff4fe3 100644 --- a/src/Telegram/Entities/InputRichBlockDivider.php +++ b/src/Telegram/Entities/InputRichBlockDivider.php @@ -8,7 +8,7 @@ * InputRichBlockDivider Entity * @property string $type */ -class InputRichBlockDivider extends Entity +class InputRichBlockDivider extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockFooter.php b/src/Telegram/Entities/InputRichBlockFooter.php index cac57a2..f385d87 100644 --- a/src/Telegram/Entities/InputRichBlockFooter.php +++ b/src/Telegram/Entities/InputRichBlockFooter.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class InputRichBlockFooter extends Entity +class InputRichBlockFooter extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockList.php b/src/Telegram/Entities/InputRichBlockList.php index 5f46222..fd75f44 100644 --- a/src/Telegram/Entities/InputRichBlockList.php +++ b/src/Telegram/Entities/InputRichBlockList.php @@ -9,7 +9,7 @@ * @property string $type * @property InputRichBlockListItem[] $items */ -class InputRichBlockList extends Entity +class InputRichBlockList extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockMap.php b/src/Telegram/Entities/InputRichBlockMap.php index 00e8098..e60c52a 100644 --- a/src/Telegram/Entities/InputRichBlockMap.php +++ b/src/Telegram/Entities/InputRichBlockMap.php @@ -13,7 +13,7 @@ * @property int $height * @property RichBlockCaption $caption */ -class InputRichBlockMap extends Entity +class InputRichBlockMap extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockMathematicalExpression.php b/src/Telegram/Entities/InputRichBlockMathematicalExpression.php index 38540ca..843da9f 100644 --- a/src/Telegram/Entities/InputRichBlockMathematicalExpression.php +++ b/src/Telegram/Entities/InputRichBlockMathematicalExpression.php @@ -9,7 +9,7 @@ * @property string $type * @property string $expression */ -class InputRichBlockMathematicalExpression extends Entity +class InputRichBlockMathematicalExpression extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockParagraph.php b/src/Telegram/Entities/InputRichBlockParagraph.php index 371f132..17cf80c 100644 --- a/src/Telegram/Entities/InputRichBlockParagraph.php +++ b/src/Telegram/Entities/InputRichBlockParagraph.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class InputRichBlockParagraph extends Entity +class InputRichBlockParagraph extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockPhoto.php b/src/Telegram/Entities/InputRichBlockPhoto.php index ce1d6bd..df2844c 100644 --- a/src/Telegram/Entities/InputRichBlockPhoto.php +++ b/src/Telegram/Entities/InputRichBlockPhoto.php @@ -10,7 +10,7 @@ * @property InputMediaPhoto $photo * @property RichBlockCaption $caption */ -class InputRichBlockPhoto extends Entity +class InputRichBlockPhoto extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockPreformatted.php b/src/Telegram/Entities/InputRichBlockPreformatted.php index ceeecd3..5dec49f 100644 --- a/src/Telegram/Entities/InputRichBlockPreformatted.php +++ b/src/Telegram/Entities/InputRichBlockPreformatted.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $language */ -class InputRichBlockPreformatted extends Entity +class InputRichBlockPreformatted extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockPullQuotation.php b/src/Telegram/Entities/InputRichBlockPullQuotation.php index 1457a08..7c8af19 100644 --- a/src/Telegram/Entities/InputRichBlockPullQuotation.php +++ b/src/Telegram/Entities/InputRichBlockPullQuotation.php @@ -10,7 +10,7 @@ * @property RichText $text * @property RichText $credit */ -class InputRichBlockPullQuotation extends Entity +class InputRichBlockPullQuotation extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockSectionHeading.php b/src/Telegram/Entities/InputRichBlockSectionHeading.php index c8e49b7..115d217 100644 --- a/src/Telegram/Entities/InputRichBlockSectionHeading.php +++ b/src/Telegram/Entities/InputRichBlockSectionHeading.php @@ -10,7 +10,7 @@ * @property RichText $text * @property int $size */ -class InputRichBlockSectionHeading extends Entity +class InputRichBlockSectionHeading extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockSlideshow.php b/src/Telegram/Entities/InputRichBlockSlideshow.php index 65d9ea8..f956120 100644 --- a/src/Telegram/Entities/InputRichBlockSlideshow.php +++ b/src/Telegram/Entities/InputRichBlockSlideshow.php @@ -10,7 +10,7 @@ * @property InputRichBlock[] $blocks * @property RichBlockCaption $caption */ -class InputRichBlockSlideshow extends Entity +class InputRichBlockSlideshow extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockTable.php b/src/Telegram/Entities/InputRichBlockTable.php index 45c65c0..2acb5b7 100644 --- a/src/Telegram/Entities/InputRichBlockTable.php +++ b/src/Telegram/Entities/InputRichBlockTable.php @@ -12,7 +12,7 @@ * @property bool $is_striped * @property RichText $caption */ -class InputRichBlockTable extends Entity +class InputRichBlockTable extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockThinking.php b/src/Telegram/Entities/InputRichBlockThinking.php index 08e601f..3b55a9c 100644 --- a/src/Telegram/Entities/InputRichBlockThinking.php +++ b/src/Telegram/Entities/InputRichBlockThinking.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class InputRichBlockThinking extends Entity +class InputRichBlockThinking extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockVideo.php b/src/Telegram/Entities/InputRichBlockVideo.php index 58ff727..68d4b45 100644 --- a/src/Telegram/Entities/InputRichBlockVideo.php +++ b/src/Telegram/Entities/InputRichBlockVideo.php @@ -10,7 +10,7 @@ * @property InputMediaVideo $video * @property RichBlockCaption $caption */ -class InputRichBlockVideo extends Entity +class InputRichBlockVideo extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichBlockVoiceNote.php b/src/Telegram/Entities/InputRichBlockVoiceNote.php index cb1c4e7..8e0ee91 100644 --- a/src/Telegram/Entities/InputRichBlockVoiceNote.php +++ b/src/Telegram/Entities/InputRichBlockVoiceNote.php @@ -10,7 +10,7 @@ * @property InputMediaVoiceNote $voice_note * @property RichBlockCaption $caption */ -class InputRichBlockVoiceNote extends Entity +class InputRichBlockVoiceNote extends InputRichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichMessageContent.php b/src/Telegram/Entities/InputRichMessageContent.php index 76b7b36..2cd68cd 100644 --- a/src/Telegram/Entities/InputRichMessageContent.php +++ b/src/Telegram/Entities/InputRichMessageContent.php @@ -8,7 +8,7 @@ * InputRichMessageContent Entity * @property InputRichMessage $rich_message */ -class InputRichMessageContent extends Entity +class InputRichMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputRichMessageMedia.php b/src/Telegram/Entities/InputRichMessageMedia.php index fc2ebed..099e4d7 100644 --- a/src/Telegram/Entities/InputRichMessageMedia.php +++ b/src/Telegram/Entities/InputRichMessageMedia.php @@ -15,7 +15,7 @@ class InputRichMessageMedia extends Entity protected function setEntities(): array { return [ - 'media' => InputMediaAnimation|InputMediaAudio|InputMediaPhoto|InputMediaVideo|InputMediaVoiceNote::class, + 'media' => InputMediaAnimation::class, ]; } } diff --git a/src/Telegram/Entities/InputStoryContentPhoto.php b/src/Telegram/Entities/InputStoryContentPhoto.php index bd13a78..4e0a4e0 100644 --- a/src/Telegram/Entities/InputStoryContentPhoto.php +++ b/src/Telegram/Entities/InputStoryContentPhoto.php @@ -9,7 +9,7 @@ * @property string $type * @property string $photo */ -class InputStoryContentPhoto extends Entity +class InputStoryContentPhoto extends InputStoryContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputStoryContentVideo.php b/src/Telegram/Entities/InputStoryContentVideo.php index cabb974..ea09e84 100644 --- a/src/Telegram/Entities/InputStoryContentVideo.php +++ b/src/Telegram/Entities/InputStoryContentVideo.php @@ -12,7 +12,7 @@ * @property float $cover_frame_timestamp * @property bool $is_animation */ -class InputStoryContentVideo extends Entity +class InputStoryContentVideo extends InputStoryContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputTextMessageContent.php b/src/Telegram/Entities/InputTextMessageContent.php index 99137f1..85faf59 100644 --- a/src/Telegram/Entities/InputTextMessageContent.php +++ b/src/Telegram/Entities/InputTextMessageContent.php @@ -11,7 +11,7 @@ * @property MessageEntity[] $entities * @property LinkPreviewOptions $link_preview_options */ -class InputTextMessageContent extends Entity +class InputTextMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/InputVenueMessageContent.php b/src/Telegram/Entities/InputVenueMessageContent.php index 04acf3c..2de4383 100644 --- a/src/Telegram/Entities/InputVenueMessageContent.php +++ b/src/Telegram/Entities/InputVenueMessageContent.php @@ -15,7 +15,7 @@ * @property string $google_place_id * @property string $google_place_type */ -class InputVenueMessageContent extends Entity +class InputVenueMessageContent extends InputMessageContent { protected function setEntities(): array diff --git a/src/Telegram/Entities/MenuButtonCommands.php b/src/Telegram/Entities/MenuButtonCommands.php index c3d9042..0a25145 100644 --- a/src/Telegram/Entities/MenuButtonCommands.php +++ b/src/Telegram/Entities/MenuButtonCommands.php @@ -8,7 +8,7 @@ * MenuButtonCommands Entity * @property string $type */ -class MenuButtonCommands extends Entity +class MenuButtonCommands extends MenuButton { protected function setEntities(): array diff --git a/src/Telegram/Entities/MenuButtonDefault.php b/src/Telegram/Entities/MenuButtonDefault.php index 7be67f1..0d5618d 100644 --- a/src/Telegram/Entities/MenuButtonDefault.php +++ b/src/Telegram/Entities/MenuButtonDefault.php @@ -8,7 +8,7 @@ * MenuButtonDefault Entity * @property string $type */ -class MenuButtonDefault extends Entity +class MenuButtonDefault extends MenuButton { protected function setEntities(): array diff --git a/src/Telegram/Entities/MenuButtonWebApp.php b/src/Telegram/Entities/MenuButtonWebApp.php index 86960c0..8907e0a 100644 --- a/src/Telegram/Entities/MenuButtonWebApp.php +++ b/src/Telegram/Entities/MenuButtonWebApp.php @@ -10,7 +10,7 @@ * @property string $text * @property WebAppInfo $web_app */ -class MenuButtonWebApp extends Entity +class MenuButtonWebApp extends MenuButton { protected function setEntities(): array diff --git a/src/Telegram/Entities/Message.php b/src/Telegram/Entities/Message.php index 7a150c1..c4f88c9 100644 --- a/src/Telegram/Entities/Message.php +++ b/src/Telegram/Entities/Message.php @@ -126,7 +126,7 @@ * @property WebAppData $web_app_data * @property InlineKeyboardMarkup $reply_markup */ -class Message extends Entity +class Message extends MaybeInaccessibleMessage { protected function setEntities(): array diff --git a/src/Telegram/Entities/MessageOriginChannel.php b/src/Telegram/Entities/MessageOriginChannel.php index 94beb81..9329127 100644 --- a/src/Telegram/Entities/MessageOriginChannel.php +++ b/src/Telegram/Entities/MessageOriginChannel.php @@ -12,7 +12,7 @@ * @property int $message_id * @property string $author_signature */ -class MessageOriginChannel extends Entity +class MessageOriginChannel extends MessageOrigin { protected function setEntities(): array diff --git a/src/Telegram/Entities/MessageOriginChat.php b/src/Telegram/Entities/MessageOriginChat.php index 1245ad0..3437c8a 100644 --- a/src/Telegram/Entities/MessageOriginChat.php +++ b/src/Telegram/Entities/MessageOriginChat.php @@ -11,7 +11,7 @@ * @property Chat $sender_chat * @property string $author_signature */ -class MessageOriginChat extends Entity +class MessageOriginChat extends MessageOrigin { protected function setEntities(): array diff --git a/src/Telegram/Entities/MessageOriginHiddenUser.php b/src/Telegram/Entities/MessageOriginHiddenUser.php index 5307c79..579660c 100644 --- a/src/Telegram/Entities/MessageOriginHiddenUser.php +++ b/src/Telegram/Entities/MessageOriginHiddenUser.php @@ -10,7 +10,7 @@ * @property int $date * @property string $sender_user_name */ -class MessageOriginHiddenUser extends Entity +class MessageOriginHiddenUser extends MessageOrigin { protected function setEntities(): array diff --git a/src/Telegram/Entities/MessageOriginUser.php b/src/Telegram/Entities/MessageOriginUser.php index eb19381..9bbb4fd 100644 --- a/src/Telegram/Entities/MessageOriginUser.php +++ b/src/Telegram/Entities/MessageOriginUser.php @@ -10,7 +10,7 @@ * @property int $date * @property User $sender_user */ -class MessageOriginUser extends Entity +class MessageOriginUser extends MessageOrigin { protected function setEntities(): array diff --git a/src/Telegram/Entities/OwnedGiftRegular.php b/src/Telegram/Entities/OwnedGiftRegular.php index 0ee56e5..f14b242 100644 --- a/src/Telegram/Entities/OwnedGiftRegular.php +++ b/src/Telegram/Entities/OwnedGiftRegular.php @@ -22,7 +22,7 @@ * @property bool $is_upgrade_separate * @property int $unique_gift_number */ -class OwnedGiftRegular extends Entity +class OwnedGiftRegular extends OwnedGift { protected function setEntities(): array diff --git a/src/Telegram/Entities/OwnedGiftUnique.php b/src/Telegram/Entities/OwnedGiftUnique.php index dcfc700..218cd8f 100644 --- a/src/Telegram/Entities/OwnedGiftUnique.php +++ b/src/Telegram/Entities/OwnedGiftUnique.php @@ -16,7 +16,7 @@ * @property int $transfer_star_count * @property int $next_transfer_date */ -class OwnedGiftUnique extends Entity +class OwnedGiftUnique extends OwnedGift { protected function setEntities(): array diff --git a/src/Telegram/Entities/PaidMediaLivePhoto.php b/src/Telegram/Entities/PaidMediaLivePhoto.php index df78304..b57ff66 100644 --- a/src/Telegram/Entities/PaidMediaLivePhoto.php +++ b/src/Telegram/Entities/PaidMediaLivePhoto.php @@ -9,7 +9,7 @@ * @property string $type * @property LivePhoto $live_photo */ -class PaidMediaLivePhoto extends Entity +class PaidMediaLivePhoto extends PaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/PaidMediaPhoto.php b/src/Telegram/Entities/PaidMediaPhoto.php index 71dbd9b..d75acb7 100644 --- a/src/Telegram/Entities/PaidMediaPhoto.php +++ b/src/Telegram/Entities/PaidMediaPhoto.php @@ -9,7 +9,7 @@ * @property string $type * @property PhotoSize[] $photo */ -class PaidMediaPhoto extends Entity +class PaidMediaPhoto extends PaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/PaidMediaPreview.php b/src/Telegram/Entities/PaidMediaPreview.php index 66b2431..14fb456 100644 --- a/src/Telegram/Entities/PaidMediaPreview.php +++ b/src/Telegram/Entities/PaidMediaPreview.php @@ -11,7 +11,7 @@ * @property int $height * @property int $duration */ -class PaidMediaPreview extends Entity +class PaidMediaPreview extends PaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/PaidMediaVideo.php b/src/Telegram/Entities/PaidMediaVideo.php index 484fcab..28132cc 100644 --- a/src/Telegram/Entities/PaidMediaVideo.php +++ b/src/Telegram/Entities/PaidMediaVideo.php @@ -9,7 +9,7 @@ * @property string $type * @property Video $video */ -class PaidMediaVideo extends Entity +class PaidMediaVideo extends PaidMedia { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorDataField.php b/src/Telegram/Entities/PassportElementErrorDataField.php index 0218295..4281e3f 100644 --- a/src/Telegram/Entities/PassportElementErrorDataField.php +++ b/src/Telegram/Entities/PassportElementErrorDataField.php @@ -12,7 +12,7 @@ * @property string $data_hash * @property string $message */ -class PassportElementErrorDataField extends Entity +class PassportElementErrorDataField extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorFile.php b/src/Telegram/Entities/PassportElementErrorFile.php index 25c97db..e1ebe88 100644 --- a/src/Telegram/Entities/PassportElementErrorFile.php +++ b/src/Telegram/Entities/PassportElementErrorFile.php @@ -11,7 +11,7 @@ * @property string $file_hash * @property string $message */ -class PassportElementErrorFile extends Entity +class PassportElementErrorFile extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorFiles.php b/src/Telegram/Entities/PassportElementErrorFiles.php index c161760..6a31688 100644 --- a/src/Telegram/Entities/PassportElementErrorFiles.php +++ b/src/Telegram/Entities/PassportElementErrorFiles.php @@ -11,7 +11,7 @@ * @property array $file_hashes * @property string $message */ -class PassportElementErrorFiles extends Entity +class PassportElementErrorFiles extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorFrontSide.php b/src/Telegram/Entities/PassportElementErrorFrontSide.php index 8910698..266b768 100644 --- a/src/Telegram/Entities/PassportElementErrorFrontSide.php +++ b/src/Telegram/Entities/PassportElementErrorFrontSide.php @@ -11,7 +11,7 @@ * @property string $file_hash * @property string $message */ -class PassportElementErrorFrontSide extends Entity +class PassportElementErrorFrontSide extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorReverseSide.php b/src/Telegram/Entities/PassportElementErrorReverseSide.php index 58b508f..374ef20 100644 --- a/src/Telegram/Entities/PassportElementErrorReverseSide.php +++ b/src/Telegram/Entities/PassportElementErrorReverseSide.php @@ -11,7 +11,7 @@ * @property string $file_hash * @property string $message */ -class PassportElementErrorReverseSide extends Entity +class PassportElementErrorReverseSide extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorSelfie.php b/src/Telegram/Entities/PassportElementErrorSelfie.php index 19b10f1..15080a5 100644 --- a/src/Telegram/Entities/PassportElementErrorSelfie.php +++ b/src/Telegram/Entities/PassportElementErrorSelfie.php @@ -11,7 +11,7 @@ * @property string $file_hash * @property string $message */ -class PassportElementErrorSelfie extends Entity +class PassportElementErrorSelfie extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorTranslationFile.php b/src/Telegram/Entities/PassportElementErrorTranslationFile.php index baff99e..956fb6b 100644 --- a/src/Telegram/Entities/PassportElementErrorTranslationFile.php +++ b/src/Telegram/Entities/PassportElementErrorTranslationFile.php @@ -11,7 +11,7 @@ * @property string $file_hash * @property string $message */ -class PassportElementErrorTranslationFile extends Entity +class PassportElementErrorTranslationFile extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorTranslationFiles.php b/src/Telegram/Entities/PassportElementErrorTranslationFiles.php index df7657c..6089636 100644 --- a/src/Telegram/Entities/PassportElementErrorTranslationFiles.php +++ b/src/Telegram/Entities/PassportElementErrorTranslationFiles.php @@ -11,7 +11,7 @@ * @property array $file_hashes * @property string $message */ -class PassportElementErrorTranslationFiles extends Entity +class PassportElementErrorTranslationFiles extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/PassportElementErrorUnspecified.php b/src/Telegram/Entities/PassportElementErrorUnspecified.php index 033f326..fee8e63 100644 --- a/src/Telegram/Entities/PassportElementErrorUnspecified.php +++ b/src/Telegram/Entities/PassportElementErrorUnspecified.php @@ -11,7 +11,7 @@ * @property string $element_hash * @property string $message */ -class PassportElementErrorUnspecified extends Entity +class PassportElementErrorUnspecified extends PassportElementError { protected function setEntities(): array diff --git a/src/Telegram/Entities/ReactionTypeCustomEmoji.php b/src/Telegram/Entities/ReactionTypeCustomEmoji.php index 3e13e65..2dc64df 100644 --- a/src/Telegram/Entities/ReactionTypeCustomEmoji.php +++ b/src/Telegram/Entities/ReactionTypeCustomEmoji.php @@ -9,7 +9,7 @@ * @property string $type * @property string $custom_emoji_id */ -class ReactionTypeCustomEmoji extends Entity +class ReactionTypeCustomEmoji extends ReactionType { protected function setEntities(): array diff --git a/src/Telegram/Entities/ReactionTypeEmoji.php b/src/Telegram/Entities/ReactionTypeEmoji.php index f03875f..3f6c734 100644 --- a/src/Telegram/Entities/ReactionTypeEmoji.php +++ b/src/Telegram/Entities/ReactionTypeEmoji.php @@ -9,7 +9,7 @@ * @property string $type * @property string $emoji */ -class ReactionTypeEmoji extends Entity +class ReactionTypeEmoji extends ReactionType { protected function setEntities(): array diff --git a/src/Telegram/Entities/ReactionTypePaid.php b/src/Telegram/Entities/ReactionTypePaid.php index 7fb9e4c..e504053 100644 --- a/src/Telegram/Entities/ReactionTypePaid.php +++ b/src/Telegram/Entities/ReactionTypePaid.php @@ -8,7 +8,7 @@ * ReactionTypePaid Entity * @property string $type */ -class ReactionTypePaid extends Entity +class ReactionTypePaid extends ReactionType { protected function setEntities(): array diff --git a/src/Telegram/Entities/RevenueWithdrawalStateFailed.php b/src/Telegram/Entities/RevenueWithdrawalStateFailed.php index c9126ab..75400e3 100644 --- a/src/Telegram/Entities/RevenueWithdrawalStateFailed.php +++ b/src/Telegram/Entities/RevenueWithdrawalStateFailed.php @@ -8,7 +8,7 @@ * RevenueWithdrawalStateFailed Entity * @property string $type */ -class RevenueWithdrawalStateFailed extends Entity +class RevenueWithdrawalStateFailed extends RevenueWithdrawalState { protected function setEntities(): array diff --git a/src/Telegram/Entities/RevenueWithdrawalStatePending.php b/src/Telegram/Entities/RevenueWithdrawalStatePending.php index dac2833..1b900f6 100644 --- a/src/Telegram/Entities/RevenueWithdrawalStatePending.php +++ b/src/Telegram/Entities/RevenueWithdrawalStatePending.php @@ -8,7 +8,7 @@ * RevenueWithdrawalStatePending Entity * @property string $type */ -class RevenueWithdrawalStatePending extends Entity +class RevenueWithdrawalStatePending extends RevenueWithdrawalState { protected function setEntities(): array diff --git a/src/Telegram/Entities/RevenueWithdrawalStateSucceeded.php b/src/Telegram/Entities/RevenueWithdrawalStateSucceeded.php index 383118b..bba9130 100644 --- a/src/Telegram/Entities/RevenueWithdrawalStateSucceeded.php +++ b/src/Telegram/Entities/RevenueWithdrawalStateSucceeded.php @@ -10,7 +10,7 @@ * @property int $date * @property string $url */ -class RevenueWithdrawalStateSucceeded extends Entity +class RevenueWithdrawalStateSucceeded extends RevenueWithdrawalState { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockAnchor.php b/src/Telegram/Entities/RichBlockAnchor.php index 8e26be0..42ed1b2 100644 --- a/src/Telegram/Entities/RichBlockAnchor.php +++ b/src/Telegram/Entities/RichBlockAnchor.php @@ -9,7 +9,7 @@ * @property string $type * @property string $name */ -class RichBlockAnchor extends Entity +class RichBlockAnchor extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockAnimation.php b/src/Telegram/Entities/RichBlockAnimation.php index 3846989..d59de59 100644 --- a/src/Telegram/Entities/RichBlockAnimation.php +++ b/src/Telegram/Entities/RichBlockAnimation.php @@ -11,7 +11,7 @@ * @property bool $has_spoiler * @property RichBlockCaption $caption */ -class RichBlockAnimation extends Entity +class RichBlockAnimation extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockAudio.php b/src/Telegram/Entities/RichBlockAudio.php index 3d563ac..55f2bd4 100644 --- a/src/Telegram/Entities/RichBlockAudio.php +++ b/src/Telegram/Entities/RichBlockAudio.php @@ -10,7 +10,7 @@ * @property Audio $audio * @property RichBlockCaption $caption */ -class RichBlockAudio extends Entity +class RichBlockAudio extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockBlockQuotation.php b/src/Telegram/Entities/RichBlockBlockQuotation.php index 6a6ba39..10c4719 100644 --- a/src/Telegram/Entities/RichBlockBlockQuotation.php +++ b/src/Telegram/Entities/RichBlockBlockQuotation.php @@ -10,7 +10,7 @@ * @property RichBlock[] $blocks * @property RichText $credit */ -class RichBlockBlockQuotation extends Entity +class RichBlockBlockQuotation extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockCollage.php b/src/Telegram/Entities/RichBlockCollage.php index 8004f4e..1f54b54 100644 --- a/src/Telegram/Entities/RichBlockCollage.php +++ b/src/Telegram/Entities/RichBlockCollage.php @@ -10,7 +10,7 @@ * @property RichBlock[] $blocks * @property RichBlockCaption $caption */ -class RichBlockCollage extends Entity +class RichBlockCollage extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockDetails.php b/src/Telegram/Entities/RichBlockDetails.php index 6ea93bd..9bbb4e9 100644 --- a/src/Telegram/Entities/RichBlockDetails.php +++ b/src/Telegram/Entities/RichBlockDetails.php @@ -11,7 +11,7 @@ * @property RichBlock[] $blocks * @property bool $is_open */ -class RichBlockDetails extends Entity +class RichBlockDetails extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockDivider.php b/src/Telegram/Entities/RichBlockDivider.php index 3351f70..b4f755e 100644 --- a/src/Telegram/Entities/RichBlockDivider.php +++ b/src/Telegram/Entities/RichBlockDivider.php @@ -8,7 +8,7 @@ * RichBlockDivider Entity * @property string $type */ -class RichBlockDivider extends Entity +class RichBlockDivider extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockFooter.php b/src/Telegram/Entities/RichBlockFooter.php index 6b64241..97d7dce 100644 --- a/src/Telegram/Entities/RichBlockFooter.php +++ b/src/Telegram/Entities/RichBlockFooter.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichBlockFooter extends Entity +class RichBlockFooter extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockList.php b/src/Telegram/Entities/RichBlockList.php index d9b6ccf..ab22025 100644 --- a/src/Telegram/Entities/RichBlockList.php +++ b/src/Telegram/Entities/RichBlockList.php @@ -9,7 +9,7 @@ * @property string $type * @property RichBlockListItem[] $items */ -class RichBlockList extends Entity +class RichBlockList extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockMap.php b/src/Telegram/Entities/RichBlockMap.php index 85ca4a6..f67f071 100644 --- a/src/Telegram/Entities/RichBlockMap.php +++ b/src/Telegram/Entities/RichBlockMap.php @@ -13,7 +13,7 @@ * @property int $height * @property RichBlockCaption $caption */ -class RichBlockMap extends Entity +class RichBlockMap extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockMathematicalExpression.php b/src/Telegram/Entities/RichBlockMathematicalExpression.php index 1541f43..99db397 100644 --- a/src/Telegram/Entities/RichBlockMathematicalExpression.php +++ b/src/Telegram/Entities/RichBlockMathematicalExpression.php @@ -9,7 +9,7 @@ * @property string $type * @property string $expression */ -class RichBlockMathematicalExpression extends Entity +class RichBlockMathematicalExpression extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockParagraph.php b/src/Telegram/Entities/RichBlockParagraph.php index 9aee12f..951a0f9 100644 --- a/src/Telegram/Entities/RichBlockParagraph.php +++ b/src/Telegram/Entities/RichBlockParagraph.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichBlockParagraph extends Entity +class RichBlockParagraph extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockPhoto.php b/src/Telegram/Entities/RichBlockPhoto.php index b932ee6..ee4370e 100644 --- a/src/Telegram/Entities/RichBlockPhoto.php +++ b/src/Telegram/Entities/RichBlockPhoto.php @@ -11,7 +11,7 @@ * @property bool $has_spoiler * @property RichBlockCaption $caption */ -class RichBlockPhoto extends Entity +class RichBlockPhoto extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockPreformatted.php b/src/Telegram/Entities/RichBlockPreformatted.php index 8ce3e4d..ccff2a2 100644 --- a/src/Telegram/Entities/RichBlockPreformatted.php +++ b/src/Telegram/Entities/RichBlockPreformatted.php @@ -10,7 +10,7 @@ * @property RichText $text * @property string $language */ -class RichBlockPreformatted extends Entity +class RichBlockPreformatted extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockPullQuotation.php b/src/Telegram/Entities/RichBlockPullQuotation.php index bf81b07..6da38fd 100644 --- a/src/Telegram/Entities/RichBlockPullQuotation.php +++ b/src/Telegram/Entities/RichBlockPullQuotation.php @@ -10,7 +10,7 @@ * @property RichText $text * @property RichText $credit */ -class RichBlockPullQuotation extends Entity +class RichBlockPullQuotation extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockSectionHeading.php b/src/Telegram/Entities/RichBlockSectionHeading.php index 52e5172..2ff4418 100644 --- a/src/Telegram/Entities/RichBlockSectionHeading.php +++ b/src/Telegram/Entities/RichBlockSectionHeading.php @@ -10,7 +10,7 @@ * @property RichText $text * @property int $size */ -class RichBlockSectionHeading extends Entity +class RichBlockSectionHeading extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockSlideshow.php b/src/Telegram/Entities/RichBlockSlideshow.php index 3af237e..8b63b17 100644 --- a/src/Telegram/Entities/RichBlockSlideshow.php +++ b/src/Telegram/Entities/RichBlockSlideshow.php @@ -10,7 +10,7 @@ * @property RichBlock[] $blocks * @property RichBlockCaption $caption */ -class RichBlockSlideshow extends Entity +class RichBlockSlideshow extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockTable.php b/src/Telegram/Entities/RichBlockTable.php index 64a49f5..045923e 100644 --- a/src/Telegram/Entities/RichBlockTable.php +++ b/src/Telegram/Entities/RichBlockTable.php @@ -12,7 +12,7 @@ * @property bool $is_striped * @property RichText $caption */ -class RichBlockTable extends Entity +class RichBlockTable extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockThinking.php b/src/Telegram/Entities/RichBlockThinking.php index 0a2bcdf..e0e709d 100644 --- a/src/Telegram/Entities/RichBlockThinking.php +++ b/src/Telegram/Entities/RichBlockThinking.php @@ -9,7 +9,7 @@ * @property string $type * @property RichText $text */ -class RichBlockThinking extends Entity +class RichBlockThinking extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockVideo.php b/src/Telegram/Entities/RichBlockVideo.php index 72f88ba..84e754f 100644 --- a/src/Telegram/Entities/RichBlockVideo.php +++ b/src/Telegram/Entities/RichBlockVideo.php @@ -11,7 +11,7 @@ * @property bool $has_spoiler * @property RichBlockCaption $caption */ -class RichBlockVideo extends Entity +class RichBlockVideo extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/RichBlockVoiceNote.php b/src/Telegram/Entities/RichBlockVoiceNote.php index b04a051..d7e765e 100644 --- a/src/Telegram/Entities/RichBlockVoiceNote.php +++ b/src/Telegram/Entities/RichBlockVoiceNote.php @@ -10,7 +10,7 @@ * @property Voice $voice_note * @property RichBlockCaption $caption */ -class RichBlockVoiceNote extends Entity +class RichBlockVoiceNote extends RichBlock { protected function setEntities(): array diff --git a/src/Telegram/Entities/StoryAreaTypeLink.php b/src/Telegram/Entities/StoryAreaTypeLink.php index 57971b6..aa37024 100644 --- a/src/Telegram/Entities/StoryAreaTypeLink.php +++ b/src/Telegram/Entities/StoryAreaTypeLink.php @@ -9,7 +9,7 @@ * @property string $type * @property string $url */ -class StoryAreaTypeLink extends Entity +class StoryAreaTypeLink extends StoryAreaType { protected function setEntities(): array diff --git a/src/Telegram/Entities/StoryAreaTypeLocation.php b/src/Telegram/Entities/StoryAreaTypeLocation.php index 194ca01..5ce4977 100644 --- a/src/Telegram/Entities/StoryAreaTypeLocation.php +++ b/src/Telegram/Entities/StoryAreaTypeLocation.php @@ -11,7 +11,7 @@ * @property float $longitude * @property LocationAddress $address */ -class StoryAreaTypeLocation extends Entity +class StoryAreaTypeLocation extends StoryAreaType { protected function setEntities(): array diff --git a/src/Telegram/Entities/StoryAreaTypeSuggestedReaction.php b/src/Telegram/Entities/StoryAreaTypeSuggestedReaction.php index 29c58b4..a01ee5e 100644 --- a/src/Telegram/Entities/StoryAreaTypeSuggestedReaction.php +++ b/src/Telegram/Entities/StoryAreaTypeSuggestedReaction.php @@ -11,7 +11,7 @@ * @property bool $is_dark * @property bool $is_flipped */ -class StoryAreaTypeSuggestedReaction extends Entity +class StoryAreaTypeSuggestedReaction extends StoryAreaType { protected function setEntities(): array diff --git a/src/Telegram/Entities/StoryAreaTypeUniqueGift.php b/src/Telegram/Entities/StoryAreaTypeUniqueGift.php index ab33e5c..6c4a0be 100644 --- a/src/Telegram/Entities/StoryAreaTypeUniqueGift.php +++ b/src/Telegram/Entities/StoryAreaTypeUniqueGift.php @@ -9,7 +9,7 @@ * @property string $type * @property string $name */ -class StoryAreaTypeUniqueGift extends Entity +class StoryAreaTypeUniqueGift extends StoryAreaType { protected function setEntities(): array diff --git a/src/Telegram/Entities/StoryAreaTypeWeather.php b/src/Telegram/Entities/StoryAreaTypeWeather.php index d9d0744..7e0fe88 100644 --- a/src/Telegram/Entities/StoryAreaTypeWeather.php +++ b/src/Telegram/Entities/StoryAreaTypeWeather.php @@ -11,7 +11,7 @@ * @property string $emoji * @property int $background_color */ -class StoryAreaTypeWeather extends Entity +class StoryAreaTypeWeather extends StoryAreaType { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerAffiliateProgram.php b/src/Telegram/Entities/TransactionPartnerAffiliateProgram.php index 11fccaf..04a7683 100644 --- a/src/Telegram/Entities/TransactionPartnerAffiliateProgram.php +++ b/src/Telegram/Entities/TransactionPartnerAffiliateProgram.php @@ -10,7 +10,7 @@ * @property User $sponsor_user * @property int $commission_per_mille */ -class TransactionPartnerAffiliateProgram extends Entity +class TransactionPartnerAffiliateProgram extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerChat.php b/src/Telegram/Entities/TransactionPartnerChat.php index ea6adba..ceb4b86 100644 --- a/src/Telegram/Entities/TransactionPartnerChat.php +++ b/src/Telegram/Entities/TransactionPartnerChat.php @@ -10,7 +10,7 @@ * @property Chat $chat * @property Gift $gift */ -class TransactionPartnerChat extends Entity +class TransactionPartnerChat extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerFragment.php b/src/Telegram/Entities/TransactionPartnerFragment.php index 6e45389..85892ff 100644 --- a/src/Telegram/Entities/TransactionPartnerFragment.php +++ b/src/Telegram/Entities/TransactionPartnerFragment.php @@ -9,7 +9,7 @@ * @property string $type * @property RevenueWithdrawalState $withdrawal_state */ -class TransactionPartnerFragment extends Entity +class TransactionPartnerFragment extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerOther.php b/src/Telegram/Entities/TransactionPartnerOther.php index 496b40a..5106f69 100644 --- a/src/Telegram/Entities/TransactionPartnerOther.php +++ b/src/Telegram/Entities/TransactionPartnerOther.php @@ -8,7 +8,7 @@ * TransactionPartnerOther Entity * @property string $type */ -class TransactionPartnerOther extends Entity +class TransactionPartnerOther extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerTelegramAds.php b/src/Telegram/Entities/TransactionPartnerTelegramAds.php index 9546826..4b06609 100644 --- a/src/Telegram/Entities/TransactionPartnerTelegramAds.php +++ b/src/Telegram/Entities/TransactionPartnerTelegramAds.php @@ -8,7 +8,7 @@ * TransactionPartnerTelegramAds Entity * @property string $type */ -class TransactionPartnerTelegramAds extends Entity +class TransactionPartnerTelegramAds extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerTelegramApi.php b/src/Telegram/Entities/TransactionPartnerTelegramApi.php index 43bb89f..93deb89 100644 --- a/src/Telegram/Entities/TransactionPartnerTelegramApi.php +++ b/src/Telegram/Entities/TransactionPartnerTelegramApi.php @@ -9,7 +9,7 @@ * @property string $type * @property int $request_count */ -class TransactionPartnerTelegramApi extends Entity +class TransactionPartnerTelegramApi extends TransactionPartner { protected function setEntities(): array diff --git a/src/Telegram/Entities/TransactionPartnerUser.php b/src/Telegram/Entities/TransactionPartnerUser.php index a69b840..0d1e7ef 100644 --- a/src/Telegram/Entities/TransactionPartnerUser.php +++ b/src/Telegram/Entities/TransactionPartnerUser.php @@ -17,7 +17,7 @@ * @property Gift $gift * @property int $premium_subscription_duration */ -class TransactionPartnerUser extends Entity +class TransactionPartnerUser extends TransactionPartner { protected function setEntities(): array From dd3d4e5bdb442a19370aabac6e073d318c05f35b Mon Sep 17 00:00:00 2001 From: al3x5dev Date: Wed, 29 Jul 2026 01:16:05 -0400 Subject: [PATCH 4/4] fix: handle pre-constructed entities, array text in blocks, fix richDatetime type, and document keyboards and rich message examples --- README.md | 3 +- docs/format.md | 278 ++++++++++++++++- docs/keyboards.md | 4 +- docs/rich-message-examples.md | 404 +++++++++++++++++++++++++ src/Telegram/Entity.php | 2 +- src/Telegram/Factories/Rich/Block.php | 148 ++++----- src/Telegram/Factories/RichMessage.php | 4 +- src/Telegram/Text.php | 5 +- 8 files changed, 770 insertions(+), 78 deletions(-) create mode 100644 docs/rich-message-examples.md diff --git a/README.md b/README.md index 6f41720..7a526fe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # xBot -![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-10.0-blue?style=flat-square) +![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-10.2-blue?style=flat-square) ![GitHub Release](https://img.shields.io/github/v/release/al3x5dev/xbot?include_prereleases&style=flat-square&color=blue) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/al3x5dev/http?style=flat-square) ![GitHub License](https://img.shields.io/github/license/al3x5dev/xbot?style=flat-square) @@ -25,6 +25,7 @@ - [Message Format](https://github.com/al3x5dev/xbot/blob/main/docs/format.md) - [Events Logger](https://github.com/al3x5dev/xbot/blob/main/docs/logger.md) - [Middlewares](https://github.com/al3x5dev/xbot/blob/main/docs/middlewares.md) +- [Rich Messages](https://github.com/al3x5dev/xbot/blob/main/docs/rich-message-examples.md) ## Contributions diff --git a/docs/format.md b/docs/format.md index 356e628..4ee24ce 100644 --- a/docs/format.md +++ b/docs/format.md @@ -136,4 +136,280 @@ Formats the provided text as an expandable blockquote. ```php $this->reply(Text::expandableBlockQuote('This is an expandable blockquote')); // Output:
This is an expandable blockquote
-``` \ No newline at end of file +``` + +--- + +## Rich Text Formatting (for RichMessage) + +These methods return `RichText` entity objects (not strings) for use inside `RichMessage` blocks and tables. They produce the nested JSON structure required by the Telegram Bot API 7.0+ rich message format. + +```php +use Al3x5\xBot\Telegram\Text; + +$bold = Text::richBold('Bold text'); +$italic = Text::richItalic('Italic text'); +``` + +### richBold(string|RichText $text): RichTextBold + +```php +Block::heading(Text::richBold('Title')); +``` + +### richItalic(string|RichText $text): RichTextItalic + +```php +Block::paragraph(Text::richItalic('Intro')); +``` + +### richUnderline(string|RichText $text): RichTextUnderline + +### richStrikethrough(string|RichText $text): RichTextStrikethrough + +### richSpoiler(string|RichText $text): RichTextSpoiler + +### richCode(string|RichText $text): RichTextCode + +### richUrl(string|RichText $text, string $url): RichTextUrl + +Creates a clickable URL with the given text. + +### richEmail(string|RichText $text): RichTextEmailAddress + +### richPhone(string|RichText $text): RichTextPhoneNumber + +### richMention(string|RichText $text, string $username): RichTextMention + +Mentions a user by username. + +### richTextMention(string|RichText $text, User|int $user): RichTextTextMention + +Mentions a user by their user ID. + +### richCustomEmoji(string $emoji, string $id): RichTextCustomEmoji + +Inserts a custom emoji by its ID. + +### richSubscript(string|RichText $text): RichTextSubscript + +### richSuperscript(string|RichText $text): RichTextSuperscript + +### richMarked(string|RichText $text): RichTextMarked + +### richDatetime(int $unix): RichTextDateTime + +Formats a Unix timestamp as a time entity. + +### richMath(string $expression): RichTextMathematicalExpression + +### richAnchor(string $name): RichTextAnchor + +Creates an anchor that can be referenced by `richAnchorLink`. + +### richAnchorLink(string|RichText $text, string $anchor): RichTextAnchorLink + +Creates a link to a previously defined anchor. + +### richReference(string|RichText $text, string $reference): RichTextReference + +### richReferenceLink(string|RichText $text, string $reference): RichTextReferenceLink + +--- + +## RichMessage Builder + +The `RichMessage` builder creates a `sendRichMessage` payload. It supports rich blocks, HTML/Markdown fallbacks, and RTL direction. + +```php +use Al3x5\xBot\Telegram\Factories\RichMessage; +use Al3x5\xBot\Telegram\Factories\Rich\Block; +use Al3x5\xBot\Telegram\Text; + +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Welcome'))) + ->block(Block::paragraph(Text::richItalic('This is a rich message'))) + ->block(Block::divider()) + ->html('Fallback HTML') + ->rtl() + ->build(); + +$this->sendRichMessage($chatId, $message); +``` + +### make(): RichMessage + +Creates a new builder instance. + +### block(Entity $block): self + +Adds a block (from `Block::*()` factories). + +### html(string $html): self + +Sets an HTML fallback for clients that don't support rich messages. + +### markdown(string $markdown): self + +Sets a Markdown fallback. + +### rtl(bool $v = true): self + +Enables right-to-left rendering. + +### build(): InputRichMessage + +Builds the message entity ready for `sendRichMessage`. + +--- + +## Rich\Block Factory + +Provides static methods to create all 20 rich block types for use with `RichMessage::block()`. + +```php +use Al3x5\xBot\Telegram\Factories\Rich\Block; + +$msg = RichMessage::make() + ->block(Block::paragraph('Simple text')) + ->block(Block::divider()) + ->block(Block::table()->header(['Name', 'Value'])->body([['Item', '$10']])->build()) + ->build(); +``` + +### paragraph(string|RichText|array $text): InputRichBlockParagraph + +A paragraph block with formatted text. + +### heading(string|RichText|array $text, int $size = 1): InputRichBlockSectionHeading + +A section heading. `$size` ranges from 1 (largest) to 6. + +### preformatted(string|RichText|array $text, string $language = ''): InputRichBlockPreformatted + +Preformatted/code block. Optionally specify the programming language. + +### footer(string|RichText|array $text): InputRichBlockFooter + +A footer block. + +### divider(): InputRichBlockDivider + +A horizontal divider line. + +### thinking(string|RichText|array $text): InputRichBlockThinking + +Animated thinking/typing indicator block. + +### blockQuote(array $blocks, string|RichText|null $credit = null): InputRichBlockBlockQuotation + +A block quote containing nested blocks. Optional attribution text. + +```php +Block::blockQuote([Block::paragraph('Quoted text')], '— Source'); +``` + +### pullQuote(string|RichText|array $text, string|RichText|null $credit = null): InputRichBlockPullQuotation + +A pull quote with large stylized text. Optional attribution. + +### photo(string $media, string|RichText|null $caption = null, string|RichText|null $credit = null): InputRichBlockPhoto + +A photo block. `$media` is the file ID. + +### video(string $media, ...): InputRichBlockVideo + +### audio(string $media, ...): InputRichBlockAudio + +### animation(string $media, ...): InputRichBlockAnimation + +### voiceNote(string $media, ...): InputRichBlockVoiceNote + +### table(): Table + +Returns a `Table` builder instance for constructing table blocks. + +### list(array $items): InputRichBlockList + +Creates a list block. Each item can be a block or array of blocks. + +```php +Block::list([ + Block::paragraph('Item 1'), + Block::paragraph('Item 2'), +]); +``` + +### details(string|RichText|array $summary, array $blocks, bool $is_open = false): InputRichBlockDetails + +A collapsible details/summary block. + +### collage(array $blocks, ...): InputRichBlockCollage + +A collage of multiple media blocks. + +### slideshow(array $blocks, ...): InputRichBlockSlideshow + +A slideshow/carousel of blocks. + +### map(array $location, int $zoom = 15, int $width = 300, int $height = 200, ...): InputRichBlockMap + +Embedded map. `$location` is `['latitude' => float, 'longitude' => float]`. + +### math(string $expression): InputRichBlockMathematicalExpression + +Renders a mathematical expression using Telegram's rendering engine. + +### anchor(string $name): InputRichBlockAnchor + +Creates an anchor point that can be linked to via block anchor links. + +--- + +## Rich\Table Builder + +The `Table` builder constructs table blocks for use inside `RichMessage`. + +```php +use Al3x5\xBot\Telegram\Factories\Rich\Block; +use Al3x5\xBot\Telegram\Text; + +$table = Block::table() + ->header(['Product', 'Price']) + ->body([ + ['Shirt', '$25'], + ['Shoes', '$80'], + ]) + ->footer(['Total', '$105']) + ->bordered() + ->caption(Text::richBold('Order Summary')) + ->build(); +``` + +### header(array $cells): self + +Sets the header row. Each cell can be a string, `RichText` object, or array. + +### body(array $rows): self + +Sets the body rows. Each row is an array of cells. + +### footer(array $cells): self + +Sets the footer row. + +### bordered(bool $v = true): self + +Enables table borders. + +### striped(bool $v = true): self + +Enables alternating row striping. + +### caption(string|RichText|array $caption): self + +Sets the table caption. + +### build(): InputRichBlockTable + +Builds the table block entity. \ No newline at end of file diff --git a/docs/keyboards.md b/docs/keyboards.md index a7293e5..4904c7b 100644 --- a/docs/keyboards.md +++ b/docs/keyboards.md @@ -15,8 +15,8 @@ Creates an inline keyboard that appears next to the message. Each button can have actions such as opening a URL, sending callback data, etc. ```php -use Al3x5\xBot\Telegram\Factories\InlineButton; use Al3x5\xBot\Telegram\Factories\Keyboard; +use Al3x5\xBot\Telegram\Factories\Keyboard\InlineButton; $keyboard = Keyboard::inline() ->row([ @@ -159,8 +159,8 @@ This static method creates a new instance of `ReplyKeyboard`, which is used to b ```php -use Al3x5\xBot\Telegram\Factories\ReplyButton; use Al3x5\xBot\Telegram\Factories\Keyboard; +use Al3x5\xBot\Telegram\Factories\Keyboard\ReplyButton; $keyboard = Keyboard::reply() ->row([ diff --git a/docs/rich-message-examples.md b/docs/rich-message-examples.md new file mode 100644 index 0000000..6658301 --- /dev/null +++ b/docs/rich-message-examples.md @@ -0,0 +1,404 @@ +# Rich Message Examples + +Complete examples of rich messages using the Telegram Bot API 7.0+ format. + +All examples assume you have access to `$this->message->chat->id` from a command context. + +> [!IMPORTANT] +> `blocks`, `html`, and `markdown` are **mutually exclusive**. Use only one per message. Calling both `->html(...)` and `->markdown(...)` (or also `->block(...)`) will send multiple fields and the API will reject the request. + +```php +use Al3x5\xBot\Telegram\Text; +use Al3x5\xBot\Telegram\Factories\RichMessage; +use Al3x5\xBot\Telegram\Factories\Rich\Block; +``` + +--- + +## 1. Simple Message + +Heading + paragraph + divider: + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Welcome to xBot'))) + ->block(Block::paragraph('This is a simple rich message.')) + ->block(Block::paragraph(Text::richItalic('Enjoy the new features!'))) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 2. Formatted Text + +Nested `RichText` entities: + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Notifications'), 1)) + ->block(Block::paragraph([ + Text::richBold('New update! '), + Text::richItalic('Version 4.6') + ])) + ->block(Block::paragraph( + Text::richSpoiler('This is a spoiler text') + )) + ->block(Block::paragraph( + Text::richCode('composer update') + )) + ->block(Block::preformatted( + Text::richBold('const VERSION = "4.6.0";'), + 'php' + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 3. Table + +Table with header, body, footer, borders, and caption: + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Order Summary'))) + ->block(Block::table() + ->header(['Product', 'Qty', 'Price']) + ->body([ + ['T-Shirt', '2', '$50'], + ['Jeans', '1', '$80'], + ['Shoes', '1', '$120'], + ]) + ->footer(['Total', '4', '$250']) + ->bordered() + ->caption(Text::richBold('Order #12345')) + ->build() + ) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 4. Table with Richtext Cells + +```php +$message = RichMessage::make() + ->block(Block::table() + ->header([Text::richBold('Name'), Text::richBold('Status')]) + ->body([ + [Text::richBold('Alice'), Text::richItalic('Online')], + [Text::richBold('Bob'), Text::richItalic('Offline')], + ]) + ->striped() + ->build() + ) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 5. List + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Shopping List'))) + ->block(Block::list([ + Block::paragraph(Text::richBold('Fruits') . ': Apples, Bananas'), + Block::paragraph(Text::richBold('Dairy') . ': Milk, Cheese'), + Block::paragraph(Text::richBold('Bakery') . ': Bread, Croissants'), + ])) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 6. Collage + +Multiple media blocks arranged as a collage: + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Photo Gallery'))) + ->block(Block::collage( + [ + Block::photo('AgACAg...photoId1'), + Block::photo('AgACAg...photoId2'), + Block::photo('AgACAg...photoId3'), + ], + Text::richItalic('Our latest collection'), + Text::richBold('Gallery 2025') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +Mixed media collage: + +```php +$message = RichMessage::make() + ->block(Block::collage( + [ + Block::photo('AgACAg...photoId'), + Block::video('BAAD...videoId'), + ] + )) + ->block(Block::audio('CQAD...audioId')) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 7. Slideshow + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Product Showcase'))) + ->block(Block::slideshow( + [ + Block::photo('AgACAg...photo1', Text::richBold('Front view')), + Block::photo('AgACAg...photo2', Text::richBold('Side view')), + Block::photo('AgACAg...photo3', Text::richBold('Back view')), + ], + Text::richItalic('Swipe to see more') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 8. Details (Collapsible) + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('FAQ'))) + ->block(Block::details( + Text::richBold('How to install?'), + [ + Block::paragraph('Run the following command:'), + Block::preformatted('composer install', 'bash'), + ], + is_open: false + )) + ->block(Block::details( + Text::richBold('How to update?'), + [ + Block::paragraph('Use composer update:'), + Block::preformatted('composer update', 'bash'), + ], + is_open: true + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 9. Blockquote + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Testimonial'))) + ->block(Block::blockQuote( + [ + Block::paragraph('Amazing product! Highly recommended.'), + Block::paragraph(Text::richItalic('Changed my workflow completely.')), + ], + Text::richBold('— Happy Customer') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 10. Pull Quote + +```php +$message = RichMessage::make() + ->block(Block::pullQuote( + Text::richBold('The best time to plant a tree was 20 years ago. The second best time is now.'), + Text::richItalic('— Chinese Proverb') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 11. Photo with Caption + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Product Photo'))) + ->block(Block::photo( + 'AgACAg...photoFileId', + [Text::richBold('Premium T-Shirt'), "\n", Text::richItalic('$49.99')], + Text::richBold('Summer Collection 2024') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 12. Video + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Promo Video'))) + ->block(Block::video( + 'BAAD...videoFileId', + Text::richBold('Watch our new promo!'), + Text::richItalic('Duration: 2:30') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 13. Embedded Map + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Our Location'))) + ->block(Block::map( + ['latitude' => 40.7128, 'longitude' => -74.0060], + zoom: 15, + width: 400, + height: 300, + caption: Text::richBold('New York City'), + credit: Text::richItalic('Main Office') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 14. Thinking / Typing Block + +```php +$message = RichMessage::make() + ->block(Block::thinking(Text::richItalic('Analyzing your request...'))) + ->build(); + +$this->sendRichMessageDraft($chatId, $draftId, $message); +``` + +--- + +## 15. Math Expression + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('Math Result'))) + ->block(Block::math('E = mc^2')) + ->block(Block::paragraph( + Text::richItalic('Einsteins equation') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 16. Complete Invoice Example + +Combines multiple block types in a realistic scenario: + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('INVOICE #INV-2024-001'))) + ->block(Block::table() + ->header([Text::richBold('Item'), Text::richBold('Qty'), Text::richBold('Price')]) + ->body([ + ['Web Development', '40h', '$2,000'], + ['UI/UX Design', '20h', '$1,200'], + ['Hosting (1 year)', '1', '$360'], + ]) + ->footer([Text::richBold('Total'), '', Text::richBold('$3,560')]) + ->bordered() + ->striped() + ->caption(Text::richBold('Payment due within 30 days')) + ->build() + ) + ->block(Block::divider()) + ->block(Block::paragraph( + Text::richBold('Status: ') . Text::richItalic('Pending Payment') + )) + ->block(Block::paragraph( + Text::richBold('Due Date: ') . Text::richDatetime(strtotime('+30 days')) + )) + ->block(Block::blockQuote( + [Block::paragraph('Thank you for your business!')], + Text::richBold('xBot Team') + )) + ->block(Block::divider()) + ->block(Block::footer( + Text::richItalic('For questions, reply to this message.') + )) + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 17. RTL Message + +```php +$message = RichMessage::make() + ->block(Block::heading(Text::richBold('مرحباً بكم'))) + ->block(Block::paragraph('هذا نص من اليمين إلى اليسار')) + ->rtl() + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 18. With HTML Fallback + +```php +$message = RichMessage::make() + ->html('Rich MessageFallback for older clients') + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` + +--- + +## 19. With Markdown Fallback + +```php +$message = RichMessage::make() + ->markdown('*Rich Message* _Fallback for older clients_') + ->build(); + +$this->sendRichMessage($this->message->chat->id, $message); +``` diff --git a/src/Telegram/Entity.php b/src/Telegram/Entity.php index 8e8a0aa..b301808 100644 --- a/src/Telegram/Entity.php +++ b/src/Telegram/Entity.php @@ -55,7 +55,7 @@ protected function resolveEntity(array $data): void // Caso: Array de entidades (ej: 'photos' => [PhotoSize::class]) if (is_array($entityClass) && is_array($value)) { $this->properties[$key] = array_map( - fn($item) => new $entityClass[0]($item), + fn($item) => $item instanceof $entityClass[0] ? $item : new $entityClass[0]($item), $value ); } diff --git a/src/Telegram/Factories/Rich/Block.php b/src/Telegram/Factories/Rich/Block.php index c62d444..bc2d688 100644 --- a/src/Telegram/Factories/Rich/Block.php +++ b/src/Telegram/Factories/Rich/Block.php @@ -36,39 +36,43 @@ class Block { public static function paragraph(string|RichText|array $text): InputRichBlockParagraph { - return new InputRichBlockParagraph([ + $block = new InputRichBlockParagraph([ 'type' => InputRichBlock::TYPE_PARAGRAPH, - 'text' => $text, ]); + $block->text = $text; + return $block; } public static function heading(string|RichText|array $text, int $size = 1): InputRichBlockSectionHeading { - return new InputRichBlockSectionHeading([ + $block = new InputRichBlockSectionHeading([ 'type' => InputRichBlock::TYPE_HEADING, - 'text' => $text, 'size' => $size, ]); + $block->text = $text; + return $block; } public static function preformatted(string|RichText|array $text, string $language = ''): InputRichBlockPreformatted { $data = [ 'type' => InputRichBlock::TYPE_PREFORMATTED, - 'text' => $text, ]; if ($language !== '') { $data['language'] = $language; } - return new InputRichBlockPreformatted($data); + $block = new InputRichBlockPreformatted($data); + $block->text = $text; + return $block; } public static function footer(string|RichText|array $text): InputRichBlockFooter { - return new InputRichBlockFooter([ + $block = new InputRichBlockFooter([ 'type' => InputRichBlock::TYPE_FOOTER, - 'text' => $text, ]); + $block->text = $text; + return $block; } public static function divider(): InputRichBlockDivider @@ -80,40 +84,41 @@ public static function divider(): InputRichBlockDivider public static function thinking(string|RichText|array $text): InputRichBlockThinking { - return new InputRichBlockThinking([ + $block = new InputRichBlockThinking([ 'type' => InputRichBlock::TYPE_THINKING, - 'text' => $text, ]); + $block->text = $text; + return $block; } - public static function blockQuote(array $blocks, string|RichText|null $credit = null): InputRichBlockBlockQuotation + public static function blockQuote(array $blocks, string|RichText|array|null $credit = null): InputRichBlockBlockQuotation { - $data = [ + $block = new InputRichBlockBlockQuotation([ 'type' => InputRichBlock::TYPE_BLOCK_QUOTATION, 'blocks' => $blocks, - ]; + ]); if ($credit !== null) { - $data['credit'] = $credit; + $block->credit = $credit; } - return new InputRichBlockBlockQuotation($data); + return $block; } - public static function pullQuote(string|RichText|array $text, string|RichText|null $credit = null): InputRichBlockPullQuotation + public static function pullQuote(string|RichText|array $text, string|RichText|array|null $credit = null): InputRichBlockPullQuotation { - $data = [ + $block = new InputRichBlockPullQuotation([ 'type' => InputRichBlock::TYPE_PULL_QUOTATION, - 'text' => $text, - ]; + ]); + $block->text = $text; if ($credit !== null) { - $data['credit'] = $credit; + $block->credit = $credit; } - return new InputRichBlockPullQuotation($data); + return $block; } public static function photo( string $media, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockPhoto { $data = [ 'type' => InputRichBlock::TYPE_PHOTO, @@ -123,22 +128,22 @@ public static function photo( ]), ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockPhoto($data); } public static function video( string $media, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockVideo { $data = [ 'type' => InputRichBlock::TYPE_VIDEO, @@ -148,22 +153,22 @@ public static function video( ]), ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockVideo($data); } public static function audio( string $media, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockAudio { $data = [ 'type' => InputRichBlock::TYPE_AUDIO, @@ -173,22 +178,22 @@ public static function audio( ]), ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockAudio($data); } public static function animation( string $media, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockAnimation { $data = [ 'type' => InputRichBlock::TYPE_ANIMATION, @@ -198,22 +203,22 @@ public static function animation( ]), ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockAnimation($data); } public static function voiceNote( string $media, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockVoiceNote { $data = [ 'type' => InputRichBlock::TYPE_VOICE_NOTE, @@ -223,14 +228,14 @@ public static function voiceNote( ]), ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockVoiceNote($data); } @@ -265,54 +270,55 @@ public static function details( array $blocks, bool $is_open = false ): InputRichBlockDetails { - return new InputRichBlockDetails([ + $block = new InputRichBlockDetails([ 'type' => InputRichBlock::TYPE_DETAILS, - 'summary' => $summary, 'blocks' => $blocks, 'is_open' => $is_open, ]); + $block->summary = $summary; + return $block; } public static function collage( array $blocks, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockCollage { $data = [ 'type' => InputRichBlock::TYPE_COLLAGE, 'blocks' => $blocks, ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockCollage($data); } public static function slideshow( array $blocks, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockSlideshow { $data = [ 'type' => InputRichBlock::TYPE_SLIDESHOW, 'blocks' => $blocks, ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockSlideshow($data); } @@ -322,8 +328,8 @@ public static function map( int $zoom = 15, int $width = 300, int $height = 200, - string|RichText|null $caption = null, - string|RichText|null $credit = null + string|RichText|array|null $caption = null, + string|RichText|array|null $credit = null ): InputRichBlockMap { $data = [ 'type' => InputRichBlock::TYPE_MAP, @@ -333,14 +339,14 @@ public static function map( 'height' => $height, ]; if ($caption !== null || $credit !== null) { - $captionData = []; + $captionBlock = new RichBlockCaption([]); if ($caption !== null) { - $captionData['text'] = $caption; + $captionBlock->text = $caption; } if ($credit !== null) { - $captionData['credit'] = $credit; + $captionBlock->credit = $credit; } - $data['caption'] = new RichBlockCaption($captionData); + $data['caption'] = $captionBlock; } return new InputRichBlockMap($data); } diff --git a/src/Telegram/Factories/RichMessage.php b/src/Telegram/Factories/RichMessage.php index 47f7aea..7af6b36 100644 --- a/src/Telegram/Factories/RichMessage.php +++ b/src/Telegram/Factories/RichMessage.php @@ -42,7 +42,9 @@ public function rtl(bool $v = true): self public function build(): InputRichMessage { $msg = new InputRichMessage([]); - $msg->blocks = $this->blocks; // ← asigna directo (usa __set) + if ($this->blocks !== []) { + $msg->blocks = $this->blocks; + } foreach ($this->options as $k => $v) { $msg->{$k} = $v; } diff --git a/src/Telegram/Text.php b/src/Telegram/Text.php index 76461c1..5960af7 100644 --- a/src/Telegram/Text.php +++ b/src/Telegram/Text.php @@ -211,7 +211,10 @@ public static function richMarked(string|RichText $text): RichTextMarked public static function richDatetime(int $unix): RichTextDateTime { - return new RichTextDateTime(['type' => 'datetime', 'unix' => $unix]); + return new RichTextDateTime([ + 'type' => RichText::TYPE_DATETIME, + 'unix_time' => $unix + ]); } public static function richMath(string $expression): RichTextMathematicalExpression