Skip to content

Commit d567e3e

Browse files
authored
Merge pull request php-telegram-bot#1339 from php-telegram-bot/api-6.1
Add DB changes for Bot API 6.1
2 parents 644ad80 + fbc790d commit d567e3e

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
66
## [Unreleased]
77
### Notes
88
- [:ledger: View file changes][Unreleased]
9+
- 64 bit PHP installs are required to handle files larger than 2GB!
910
### Added
11+
- Bot API 6.1 (@jyxjjj, @OxMohsen, @noplanman) (#1333, #1338, #1339)
1012
### Changed
1113
### Deprecated
1214
### Removed

src/DB.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,18 @@ public static function insertUser(User $user, ?string $date = null, ?Chat $chat
421421
try {
422422
$sth = self::$pdo->prepare('
423423
INSERT INTO `' . TB_USER . '`
424-
(`id`, `is_bot`, `username`, `first_name`, `last_name`, `language_code`, `created_at`, `updated_at`)
424+
(`id`, `is_bot`, `username`, `first_name`, `last_name`, `language_code`, `is_premium`, `added_to_attachment_menu`, `created_at`, `updated_at`)
425425
VALUES
426-
(:id, :is_bot, :username, :first_name, :last_name, :language_code, :created_at, :updated_at)
426+
(:id, :is_bot, :username, :first_name, :last_name, :language_code, :is_premium, :added_to_attachment_menu, :created_at, :updated_at)
427427
ON DUPLICATE KEY UPDATE
428-
`is_bot` = VALUES(`is_bot`),
429-
`username` = VALUES(`username`),
430-
`first_name` = VALUES(`first_name`),
431-
`last_name` = VALUES(`last_name`),
432-
`language_code` = VALUES(`language_code`),
433-
`updated_at` = VALUES(`updated_at`)
428+
`is_bot` = VALUES(`is_bot`),
429+
`username` = VALUES(`username`),
430+
`first_name` = VALUES(`first_name`),
431+
`last_name` = VALUES(`last_name`),
432+
`language_code` = VALUES(`language_code`),
433+
`is_premium` = VALUES(`is_premium`),
434+
`added_to_attachment_menu` = VALUES(`added_to_attachment_menu`),
435+
`updated_at` = VALUES(`updated_at`)
434436
');
435437

436438
$sth->bindValue(':id', $user->getId());
@@ -439,6 +441,8 @@ public static function insertUser(User $user, ?string $date = null, ?Chat $chat
439441
$sth->bindValue(':first_name', $user->getFirstName());
440442
$sth->bindValue(':last_name', $user->getLastName());
441443
$sth->bindValue(':language_code', $user->getLanguageCode());
444+
$sth->bindValue(':is_premium', $user->getIsPremium(), PDO::PARAM_INT);
445+
$sth->bindValue(':added_to_attachment_menu', $user->getAddedToAttachmentMenu(), PDO::PARAM_INT);
442446
$date = $date ?: self::getTimestamp();
443447
$sth->bindValue(':created_at', $date);
444448
$sth->bindValue(':updated_at', $date);

structure.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CREATE TABLE IF NOT EXISTS `user` (
55
`last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s or bot''s last name',
66
`username` CHAR(191) DEFAULT NULL COMMENT 'User''s or bot''s username',
77
`language_code` CHAR(10) DEFAULT NULL COMMENT 'IETF language tag of the user''s language',
8+
`is_premium` tinyint(1) DEFAULT 0 COMMENT 'True, if this user is a Telegram Premium user',
9+
`added_to_attachment_menu` tinyint(1) DEFAULT 0 COMMENT 'True, if this user added the bot to the attachment menu',
810
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation',
911
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update',
1012

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE `user` ADD COLUMN `is_premium` tinyint(1) DEFAULT 0 COMMENT 'True, if this user is a Telegram Premium user' AFTER `language_code`;
2+
ALTER TABLE `user` ADD COLUMN `added_to_attachment_menu` tinyint(1) DEFAULT 0 COMMENT 'True, if this user added the bot to the attachment menu' AFTER `is_premium`;

0 commit comments

Comments
 (0)