Skip to content

Commit c295ae1

Browse files
authored
Telegram Bot API 9.4 (#186)
1 parent 3dd0589 commit c295ae1

34 files changed

Lines changed: 822 additions & 1 deletion

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Telegram Bot API for PHP Change Log
22

3+
## 0.14.1 February 9, 2026
4+
5+
- New #186: Add `SetMyProfilePhoto`, `RemoveMyProfilePhoto` and `GetUserProfileAudios` methods.
6+
- New #186: Add `ChatOwnerLeft`, `ChatOwnerChanged`, `VideoQuality` and `UserProfileAudios` types.
7+
- New #186: Add `allowsUsersToCreateTopics` field to `User` type.
8+
- New #186: Add `iconCustomEmojiId` and `style` fields to `KeyboardButton` type.
9+
- New #186: Add `iconCustomEmojiId` and `style` fields to `InlineKeyboardButton` type.
10+
- New #186: Add `chatOwnerLeft` and `chatOwnerChanged` fields to `Message` type.
11+
- New #186: Add `qualities` field to `Video` type.
12+
- New #186: Add `firstProfileAudio` field to `ChatFullInfo` type.
13+
- New #186: Add `rarity` field to `UniqueGiftModel` type.
14+
- New #186: Add `isBurned` field to `UniqueGift` type.
15+
316
## 0.14 February 7, 2026
417

518
- New #182: Introduce resource readers that handle reading content from different types of resources stored in

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.3 (December 31, 2025) is **fully supported**.
18+
✔️ Telegram Bot API 9.4 (February 9, 2026) is **fully supported**.
1919

2020
> [!IMPORTANT]
2121
> This project is developed and maintained by [Sergei Predvoditelev](https://github.com/vjik).
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\MethodInterface;
8+
use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue;
9+
use Phptg\BotApi\Transport\HttpMethod;
10+
use Phptg\BotApi\Type\UserProfileAudios;
11+
12+
/**
13+
* @see https://core.telegram.org/bots/api#getuserprofileaudios
14+
*
15+
* @template-implements MethodInterface<UserProfileAudios>
16+
*/
17+
final readonly class GetUserProfileAudios implements MethodInterface
18+
{
19+
public function __construct(
20+
private int $userId,
21+
private ?int $offset = null,
22+
private ?int $limit = null,
23+
) {}
24+
25+
public function getHttpMethod(): HttpMethod
26+
{
27+
return HttpMethod::GET;
28+
}
29+
30+
public function getApiMethod(): string
31+
{
32+
return 'getUserProfileAudios';
33+
}
34+
35+
public function getData(): array
36+
{
37+
return array_filter(
38+
[
39+
'user_id' => $this->userId,
40+
'offset' => $this->offset,
41+
'limit' => $this->limit,
42+
],
43+
static fn(mixed $value): bool => $value !== null,
44+
);
45+
}
46+
47+
public function getResultType(): ObjectValue
48+
{
49+
return new ObjectValue(UserProfileAudios::class);
50+
}
51+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\MethodInterface;
8+
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
9+
use Phptg\BotApi\Transport\HttpMethod;
10+
11+
/**
12+
* @see https://core.telegram.org/bots/api#removemyprofilephoto
13+
*
14+
* @template-implements MethodInterface<true>
15+
*
16+
* @api
17+
*/
18+
final readonly class RemoveMyProfilePhoto implements MethodInterface
19+
{
20+
public function getHttpMethod(): HttpMethod
21+
{
22+
return HttpMethod::POST;
23+
}
24+
25+
public function getApiMethod(): string
26+
{
27+
return 'removeMyProfilePhoto';
28+
}
29+
30+
public function getData(): array
31+
{
32+
return [];
33+
}
34+
35+
public function getResultType(): TrueValue
36+
{
37+
return new TrueValue();
38+
}
39+
}

src/Method/SetMyProfilePhoto.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Method;
6+
7+
use Phptg\BotApi\FileCollector;
8+
use Phptg\BotApi\MethodInterface;
9+
use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue;
10+
use Phptg\BotApi\Transport\HttpMethod;
11+
use Phptg\BotApi\Type\InputProfilePhoto;
12+
13+
/**
14+
* @see https://core.telegram.org/bots/api#setmyprofilephoto
15+
*
16+
* @template-implements MethodInterface<true>
17+
*
18+
* @api
19+
*/
20+
final readonly class SetMyProfilePhoto implements MethodInterface
21+
{
22+
public function __construct(
23+
private InputProfilePhoto $photo,
24+
) {}
25+
26+
public function getHttpMethod(): HttpMethod
27+
{
28+
return HttpMethod::POST;
29+
}
30+
31+
public function getApiMethod(): string
32+
{
33+
return 'setMyProfilePhoto';
34+
}
35+
36+
public function getData(): array
37+
{
38+
$fileCollector = new FileCollector();
39+
$photo = $this->photo->toRequestArray($fileCollector);
40+
41+
return [
42+
'photo' => $photo,
43+
...$fileCollector->get(),
44+
];
45+
}
46+
47+
public function getResultType(): TrueValue
48+
{
49+
return new TrueValue();
50+
}
51+
}

src/TelegramBotApi.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
use Phptg\BotApi\Method\GetMyStarBalance;
6262
use Phptg\BotApi\Method\GetUserChatBoosts;
6363
use Phptg\BotApi\Method\GetUserGifts;
64+
use Phptg\BotApi\Method\GetUserProfileAudios;
6465
use Phptg\BotApi\Method\GetUserProfilePhotos;
6566
use Phptg\BotApi\Method\GiftPremiumSubscription;
6667
use Phptg\BotApi\Method\HideGeneralForumTopic;
@@ -82,6 +83,7 @@
8283
use Phptg\BotApi\Method\PromoteChatMember;
8384
use Phptg\BotApi\Method\RepostStory;
8485
use Phptg\BotApi\Method\RemoveBusinessAccountProfilePhoto;
86+
use Phptg\BotApi\Method\RemoveMyProfilePhoto;
8587
use Phptg\BotApi\Method\RemoveChatVerification;
8688
use Phptg\BotApi\Method\RemoveUserVerification;
8789
use Phptg\BotApi\Method\ReopenForumTopic;
@@ -123,6 +125,7 @@
123125
use Phptg\BotApi\Method\SetMyDefaultAdministratorRights;
124126
use Phptg\BotApi\Method\SetMyDescription;
125127
use Phptg\BotApi\Method\SetMyName;
128+
use Phptg\BotApi\Method\SetMyProfilePhoto;
126129
use Phptg\BotApi\Method\SetMyShortDescription;
127130
use Phptg\BotApi\Method\SetUserEmojiStatus;
128131
use Phptg\BotApi\Method\Sticker\AddStickerToSet;
@@ -236,6 +239,7 @@
236239
use Phptg\BotApi\Type\Update\WebhookInfo;
237240
use Phptg\BotApi\Type\User;
238241
use Phptg\BotApi\Type\UserChatBoosts;
242+
use Phptg\BotApi\Type\UserProfileAudios;
239243
use Phptg\BotApi\Type\UserProfilePhotos;
240244

241245
use function extension_loaded;
@@ -1459,6 +1463,19 @@ public function getUserGifts(
14591463
);
14601464
}
14611465

1466+
/**
1467+
* @see https://core.telegram.org/bots/api#getuserprofileaudios
1468+
*/
1469+
public function getUserProfileAudios(
1470+
int $userId,
1471+
?int $offset = null,
1472+
?int $limit = null,
1473+
): FailResult|UserProfileAudios {
1474+
return $this->call(
1475+
new GetUserProfileAudios($userId, $offset, $limit),
1476+
);
1477+
}
1478+
14621479
/**
14631480
* @see https://core.telegram.org/bots/api#getuserprofilephotos
14641481
*/
@@ -1683,6 +1700,14 @@ public function removeBusinessAccountProfilePhoto(
16831700
);
16841701
}
16851702

1703+
/**
1704+
* @see https://core.telegram.org/bots/api#removemyprofilephoto
1705+
*/
1706+
public function removeMyProfilePhoto(): FailResult|true
1707+
{
1708+
return $this->call(new RemoveMyProfilePhoto());
1709+
}
1710+
16861711
/**
16871712
* @see https://core.telegram.org/bots/api#removechatverification
16881713
*/
@@ -2956,6 +2981,14 @@ public function setMyName(?string $name = null, ?string $languageCode = null): F
29562981
return $this->call(new SetMyName($name, $languageCode));
29572982
}
29582983

2984+
/**
2985+
* @see https://core.telegram.org/bots/api#setmyprofilephoto
2986+
*/
2987+
public function setMyProfilePhoto(InputProfilePhoto $photo): FailResult|true
2988+
{
2989+
return $this->call(new SetMyProfilePhoto($photo));
2990+
}
2991+
29592992
/**
29602993
* @see https://core.telegram.org/bots/api#setmyshortdescription
29612994
*/

src/Type/ChatFullInfo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ public function __construct(
7373
public ?UserRating $rating = null,
7474
public ?UniqueGiftColors $uniqueGiftColors = null,
7575
public ?int $paidMessageStarCount = null,
76+
public ?Audio $firstProfileAudio = null,
7677
) {}
7778
}

src/Type/ChatOwnerChanged.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Type;
6+
7+
/**
8+
* @see https://core.telegram.org/bots/api#chatownerchanged
9+
*
10+
* @api
11+
*/
12+
final readonly class ChatOwnerChanged
13+
{
14+
public function __construct(
15+
public User $newOwner,
16+
) {}
17+
}

src/Type/ChatOwnerLeft.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Phptg\BotApi\Type;
6+
7+
/**
8+
* @see https://core.telegram.org/bots/api#chatownerleft
9+
*
10+
* @api
11+
*/
12+
final readonly class ChatOwnerLeft
13+
{
14+
public function __construct(
15+
public ?User $newOwner = null,
16+
) {}
17+
}

src/Type/InlineKeyboardButton.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ public function __construct(
2525
public ?CallbackGame $callbackGame = null,
2626
public ?bool $pay = null,
2727
public ?CopyTextButton $copyText = null,
28+
public ?string $iconCustomEmojiId = null,
29+
public ?string $style = null,
2830
) {}
2931

3032
public function toRequestArray(): array
3133
{
3234
return array_filter(
3335
[
3436
'text' => $this->text,
37+
'icon_custom_emoji_id' => $this->iconCustomEmojiId,
38+
'style' => $this->style,
3539
'url' => $this->url,
3640
'callback_data' => $this->callbackData,
3741
'web_app' => $this->webApp?->toRequestArray(),

0 commit comments

Comments
 (0)