Skip to content

Commit 1464f58

Browse files
authored
Telegram Bot API 9.3 (#177)
1 parent df6a726 commit 1464f58

51 files changed

Lines changed: 1172 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
# Telegram Bot API for PHP Change Log
22

3+
## 0.12.0 January 1, 2026
4+
5+
- New #177: Add `hasTopicsEnabled` field to `User` type.
6+
- New #177: Add `isNameImplicit` field to `ForumTopic` and `ForumTopicCreated` types.
7+
- New #177: Add `giftUpgradeSent` field to `Message` type.
8+
- New #177: Add `giftId`, `isPremium`, `isFromBlockchain` and `colors` fields to `UniqueGift` type.
9+
- New #177: Add `isPremium`, `hasColors`, `personalTotalCount`, `personalRemainingCount`, `background` and
10+
`uniqueGiftVariantCount` fields to `Gift` type.
11+
- New #177: Add `isUpgradeSeparate` and `uniqueGiftNumber` fields to `GiftInfo` and `OwnedGiftRegular` types.
12+
- New #177: Add `giftsFromChannels` field to `AcceptedGiftTypes` type.
13+
- New #177: Add `rating`, `uniqueGiftColors` and `paidMessageStarCount` fields to `ChatFullInfo` type.
14+
- New #177: Add `UniqueGiftColors`, `GiftBackground` and `UserRating` types.
15+
- New #177: Add `SendMessageDraft`, `getUserGifts`, `getChatGifts` and `repostStory` methods.
16+
- New #177: Add `excludeFromBlockchain` parameter to `getBusinessAccountGifts` method.
17+
- New #177: Add `messageEffectId` parameter to `forwardMessage` and `copyMessage` methods.
18+
- New #177: Add `completedByChat` field to `ChecklistTask` type.
19+
- Chg #177: Replace `lastResaleStarCount` field with `lastResaleCurrency` and `lastResaleAmount` fields in
20+
`UniqueGiftInfo` type.
21+
- Chg #177: Replace `excludeLimited` parameter with `excludeLimitedUpgradable` and `excludeLimitedNonUpgradable`
22+
parameters in `getBusinessAccountGifts` method.
23+
324
## 0.11.0 December 29, 2025
425

5-
- Chg #171: Simplify `TransportInterface` implementations by replacing single `send()` method with specific methods:
26+
- Chg #171: Simplify `TransportInterface` implementations by replacing single `send()` method with specific methods:
627
`get()`, `post()`, and `postWithFiles()`.
728
- Chg #175: Change PHP constraint in `composer.json` to `8.2 - 8.5`.
829

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

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

18-
✔️ Telegram Bot API 9.2 (August 15, 2025) is **fully supported**.
18+
✔️ Telegram Bot API 9.3 (December 31, 2025) is **fully supported**.
1919

2020
## Requirements
2121

src/Method/CopyMessage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function __construct(
4242
private ?bool $allowPaidBroadcast = null,
4343
private ?int $videoStartTimestamp = null,
4444
private ?int $directMessagesTopicId = null,
45+
private ?string $messageEffectId = null,
4546
private ?SuggestedPostParameters $suggestedPostParameters = null,
4647
) {}
4748

@@ -76,6 +77,7 @@ public function getData(): array
7677
'disable_notification' => $this->disableNotification,
7778
'protect_content' => $this->protectContent,
7879
'allow_paid_broadcast' => $this->allowPaidBroadcast,
80+
'message_effect_id' => $this->messageEffectId,
7981
'suggested_post_parameters' => $this->suggestedPostParameters?->toRequestArray(),
8082
'reply_parameters' => $this->replyParameters?->toRequestArray(),
8183
'reply_markup' => $this->replyMarkup?->toRequestArray(),

src/Method/ForwardMessage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function __construct(
2626
private ?bool $protectContent = null,
2727
private ?int $videoStartTimestamp = null,
2828
private ?int $directMessagesTopicId = null,
29+
private ?string $messageEffectId = null,
2930
private ?SuggestedPostParameters $suggestedPostParameters = null,
3031
) {}
3132

@@ -50,6 +51,7 @@ public function getData(): array
5051
'video_start_timestamp' => $this->videoStartTimestamp,
5152
'disable_notification' => $this->disableNotification,
5253
'protect_content' => $this->protectContent,
54+
'message_effect_id' => $this->messageEffectId,
5355
'suggested_post_parameters' => $this->suggestedPostParameters?->toRequestArray(),
5456
'message_id' => $this->messageId,
5557
],

src/Method/GetBusinessAccountGifts.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ public function __construct(
2323
private ?bool $excludeUnsaved = null,
2424
private ?bool $excludeSaved = null,
2525
private ?bool $excludeUnlimited = null,
26-
private ?bool $excludeLimited = null,
26+
private ?bool $excludeLimitedUpgradable = null,
27+
private ?bool $excludeLimitedNonUpgradable = null,
2728
private ?bool $excludeUnique = null,
29+
private ?bool $excludeFromBlockchain = null,
2830
private ?bool $sortByPrice = null,
2931
private ?string $offset = null,
3032
private ?int $limit = null,
@@ -47,8 +49,10 @@ public function getData(): array
4749
'exclude_unsaved' => $this->excludeUnsaved,
4850
'exclude_saved' => $this->excludeSaved,
4951
'exclude_unlimited' => $this->excludeUnlimited,
50-
'exclude_limited' => $this->excludeLimited,
52+
'exclude_limited_upgradable' => $this->excludeLimitedUpgradable,
53+
'exclude_limited_non_upgradable' => $this->excludeLimitedNonUpgradable,
5154
'exclude_unique' => $this->excludeUnique,
55+
'exclude_from_blockchain' => $this->excludeFromBlockchain,
5256
'sort_by_price' => $this->sortByPrice,
5357
'offset' => $this->offset,
5458
'limit' => $this->limit,

src/Method/GetChatGifts.php

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;
8+
use Phptg\BotApi\Transport\HttpMethod;
9+
use Phptg\BotApi\MethodInterface;
10+
use Phptg\BotApi\Type\OwnedGifts;
11+
12+
/**
13+
* @see https://core.telegram.org/bots/api#getchatgifts
14+
*
15+
* @template-implements MethodInterface<OwnedGifts>
16+
*
17+
* @api
18+
*/
19+
final readonly class GetChatGifts implements MethodInterface
20+
{
21+
public function __construct(
22+
private int|string $chatId,
23+
private ?bool $excludeUnsaved = null,
24+
private ?bool $excludeSaved = null,
25+
private ?bool $excludeUnlimited = null,
26+
private ?bool $excludeLimitedUpgradable = null,
27+
private ?bool $excludeLimitedNonUpgradable = null,
28+
private ?bool $excludeFromBlockchain = null,
29+
private ?bool $excludeUnique = null,
30+
private ?bool $sortByPrice = null,
31+
private ?string $offset = null,
32+
private ?int $limit = null,
33+
) {}
34+
35+
public function getHttpMethod(): HttpMethod
36+
{
37+
return HttpMethod::GET;
38+
}
39+
40+
public function getApiMethod(): string
41+
{
42+
return 'getChatGifts';
43+
}
44+
45+
public function getData(): array
46+
{
47+
return array_filter([
48+
'chat_id' => $this->chatId,
49+
'exclude_unsaved' => $this->excludeUnsaved,
50+
'exclude_saved' => $this->excludeSaved,
51+
'exclude_unlimited' => $this->excludeUnlimited,
52+
'exclude_limited_upgradable' => $this->excludeLimitedUpgradable,
53+
'exclude_limited_non_upgradable' => $this->excludeLimitedNonUpgradable,
54+
'exclude_from_blockchain' => $this->excludeFromBlockchain,
55+
'exclude_unique' => $this->excludeUnique,
56+
'sort_by_price' => $this->sortByPrice,
57+
'offset' => $this->offset,
58+
'limit' => $this->limit,
59+
], static fn($value) => $value !== null);
60+
}
61+
62+
public function getResultType(): ObjectValue
63+
{
64+
return new ObjectValue(OwnedGifts::class);
65+
}
66+
}

src/Method/GetUserGifts.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;
8+
use Phptg\BotApi\Transport\HttpMethod;
9+
use Phptg\BotApi\MethodInterface;
10+
use Phptg\BotApi\Type\OwnedGifts;
11+
12+
/**
13+
* @see https://core.telegram.org/bots/api#getusergifts
14+
*
15+
* @template-implements MethodInterface<OwnedGifts>
16+
*
17+
* @api
18+
*/
19+
final readonly class GetUserGifts implements MethodInterface
20+
{
21+
public function __construct(
22+
private int $userId,
23+
private ?bool $excludeUnlimited = null,
24+
private ?bool $excludeLimitedUpgradable = null,
25+
private ?bool $excludeLimitedNonUpgradable = null,
26+
private ?bool $excludeFromBlockchain = null,
27+
private ?bool $excludeUnique = null,
28+
private ?bool $sortByPrice = null,
29+
private ?string $offset = null,
30+
private ?int $limit = null,
31+
) {}
32+
33+
public function getHttpMethod(): HttpMethod
34+
{
35+
return HttpMethod::GET;
36+
}
37+
38+
public function getApiMethod(): string
39+
{
40+
return 'getUserGifts';
41+
}
42+
43+
public function getData(): array
44+
{
45+
return array_filter([
46+
'user_id' => $this->userId,
47+
'exclude_unlimited' => $this->excludeUnlimited,
48+
'exclude_limited_upgradable' => $this->excludeLimitedUpgradable,
49+
'exclude_limited_non_upgradable' => $this->excludeLimitedNonUpgradable,
50+
'exclude_from_blockchain' => $this->excludeFromBlockchain,
51+
'exclude_unique' => $this->excludeUnique,
52+
'sort_by_price' => $this->sortByPrice,
53+
'offset' => $this->offset,
54+
'limit' => $this->limit,
55+
], static fn($value) => $value !== null);
56+
}
57+
58+
public function getResultType(): ObjectValue
59+
{
60+
return new ObjectValue(OwnedGifts::class);
61+
}
62+
}

src/Method/RepostStory.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;
8+
use Phptg\BotApi\Transport\HttpMethod;
9+
use Phptg\BotApi\MethodInterface;
10+
use Phptg\BotApi\Type\Story;
11+
12+
/**
13+
* @see https://core.telegram.org/bots/api#repoststory
14+
*
15+
* @template-implements MethodInterface<Story>
16+
*
17+
* @api
18+
*/
19+
final readonly class RepostStory implements MethodInterface
20+
{
21+
public function __construct(
22+
private string $businessConnectionId,
23+
private int $fromChatId,
24+
private int $fromStoryId,
25+
private int $activePeriod,
26+
private ?bool $postToChatPage = null,
27+
private ?bool $protectContent = null,
28+
) {}
29+
30+
public function getHttpMethod(): HttpMethod
31+
{
32+
return HttpMethod::POST;
33+
}
34+
35+
public function getApiMethod(): string
36+
{
37+
return 'repostStory';
38+
}
39+
40+
public function getData(): array
41+
{
42+
return array_filter([
43+
'business_connection_id' => $this->businessConnectionId,
44+
'from_chat_id' => $this->fromChatId,
45+
'from_story_id' => $this->fromStoryId,
46+
'active_period' => $this->activePeriod,
47+
'post_to_chat_page' => $this->postToChatPage,
48+
'protect_content' => $this->protectContent,
49+
], static fn($value) => $value !== null);
50+
}
51+
52+
public function getResultType(): ObjectValue
53+
{
54+
return new ObjectValue(Story::class);
55+
}
56+
}

src/Method/SendMessageDraft.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
8+
use Phptg\BotApi\Transport\HttpMethod;
9+
use Phptg\BotApi\MethodInterface;
10+
use Phptg\BotApi\Type\MessageEntity;
11+
12+
/**
13+
* @see https://core.telegram.org/bots/api#sendmessagedraft
14+
*
15+
* @template-implements MethodInterface<true>
16+
*/
17+
final readonly class SendMessageDraft implements MethodInterface
18+
{
19+
/**
20+
* @param MessageEntity[]|null $entities
21+
*/
22+
public function __construct(
23+
private int $chatId,
24+
private int $draftId,
25+
private string $text,
26+
private ?int $messageThreadId = null,
27+
private ?string $parseMode = null,
28+
private ?array $entities = null,
29+
) {}
30+
31+
public function getHttpMethod(): HttpMethod
32+
{
33+
return HttpMethod::POST;
34+
}
35+
36+
public function getApiMethod(): string
37+
{
38+
return 'sendMessageDraft';
39+
}
40+
41+
public function getData(): array
42+
{
43+
return array_filter(
44+
[
45+
'chat_id' => $this->chatId,
46+
'message_thread_id' => $this->messageThreadId,
47+
'draft_id' => $this->draftId,
48+
'text' => $this->text,
49+
'parse_mode' => $this->parseMode,
50+
'entities' => $this->entities === null ? null : array_map(
51+
static fn(MessageEntity $entity) => $entity->toRequestArray(),
52+
$this->entities,
53+
),
54+
],
55+
static fn(mixed $value): bool => $value !== null,
56+
);
57+
}
58+
59+
public function getResultType(): TrueValue
60+
{
61+
return new TrueValue();
62+
}
63+
}

0 commit comments

Comments
 (0)