Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Telegram Bot API for PHP Change Log

## 0.21.1 June 12, 2026

- New #200: Add `RichText` interface and 25 rich text types: `RichTextBold`, `RichTextItalic`, `RichTextUnderline`,
`RichTextStrikethrough`, `RichTextSpoiler`, `RichTextDateTime`, `RichTextTextMention`, `RichTextSubscript`,
`RichTextSuperscript`, `RichTextMarked`, `RichTextCode`, `RichTextCustomEmoji`, `RichTextMathematicalExpression`,
`RichTextUrl`, `RichTextEmailAddress`, `RichTextPhoneNumber`, `RichTextBankCardNumber`, `RichTextMention`,
`RichTextHashtag`, `RichTextCashtag`, `RichTextBotCommand`, `RichTextAnchor`, `RichTextAnchorLink`,
`RichTextReference`, `RichTextReferenceLink`.
- New #200: Add `RichBlockCaption`, `RichBlockTableCell`, and `RichBlockListItem` types.
- New #200: Add `RichBlock` interface and 21 rich block types: `RichBlockParagraph`, `RichBlockSectionHeading`,
`RichBlockPreformatted`, `RichBlockFooter`, `RichBlockDivider`, `RichBlockMathematicalExpression`,
`RichBlockAnchor`, `RichBlockList`, `RichBlockBlockQuotation`, `RichBlockPullQuotation`, `RichBlockCollage`,
`RichBlockSlideshow`, `RichBlockTable`, `RichBlockDetails`, `RichBlockMap`, `RichBlockAnimation`,
`RichBlockAudio`, `RichBlockPhoto`, `RichBlockVideo`, `RichBlockVoiceNote`, `RichBlockThinking`.
- New #200: Add `RichMessage` type.
- New #200: Add `InputRichMessage` and `InputRichMessageContent` types.
- New #200: Add `SendRichMessage` and `SendRichMessageDraft` methods.
- New #200: Add `richMessage` parameter to `EditMessageText` method.
- New #200: Add `richMessage` field to `Message` type.
- New #200: Add `supportsJoinRequestQueries` field to `User` type.
- New #200: Add `guardBot` field to `ChatFullInfo` type.
- New #200: Add `queryId` field to `ChatJoinRequest` type.
- New #200: Add `AnswerChatJoinRequestQuery` and `SendChatJoinRequestWebApp` methods.
- New #200: Add `Link` type.
- New #200: Add `link` field to `PollMedia` type.
- New #200: Add `InputMediaLink` type.
- Enh #200: Make `text` parameter of `EditMessageText` method optional.

## 0.21 May 9, 2026

- New #199: Add `supportsGuestQueries` field to `User` type.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

The package provides a simple and convenient way to interact with the Telegram Bot API.

✔️ Telegram Bot API 10.0 (May 8, 2026) is **fully supported**.
✔️ Telegram Bot API 10.1 (June 11, 2026) is **fully supported**.

♻️ **Zero dependencies** — no third-party libraries, only native PHP.

Expand Down
45 changes: 45 additions & 0 deletions src/Method/AnswerChatJoinRequestQuery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Phptg\BotApi\Method;

use Phptg\BotApi\MethodInterface;
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
use Phptg\BotApi\Transport\HttpMethod;

/**
* @see https://core.telegram.org/bots/api#answerchatjoinrequestquery
*
* @template-implements MethodInterface<true>
*/
final readonly class AnswerChatJoinRequestQuery implements MethodInterface
{
public function __construct(
private string $chatJoinRequestQueryId,
private string $result,
) {}

public function getHttpMethod(): HttpMethod
{
return HttpMethod::POST;
}

public function getApiMethod(): string
{
return 'answerChatJoinRequestQuery';
}

public function getData(): array
{
return [
'chat_join_request_query_id' => $this->chatJoinRequestQueryId,
'result' => $this->result,
];
}

public function getResultType(): TrueValue
{
return new TrueValue();
}
}
45 changes: 45 additions & 0 deletions src/Method/SendChatJoinRequestWebApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace Phptg\BotApi\Method;

use Phptg\BotApi\MethodInterface;
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
use Phptg\BotApi\Transport\HttpMethod;

/**
* @see https://core.telegram.org/bots/api#sendchatjoinrequestwebapp
*
* @template-implements MethodInterface<true>
*/
final readonly class SendChatJoinRequestWebApp implements MethodInterface
{
public function __construct(
private string $chatJoinRequestQueryId,
private string $webAppUrl,
) {}

public function getHttpMethod(): HttpMethod
{
return HttpMethod::POST;
}

public function getApiMethod(): string
{
return 'sendChatJoinRequestWebApp';
}

public function getData(): array
{
return [
'chat_join_request_query_id' => $this->chatJoinRequestQueryId,
'web_app_url' => $this->webAppUrl,
];
}

public function getResultType(): TrueValue
{
return new TrueValue();
}
}
76 changes: 76 additions & 0 deletions src/Method/SendRichMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

declare(strict_types=1);

namespace Phptg\BotApi\Method;

use Phptg\BotApi\MethodInterface;
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;
use Phptg\BotApi\Transport\HttpMethod;
use Phptg\BotApi\Type\ForceReply;
use Phptg\BotApi\Type\InlineKeyboardMarkup;
use Phptg\BotApi\Type\InputRichMessage;
use Phptg\BotApi\Type\Message;
use Phptg\BotApi\Type\ReplyKeyboardMarkup;
use Phptg\BotApi\Type\ReplyKeyboardRemove;
use Phptg\BotApi\Type\ReplyParameters;
use Phptg\BotApi\Type\SuggestedPostParameters;

/**
* @see https://core.telegram.org/bots/api#sendrichmessage
*
* @template-implements MethodInterface<Message>
*/
final readonly class SendRichMessage implements MethodInterface
{
public function __construct(
private int|string $chatId,
private InputRichMessage $richMessage,
private ?string $businessConnectionId = null,
private ?int $messageThreadId = null,
private ?int $directMessagesTopicId = null,
private ?bool $disableNotification = null,
private ?bool $protectContent = null,
private ?bool $allowPaidBroadcast = null,
private ?string $messageEffectId = null,
private ?SuggestedPostParameters $suggestedPostParameters = null,
private ?ReplyParameters $replyParameters = null,
private InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply|null $replyMarkup = null,
) {}

public function getHttpMethod(): HttpMethod
{
return HttpMethod::POST;
}

public function getApiMethod(): string
{
return 'sendRichMessage';
}

public function getData(): array
{
return array_filter(
[
'business_connection_id' => $this->businessConnectionId,
'chat_id' => $this->chatId,
'message_thread_id' => $this->messageThreadId,
'direct_messages_topic_id' => $this->directMessagesTopicId,
'rich_message' => $this->richMessage->toRequestArray(),
'disable_notification' => $this->disableNotification,
'protect_content' => $this->protectContent,
'allow_paid_broadcast' => $this->allowPaidBroadcast,
'message_effect_id' => $this->messageEffectId,
'suggested_post_parameters' => $this->suggestedPostParameters?->toRequestArray(),
'reply_parameters' => $this->replyParameters?->toRequestArray(),
'reply_markup' => $this->replyMarkup?->toRequestArray(),
],
static fn(mixed $value): bool => $value !== null,
);
}

public function getResultType(): ObjectValue
{
return new ObjectValue(Message::class);
}
}
53 changes: 53 additions & 0 deletions src/Method/SendRichMessageDraft.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

namespace Phptg\BotApi\Method;

use Phptg\BotApi\MethodInterface;
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
use Phptg\BotApi\Transport\HttpMethod;
use Phptg\BotApi\Type\InputRichMessage;

/**
* @see https://core.telegram.org/bots/api#sendrichmessagedraft
*
* @template-implements MethodInterface<true>
*/
final readonly class SendRichMessageDraft implements MethodInterface
{
public function __construct(
private int $chatId,
private int $draftId,
private InputRichMessage $richMessage,
private ?int $messageThreadId = null,
) {}

public function getHttpMethod(): HttpMethod
{
return HttpMethod::POST;
}

public function getApiMethod(): string
{
return 'sendRichMessageDraft';
}

public function getData(): array
{
return array_filter(
[
'chat_id' => $this->chatId,
'message_thread_id' => $this->messageThreadId,
'draft_id' => $this->draftId,
'rich_message' => $this->richMessage->toRequestArray(),
],
static fn(mixed $value): bool => $value !== null,
);
}

public function getResultType(): TrueValue
{
return new TrueValue();
}
}
5 changes: 4 additions & 1 deletion src/Method/UpdatingMessage/EditMessageText.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Phptg\BotApi\Transport\HttpMethod;
use Phptg\BotApi\MethodInterface;
use Phptg\BotApi\Type\InlineKeyboardMarkup;
use Phptg\BotApi\Type\InputRichMessage;
use Phptg\BotApi\Type\LinkPreviewOptions;
use Phptg\BotApi\Type\Message;
use Phptg\BotApi\Type\MessageEntity;
Expand All @@ -23,7 +24,7 @@
* @param MessageEntity[]|null $entities
*/
public function __construct(
private string $text,
private ?string $text = null,
private ?string $businessConnectionId = null,
private int|string|null $chatId = null,
private ?int $messageId = null,
Expand All @@ -32,6 +33,7 @@ public function __construct(
private ?array $entities = null,
private ?LinkPreviewOptions $linkPreviewOptions = null,
private ?InlineKeyboardMarkup $replyMarkup = null,
private ?InputRichMessage $richMessage = null,
) {}
Comment on lines 33 to 37

public function getHttpMethod(): HttpMethod
Expand Down Expand Up @@ -59,6 +61,7 @@ public function getData(): array
$this->entities,
),
'link_preview_options' => $this->linkPreviewOptions?->toRequestArray(),
'rich_message' => $this->richMessage?->toRequestArray(),
'reply_markup' => $this->replyMarkup?->toRequestArray(),
],
static fn(mixed $value): bool => $value !== null,
Expand Down
3 changes: 3 additions & 0 deletions src/ParseResult/ObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use ReflectionProperty;
use Phptg\BotApi\ParseResult\ValueProcessor\BackgroundFillValue;
use Phptg\BotApi\ParseResult\ValueProcessor\BackgroundTypeValue;
use Phptg\BotApi\ParseResult\ValueProcessor\RichBlockValue;
use Phptg\BotApi\ParseResult\ValueProcessor\BooleanValue;
use Phptg\BotApi\ParseResult\ValueProcessor\ChatBoostSourceValue;
use Phptg\BotApi\ParseResult\ValueProcessor\ChatMemberValue;
Expand All @@ -28,6 +29,7 @@
use Phptg\BotApi\ParseResult\ValueProcessor\ValueProcessorInterface;
use Phptg\BotApi\Type\BackgroundFill;
use Phptg\BotApi\Type\BackgroundType;
use Phptg\BotApi\Type\RichBlock;
use Phptg\BotApi\Type\ChatBoostSource;
use Phptg\BotApi\Type\ChatMember;
use Phptg\BotApi\Type\MessageOrigin;
Expand Down Expand Up @@ -165,6 +167,7 @@ private function getTypeMap(): array
'bool' => new BooleanValue(),
DateTimeImmutable::class => new DateValue(),
ChatBoostSource::class => new ChatBoostSourceValue(),
RichBlock::class => new RichBlockValue(),
BackgroundFill::class => new BackgroundFillValue(),
BackgroundType::class => new BackgroundTypeValue(),
ChatMember::class => new ChatMemberValue(),
Expand Down
71 changes: 71 additions & 0 deletions src/ParseResult/ValueProcessor/RichBlockValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

namespace Phptg\BotApi\ParseResult\ValueProcessor;

use Phptg\BotApi\Type\RichBlock;
use Phptg\BotApi\Type\RichBlockParagraph;
use Phptg\BotApi\Type\RichBlockDivider;
use Phptg\BotApi\Type\RichBlockAnchor;
use Phptg\BotApi\Type\RichBlockBlockQuotation;
use Phptg\BotApi\Type\RichBlockCollage;
use Phptg\BotApi\Type\RichBlockSlideshow;
use Phptg\BotApi\Type\RichBlockDetails;
use Phptg\BotApi\Type\RichBlockAnimation;
use Phptg\BotApi\Type\RichBlockAudio;
use Phptg\BotApi\Type\RichBlockPhoto;
use Phptg\BotApi\Type\RichBlockVideo;
use Phptg\BotApi\Type\RichBlockThinking;
use Phptg\BotApi\Type\RichBlockVoiceNote;
use Phptg\BotApi\Type\RichBlockMap;
use Phptg\BotApi\Type\RichBlockTable;
use Phptg\BotApi\Type\RichBlockPullQuotation;
use Phptg\BotApi\Type\RichBlockList;
use Phptg\BotApi\Type\RichBlockMathematicalExpression;
use Phptg\BotApi\Type\RichBlockFooter;
use Phptg\BotApi\Type\RichBlockPreformatted;
use Phptg\BotApi\Type\RichBlockSectionHeading;

/**
* @template-extends InterfaceValue<RichBlock>
*/
final readonly class RichBlockValue extends InterfaceValue
{
public function getTypeKey(): string
{
return 'type';
}

public function getClassMap(): array
{
return [
'paragraph' => RichBlockParagraph::class,
'heading' => RichBlockSectionHeading::class,
'pre' => RichBlockPreformatted::class,
'footer' => RichBlockFooter::class,
'divider' => RichBlockDivider::class,
'mathematical_expression' => RichBlockMathematicalExpression::class,
'anchor' => RichBlockAnchor::class,
'list' => RichBlockList::class,
'blockquote' => RichBlockBlockQuotation::class,
'pullquote' => RichBlockPullQuotation::class,
'collage' => RichBlockCollage::class,
'slideshow' => RichBlockSlideshow::class,
'table' => RichBlockTable::class,
'details' => RichBlockDetails::class,
'map' => RichBlockMap::class,
'animation' => RichBlockAnimation::class,
'audio' => RichBlockAudio::class,
'photo' => RichBlockPhoto::class,
'video' => RichBlockVideo::class,
'voice_note' => RichBlockVoiceNote::class,
'thinking' => RichBlockThinking::class,
];
}

public function getUnknownTypeMessage(): string
{
return 'Unknown rich block type.';
}
}
Loading
Loading