Skip to content

Commit b6daa54

Browse files
authored
Merge pull request #1371 from php-telegram-bot/api-6.3
Bot API 6.3
2 parents 8e8dc64 + bcf9afb commit b6daa54

15 files changed

+134
-17
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
55

66
## [Unreleased]
77
### Notes
8-
- [:ledger: View file changes][Unreleased]
9-
### Added
8+
- [:ledger: View file changes][Unreleased][:page_with_curl: DB migration script][0.80.0-sql-migration]
9+
- This update adds support for [Bot API 6.3](https://core.telegram.org/bots/api#november-5-2022) (@TiiFuchs)
10+
### Added
11+
- Added the field `is_forum` to the class `Chat`.
12+
- Added the fields `is_topic_message` and `message_thread_id` to the class `Message` to allow detection of messages belonging to a forum topic and their message thread identifier.
13+
- Added the classes `ForumTopicCreated`, `ForumTopicClosed`, and `ForumTopicReopened` and the fields `forum_topic_created`, `forum_topic_closed`, and `forum_topic_reopened` to the class `Message`.
14+
- Added the field `can_manage_topics` to the classes `ChatAdministratorRights`, `ChatPermissions`, `ChatMemberAdministrator`, and `ChatMemberRestricted`.
15+
- Added the methods `createForumTopic`, `editForumTopic`, `closeForumTopic`, `reopenForumTopic`, `deleteForumTopic`, `unpinAllForumTopicMessages`, and `getForumTopicIconStickers` for forum topic management.
16+
- Added support for Multiple Usernames via the field `active_usernames` in the class `Chat`.
17+
- Added the field `emoji_status_custom_emoji_id` to the class `Chat`.
1018
### Changed
1119
### Deprecated
1220
### Removed
@@ -603,6 +611,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
603611
### Deprecated
604612
- Move `hideKeyboard` to `removeKeyboard`.
605613

614+
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/new-release.sql
606615
[0.78.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.77.1-0.78.0.sql
607616
[0.77.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.76.1-0.77.0.sql
608617
[0.75.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.74.0-0.75.0.sql

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A Telegram Bot based on the official [Telegram Bot API]
99

10-
[![API Version](https://img.shields.io/badge/Bot%20API-6.2%20%28August%202022%29-32a2da.svg)](https://core.telegram.org/bots/api#june-20-2022)
10+
[![API Version](https://img.shields.io/badge/Bot%20API-6.3%20%28November%202022%29-32a2da.svg)](https://core.telegram.org/bots/api#november-5-2022)
1111
[![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support)
1212
[![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate)
1313

@@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in
7878

7979
The Bot can:
8080
- Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods.
81-
- Supports all types and methods according to Telegram Bot API 6.2 (August 2022).
81+
- Supports all types and methods according to Telegram Bot API 6.3 (November 2022).
8282
- Supports supergroups.
8383
- Handle commands in chat with other bots.
8484
- Manage Channel from the bot admin interface.
@@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th
389389

390390
### Types
391391

392-
All types are implemented according to Telegram API 6.2 (August 2022).
392+
All types are implemented according to Telegram API 6.3 (November 2022).
393393

394394
### Inline Query
395395

396-
Full support for inline query according to Telegram API 6.2 (August 2022).
396+
Full support for inline query according to Telegram API 6.3 (November 2022).
397397

398398
### Methods
399399

400-
All methods are implemented according to Telegram API 6.2 (August 2022).
400+
All methods are implemented according to Telegram API 6.3 (November 2022).
401401

402402
#### Send Message
403403

src/DB.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,16 @@ public static function insertChat(Chat $chat, ?string $date = null, ?int $migrat
493493
try {
494494
$sth = self::$pdo->prepare('
495495
INSERT IGNORE INTO `' . TB_CHAT . '`
496-
(`id`, `type`, `title`, `username`, `first_name`, `last_name`, `created_at` ,`updated_at`, `old_id`)
496+
(`id`, `type`, `title`, `username`, `first_name`, `last_name`, `is_forum`, `created_at` ,`updated_at`, `old_id`)
497497
VALUES
498-
(:id, :type, :title, :username, :first_name, :last_name, :created_at, :updated_at, :old_id)
498+
(:id, :type, :title, :username, :first_name, :last_name, :is_forum, :created_at, :updated_at, :old_id)
499499
ON DUPLICATE KEY UPDATE
500500
`type` = VALUES(`type`),
501501
`title` = VALUES(`title`),
502502
`username` = VALUES(`username`),
503503
`first_name` = VALUES(`first_name`),
504504
`last_name` = VALUES(`last_name`),
505+
`is_forum` = VALUES(`is_forum`),
505506
`updated_at` = VALUES(`updated_at`)
506507
');
507508

@@ -523,6 +524,7 @@ public static function insertChat(Chat $chat, ?string $date = null, ?int $migrat
523524
$sth->bindValue(':username', $chat->getUsername());
524525
$sth->bindValue(':first_name', $chat->getFirstName());
525526
$sth->bindValue(':last_name', $chat->getLastName());
527+
$sth->bindValue(':is_forum', $chat->getIsForum());
526528
$date = $date ?: self::getTimestamp();
527529
$sth->bindValue(':created_at', $date);
528530
$sth->bindValue(':updated_at', $date);
@@ -1131,24 +1133,26 @@ public static function insertMessageRequest(Message $message): bool
11311133
$sth = self::$pdo->prepare('
11321134
INSERT IGNORE INTO `' . TB_MESSAGE . '`
11331135
(
1134-
`id`, `user_id`, `chat_id`, `sender_chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
1135-
`forward_signature`, `forward_sender_name`, `forward_date`,
1136+
`id`, `user_id`, `chat_id`, `message_thread_id`, `sender_chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
1137+
`forward_signature`, `forward_sender_name`, `forward_date`, `is_topic_message`,
11361138
`reply_to_chat`, `reply_to_message`, `via_bot`, `edit_date`, `media_group_id`, `author_signature`, `text`, `entities`, `caption_entities`,
11371139
`audio`, `document`, `animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
11381140
`location`, `venue`, `poll`, `dice`, `new_chat_members`, `left_chat_member`,
11391141
`new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
11401142
`supergroup_chat_created`, `channel_chat_created`, `message_auto_delete_timer_changed`, `migrate_to_chat_id`, `migrate_from_chat_id`,
11411143
`pinned_message`, `invoice`, `successful_payment`, `connected_website`, `passport_data`, `proximity_alert_triggered`,
1144+
`forum_topic_created`, `forum_topic_closed`, `forum_topic_reopened`,
11421145
`video_chat_scheduled`, `video_chat_started`, `video_chat_ended`, `video_chat_participants_invited`, `web_app_data`, `reply_markup`
11431146
) VALUES (
1144-
:message_id, :user_id, :chat_id, :sender_chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
1145-
:forward_signature, :forward_sender_name, :forward_date,
1147+
:message_id, :user_id, :chat_id, :message_thread_id, :sender_chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
1148+
:forward_signature, :forward_sender_name, :forward_date, :is_topic_message,
11461149
:reply_to_chat, :reply_to_message, :via_bot, :edit_date, :media_group_id, :author_signature, :text, :entities, :caption_entities,
11471150
:audio, :document, :animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
11481151
:location, :venue, :poll, :dice, :new_chat_members, :left_chat_member,
11491152
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
11501153
:supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id,
11511154
:pinned_message, :invoice, :successful_payment, :connected_website, :passport_data, :proximity_alert_triggered,
1155+
:forum_topic_created, :forum_topic_closed, :forum_topic_reopened,
11521156
:video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup
11531157
)
11541158
');
@@ -1167,6 +1171,7 @@ public static function insertMessageRequest(Message $message): bool
11671171
$sth->bindValue(':message_id', $message->getMessageId());
11681172
$sth->bindValue(':chat_id', $chat_id);
11691173
$sth->bindValue(':sender_chat_id', $sender_chat_id);
1174+
$sth->bindValue(':message_thread_id', $message->getMessageThreadId());
11701175
$sth->bindValue(':user_id', $user_id);
11711176
$sth->bindValue(':date', $date);
11721177
$sth->bindValue(':forward_from', $forward_from);
@@ -1175,6 +1180,7 @@ public static function insertMessageRequest(Message $message): bool
11751180
$sth->bindValue(':forward_signature', $message->getForwardSignature());
11761181
$sth->bindValue(':forward_sender_name', $message->getForwardSenderName());
11771182
$sth->bindValue(':forward_date', $forward_date);
1183+
$sth->bindValue(':is_topic_message', $message->getIsTopicMessage());
11781184

11791185
$reply_to_chat_id = null;
11801186
if ($reply_to_message_id !== null) {
@@ -1222,6 +1228,9 @@ public static function insertMessageRequest(Message $message): bool
12221228
$sth->bindValue(':connected_website', $message->getConnectedWebsite());
12231229
$sth->bindValue(':passport_data', $message->getPassportData());
12241230
$sth->bindValue(':proximity_alert_triggered', $message->getProximityAlertTriggered());
1231+
$sth->bindValue(':forum_topic_created', $message->getForumTopicCreated());
1232+
$sth->bindValue(':forum_topic_closed', $message->getForumTopicClosed());
1233+
$sth->bindValue(':forum_topic_reopened', $message->getForumTopicReopened());
12251234
$sth->bindValue(':video_chat_scheduled', $message->getVideoChatScheduled());
12261235
$sth->bindValue(':video_chat_started', $message->getVideoChatStarted());
12271236
$sth->bindValue(':video_chat_ended', $message->getVideoChatEnded());

src/Entities/Chat.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
2525
* @method string getFirstName() Optional. First name of the other party in a private chat
2626
* @method string getLastName() Optional. Last name of the other party in a private chat
27+
* @method bool getIsForum() Optional. True, if the supergroup chat is a forum (has topics enabled)
2728
* @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat.
29+
* @method string[] getActiveUsernames() Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.
30+
* @method string getEmojiStatusCustomEmojiId() Optional. Custom emoji identifier of emoji status of the other party in a private chat. Returned only in getChat.
2831
* @method string getBio() Optional. Bio of the other party in a private chat. Returned only in getChat.
2932
* @method bool getHasPrivateForwards() Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user. Returned only in getChat.
3033
* @method bool getHasRestrictedVoiceAndVideoMessages() Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat.

src/Entities/ChatAdministratorRights.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @method bool getCanPostMessages() Optional. True, if the administrator can post in the channel; channels only
1717
* @method bool getCanEditMessages() Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
1818
* @method bool getCanPinMessages() Optional. True, if the user is allowed to pin messages; groups and supergroups only
19+
* @method bool getCanManageTopics() Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
1920
*
2021
* @method $this setIsAnonymous(bool $is_anonymous) True, if the user's presence in the chat is hidden
2122
* @method $this setCanManageChat(bool $can_manage_chat) True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
@@ -28,6 +29,7 @@
2829
* @method $this setCanPostMessages(bool $can_post_messages) Optional. True, if the administrator can post in the channel; channels only
2930
* @method $this setCanEditMessages(bool $can_edit_messages) Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
3031
* @method $this setCanPinMessages(bool $can_pin_messages) Optional. True, if the user is allowed to pin messages; groups and supergroups only
32+
* @method $this setCanManageTopics(bool $can_manage_topics) Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
3133
*/
3234
class ChatAdministratorRights extends Entity
3335
{

src/Entities/ChatMember/ChatMemberAdministrator.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@
1313
* @method string getStatus() The member's status in the chat, always “administrator”
1414
* @method User getUser() Information about the user
1515
* @method bool getCanBeEdited() True, if the bot is allowed to edit administrator privileges of that user
16-
* @method string getCustomTitle() Custom title for this user
1716
* @method bool getIsAnonymous() True, if the user's presence in the chat is hidden
1817
* @method bool getCanManageChat() True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
19-
* @method bool getCanPostMessages() True, if the administrator can post in the channel; channels only
20-
* @method bool getCanEditMessages() True, if the administrator can edit messages of other users and can pin messages; channels only
2118
* @method bool getCanDeleteMessages() True, if the administrator can delete messages of other users
2219
* @method bool getCanManageVideoChats() True, if the administrator can manage video chats
2320
* @method bool getCanRestrictMembers() True, if the administrator can restrict, ban or unban chat members
2421
* @method bool getCanPromoteMembers() True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
2522
* @method bool getCanChangeInfo() True, if the user is allowed to change the chat title, photo and other settings
2623
* @method bool getCanInviteUsers() True, if the user is allowed to invite new users to the chat
27-
* @method bool getCanPinMessages() True, if the user is allowed to pin messages; groups and supergroups only
24+
* @method bool getCanPostMessages() Optional. True, if the administrator can post in the channel; channels only
25+
* @method bool getCanEditMessages() Optional. True, if the administrator can edit messages of other users and can pin messages; channels only
26+
* @method bool getCanPinMessages() Optional. True, if the user is allowed to pin messages; groups and supergroups only
27+
* @method bool getCanManageTopics() Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
28+
* @method string getCustomTitle() Custom title for this user
2829
*/
2930
class ChatMemberAdministrator extends Entity implements ChatMember
3031
{

src/Entities/ChatMember/ChatMemberRestricted.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @method bool getCanChangeInfo() True, if the user is allowed to change the chat title, photo and other settings
1717
* @method bool getCanInviteUsers() True, if the user is allowed to invite new users to the chat
1818
* @method bool getCanPinMessages() True, if the user is allowed to pin messages; groups and supergroups only
19+
* @method bool getCanManageTopics() True, if the user is allowed to create forum topics
1920
* @method bool getCanSendMessages() True, if the user is allowed to send text messages, contacts, locations and venues
2021
* @method bool getCanSendMediaMessages() True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
2122
* @method bool getCanSendPolls() True, if the user is allowed to send polls

src/Entities/ChatPermissions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @method bool getCanChangeInfo() Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups
2525
* @method bool getCanInviteUsers() Optional. True, if the user is allowed to invite new users to the chat
2626
* @method bool getCanPinMessages() Optional. True, if the user is allowed to pin messages. Ignored in public supergroups
27+
* @method bool getCanManageTopics() Optional. True, if the user is allowed to create forum topics. If omitted defaults to the value of can_pin_messages
2728
*/
2829
class ChatPermissions extends Entity
2930
{

0 commit comments

Comments
 (0)