Skip to content

Commit fc28e3e

Browse files
authored
Merge pull request #5 from devrabie/feature/telegram-api-7.3-support
Add support for Telegram Bot API 7.3
2 parents 6d51208 + 370e196 commit fc28e3e

12 files changed

+258
-15
lines changed

CHANGELOG.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,53 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
77
### Notes
88
- [:ledger: View file changes][Unreleased]
99
### Added
10-
- Bot API 7.2 support. This includes:
11-
- Business Account Integration (New entities: `BusinessConnection`, `BusinessMessagesDeleted`; Updated `Update.php`, `Request.php`, `Message.php`)
12-
- Business Information Entities (New entities: `BusinessIntro`, `BusinessLocation`, `BusinessOpeningHours`, `BusinessOpeningHoursInterval`; Updated `Chat.php`)
13-
- Sticker Pack Modifications (Updated `StickerSet.php`, `InputSticker.php`, `Request.php`)
14-
- Request & Shared Object Improvements (New entity: `SharedUser`; Updated `KeyboardButtonRequestUsers.php`, `KeyboardButtonRequestChat.php`, `UsersShared.php`, `ChatShared.php`)
15-
- Miscellaneous Changes (New entity: `Birthdate`; Updated `Chat.php`, `Message.php`, `User.php`)
1610
### Changed
1711
### Deprecated
1812
### Removed
1913
### Fixed
2014
### Security
2115

16+
## [1.0.3] - 2024-05-07
17+
### Notes
18+
- [:ledger: View file changes][1.0.3]
19+
- Support for Telegram Bot API 7.3.
20+
### Added
21+
- **Poll Enhancements:**
22+
- New entity `InputPollOption` (`src/Entities/Poll/InputPollOption.php`) with properties `text` and optional `text_entities`.
23+
- Added optional property `question_entities` (array of `MessageEntity`) to `src/Entities/Poll.php`.
24+
- Added optional property `text_entities` (array of `MessageEntity`) to `src/Entities/PollOption.php`.
25+
- Updated `sendPoll` method in `src/Request.php`:
26+
- Changed `options` parameter to be an array of `InputPollOption`.
27+
- Added optional parameters `question_parse_mode` (string) and `question_entities` (array of `MessageEntity`).
28+
- **Chat and getChat Method Refactoring:**
29+
- New entity `ChatFullInfo` (`src/Entities/ChatFullInfo.php`) containing all properties from `Chat` entity plus properties from `getChat` (e.g., `description`, `invite_link`, `pinned_message`, `bio`) and new optional property `max_reaction_count` (integer).
30+
- Updated `getChat` method in `src/Request.php` docblock to return a `ServerResponse` with a `ChatFullInfo` object.
31+
- **Miscellaneous Updates:**
32+
- New Chat Background entities:
33+
- `src/Entities/ChatBackground.php`
34+
- `src/Entities/Background/BackgroundType.php`
35+
- `src/Entities/Background/BackgroundFill.php`
36+
- Added optional property `chat_background_set` (`ChatBackground`) to `src/Entities/Message.php`.
37+
- Added optional property `via_join_request` (boolean) to `src/Entities/ChatMemberUpdated.php`.
38+
- Added optional parameter `live_period` (integer) to `editMessageLiveLocation` method in `src/Request.php`.
39+
### Changed
40+
- Version bumped to 1.0.3.
41+
### Deprecated
42+
### Removed
43+
### Fixed
44+
### Security
45+
2246
## [1.0.2] - 2025-07-04
2347
### Notes
2448
- [:ledger: View file changes][1.0.2]
2549
- Support for Telegram Bot API 7.2.
2650
### Added
27-
- All features from Telegram Bot API 7.2 update (see Unreleased section above for details).
51+
- Bot API 7.2 support. This includes:
52+
- Business Account Integration (New entities: `BusinessConnection`, `BusinessMessagesDeleted`; Updated `Update.php`, `Request.php`, `Message.php`)
53+
- Business Information Entities (New entities: `BusinessIntro`, `BusinessLocation`, `BusinessOpeningHours`, `BusinessOpeningHoursInterval`; Updated `Chat.php`)
54+
- Sticker Pack Modifications (Updated `StickerSet.php`, `InputSticker.php`, `Request.php`)
55+
- Request & Shared Object Improvements (New entity: `SharedUser`; Updated `KeyboardButtonRequestUsers.php`, `KeyboardButtonRequestChat.php`, `UsersShared.php`, `ChatShared.php`)
56+
- Miscellaneous Changes (New entity: `Birthdate`; Updated `Chat.php`, `Message.php`, `User.php`)
2857
### Changed
2958
- Version bumped to 1.0.2.
3059
### Deprecated
@@ -713,7 +742,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
713742
[PSR-3]: https://www.php-fig.org/psr/psr-3
714743
[Tidelift]: https://tidelift.com/subscription/pkg/packagist-longman-telegram-bot?utm_source=packagist-longman-telegram-bot&utm_medium=referral&utm_campaign=changelog
715744

716-
[Unreleased]: https://github.com/php-telegram-bot/core/compare/1.0.2...develop
745+
[Unreleased]: https://github.com/php-telegram-bot/core/compare/1.0.3...develop
746+
[1.0.3]: https://github.com/php-telegram-bot/core/compare/1.0.2...1.0.3
717747
[1.0.2]: https://github.com/php-telegram-bot/core/compare/0.83.0...1.0.2
718748
[0.83.0]: https://github.com/php-telegram-bot/core/compare/0.82.0...0.83.0
719749
[0.82.0]: https://github.com/php-telegram-bot/core/compare/0.81.0...0.82.0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities\Background;
13+
14+
/**
15+
* Class BackgroundFill
16+
*
17+
* The background is automatically filled based on the selected colors.
18+
*
19+
* @link https://core.telegram.org/bots/api#backgroundfill
20+
*
21+
* @method string getType() Type of the fill, always “fill”
22+
* @method int getTopColor() The color of the top gradient fill as a RGB24 value
23+
* @method int getBottomColor() The color of the bottom gradient fill as a RGB24 value
24+
* @method int getRotationAngle() Clockwise rotation angle of the background fill in degrees; 0-359
25+
*/
26+
class BackgroundFill extends BackgroundType
27+
{
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
public function __construct(array $data = [])
32+
{
33+
$data['type'] = 'fill';
34+
parent::__construct($data);
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities\Background;
13+
14+
use Longman\TelegramBot\Entities\Entity;
15+
16+
/**
17+
* Class BackgroundType
18+
*
19+
* This object represents the type of a background. Currently, it can be one of
20+
* - BackgroundTypeFill
21+
* - BackgroundTypeWallpaper
22+
* - BackgroundTypePattern
23+
* - BackgroundTypeChatTheme
24+
*
25+
* @link https://core.telegram.org/bots/api#backgroundtype
26+
*
27+
* @method string getType() Type of the background
28+
*/
29+
class BackgroundType extends Entity
30+
{
31+
// Further specific properties depend on the actual type of background,
32+
// which will be handled by subclasses or by checking the 'type' field.
33+
// For example, BackgroundTypeFill, BackgroundTypeWallpaper, etc.
34+
}

src/Entities/ChatBackground.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities;
13+
14+
use Longman\TelegramBot\Entities\Background\BackgroundType;
15+
16+
/**
17+
* Class ChatBackground
18+
*
19+
* This object represents a chat background.
20+
*
21+
* @link https://core.telegram.org/bots/api#chatbackground
22+
*
23+
* @method BackgroundType getType() Type of the background
24+
*/
25+
class ChatBackground extends Entity
26+
{
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
protected function subEntities(): array
31+
{
32+
return [
33+
'type' => BackgroundType::class,
34+
];
35+
}
36+
}

src/Entities/ChatFullInfo.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities;
13+
14+
/**
15+
* Class ChatFullInfo
16+
*
17+
* This object contains full information about a chat.
18+
*
19+
* @link https://core.telegram.org/bots/api#chatfullinfo
20+
*
21+
* @method string getDescription() Optional. Description, for groups, supergroups and channel chats.
22+
* @method string getInviteLink() Optional. Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.
23+
* @method Message getPinnedMessage() Optional. The most recent pinned message (by sending date). Returned only in getChat.
24+
* @method ChatPermissions getPermissions() Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
25+
* @method int getSlowModeDelay() Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds. Returned only in getChat.
26+
* @method int getUnrestrictBoostCount() Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions.
27+
* @method int getMessageAutoDeleteTime() Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
28+
* @method bool getHasAggressiveAntiSpamEnabled() Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators.
29+
* @method bool getHasHiddenMembers() Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat.
30+
* @method bool getHasProtectedContent() Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
31+
* @method bool getHasVisibleHistory() Optional. True, if new chat members will have access to old messages; available only to chat administrators.
32+
* @method string getStickerSetName() Optional. For supergroups, name of group sticker set. Returned only in getChat.
33+
* @method bool getCanSetStickerSet() Optional. True, if the bot can change the group sticker set. Returned only in getChat.
34+
* @method string getCustomEmojiStickerSetName() Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group.
35+
* @method int getLinkedChatId() Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. Returned only in getChat.
36+
* @method ChatLocation getLocation() Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
37+
* @method int getMaxReactionCount() Optional. The maximum number of reactions that can be set on a message in the chat
38+
*/
39+
class ChatFullInfo extends Chat
40+
{
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
protected function subEntities(): array
45+
{
46+
return array_merge(parent::subEntities(), [
47+
// Properties already defined in Chat.php and handled by its subEntities are inherited.
48+
// Add or override here if ChatFullInfo has different types or new sub-entities.
49+
// For example, if PinnedMessage in ChatFullInfo could be a different class than in Chat,
50+
// or if new properties in ChatFullInfo are entities themselves.
51+
// Based on the current structure, most of these are already covered by Chat.php
52+
]);
53+
}
54+
}

src/Entities/ChatMemberUpdated.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method ChatMember getNewChatMember() New information about the chat member
2929
* @method ChatInviteLink getInviteLink() Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
3030
* @method bool getViaChatFolderInviteLink() Optional. True, if the user joined the chat via a chat folder invite link
31+
* @method bool getViaJoinRequest() Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator
3132
*/
3233
class ChatMemberUpdated extends Entity
3334
{

src/Entities/Message.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
* @method string getBusinessConnectionId() Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message is business_message.
117117
* @method User getSenderBusinessBot() Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the business account.
118118
* @method bool getIsFromOffline() Optional. True, if the message was sent by an offline user. Applicable to messages sent by the bot on behalf of a user to a fellow user in a private chat.
119+
* @method ChatBackground getChatBackgroundSet() Optional. Service message: chat background set
119120
*/
120121
class Message extends Entity implements MaybeInaccessibleMessage
121122
{
@@ -181,6 +182,7 @@ protected function subEntities(): array
181182
'video_chat_participants_invited' => VideoChatParticipantsInvited::class,
182183
'web_app_data' => WebAppData::class,
183184
'reply_markup' => InlineKeyboard::class,
185+
'chat_background_set' => ChatBackground::class,
184186
];
185187
}
186188

@@ -328,6 +330,7 @@ public function getType(): string
328330
'video_chat_participants_invited',
329331
'web_app_data',
330332
'reply_markup',
333+
'chat_background_set',
331334
];
332335

333336
$is_command = $this->getCommand() !== null;

src/Entities/Poll.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* @method MessageEntity[] getExplanationEntities() Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation
3232
* @method int getOpenPeriod() Optional. Amount of time in seconds the poll will be active after creation
3333
* @method int getCloseDate() Optional. Point in time (Unix timestamp) when the poll will be automatically closed
34+
* @method MessageEntity[] getQuestionEntities() Optional. Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions
3435
*/
3536
class Poll extends Entity
3637
{
@@ -42,6 +43,7 @@ protected function subEntities(): array
4243
return [
4344
'options' => [PollOption::class],
4445
'explanation_entities' => [MessageEntity::class],
46+
'question_entities' => [MessageEntity::class],
4547
];
4648
}
4749
}

src/Entities/Poll/InputPollOption.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the TelegramBot package.
5+
*
6+
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Longman\TelegramBot\Entities\Poll;
13+
14+
use Longman\TelegramBot\Entities\Entity;
15+
use Longman\TelegramBot\Entities\MessageEntity;
16+
17+
/**
18+
* Class InputPollOption
19+
*
20+
* This entity contains information about one answer option in a poll to be sent.
21+
*
22+
* @link https://core.telegram.org/bots/api#inputpolloption
23+
*
24+
* @method string getText() Option text, 1-100 characters
25+
* @method MessageEntity[] getTextEntities() Optional. A JSON-serialized list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode
26+
*/
27+
class InputPollOption extends Entity
28+
{
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
protected function subEntities(): array
33+
{
34+
return [
35+
'text_entities' => [MessageEntity::class],
36+
];
37+
}
38+
}

src/Entities/PollOption.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@
1818
*
1919
* @link https://core.telegram.org/bots/api#polloption
2020
*
21-
* @method string getText() Option text, 1-100 characters
22-
* @method int getVoterCount() Number of users that voted for this option
21+
* @method string getText() Option text, 1-100 characters
22+
* @method int getVoterCount() Number of users that voted for this option
23+
* @method MessageEntity[] getTextEntities() Optional. Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts
2324
*/
2425
class PollOption extends Entity
2526
{
26-
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
protected function subEntities(): array
31+
{
32+
return [
33+
'text_entities' => [MessageEntity::class],
34+
];
35+
}
2736
}

0 commit comments

Comments
 (0)