Commit ff7ac510 authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #605 from noplanman/bot_api_3.3

Bot API 3.3
parents 4e284cd8 a237104e
...@@ -4,9 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ...@@ -4,9 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more. Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.
## [Unreleased] ## [Unreleased]
**Note:** After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
### Added ### Added
- New entities, methods, update types and inline keyboard button for Payments (Bot API 3.0). - New entities, methods, update types and inline keyboard button for Payments (Bot API 3.0).
- Add new methods, fields and objects for working with stickers (Bot API 3.2). - Add new methods, fields and objects for working with stickers (Bot API 3.2).
- New fields for Chat, User and Message objects (Bot API 3.3). `is_bot` added to `user` DB table.
### Changed ### Changed
- [:exclamation:][unreleased-correct-printerror] Corrected `ServerResponse->printError` method to print by default and return by setting `$return` parameter. - [:exclamation:][unreleased-correct-printerror] Corrected `ServerResponse->printError` method to print by default and return by setting `$return` parameter.
- Ensure command names are handled as lower case. - Ensure command names are handled as lower case.
...@@ -149,6 +151,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -149,6 +151,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Deprecated ### Deprecated
- Move `hideKeyboard` to `removeKeyboard`. - Move `hideKeyboard` to `removeKeyboard`.
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/0.47.1-unreleased.sql
[unreleased-correct-printerror]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#correct-printerror [unreleased-correct-printerror]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#correct-printerror
[0.47.0-private-only-admin-commands]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#private-only-admin-commands [0.47.0-private-only-admin-commands]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#private-only-admin-commands
[0.46.0-bc-request-class-refactor]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#request-class-refactor [0.46.0-bc-request-class-refactor]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#request-class-refactor
......
...@@ -358,6 +358,7 @@ class DB ...@@ -358,6 +358,7 @@ class DB
} }
$user_id = $user->getId(); $user_id = $user->getId();
$is_bot = $user->getIsBot();
$username = $user->getUsername(); $username = $user->getUsername();
$first_name = $user->getFirstName(); $first_name = $user->getFirstName();
$last_name = $user->getLastName(); $last_name = $user->getLastName();
...@@ -366,10 +367,11 @@ class DB ...@@ -366,10 +367,11 @@ class DB
try { try {
$sth = self::$pdo->prepare(' $sth = self::$pdo->prepare('
INSERT INTO `' . TB_USER . '` INSERT INTO `' . TB_USER . '`
(`id`, `username`, `first_name`, `last_name`, `language_code`, `created_at`, `updated_at`) (`id`, `is_bot`, `username`, `first_name`, `last_name`, `language_code`, `created_at`, `updated_at`)
VALUES VALUES
(:id, :username, :first_name, :last_name, :language_code, :created_at, :updated_at) (:id, :is_bot,:username, :first_name, :last_name, :language_code, :created_at, :updated_at)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
`is_bot` = VALUES(`is_bot`),
`username` = VALUES(`username`), `username` = VALUES(`username`),
`first_name` = VALUES(`first_name`), `first_name` = VALUES(`first_name`),
`last_name` = VALUES(`last_name`), `last_name` = VALUES(`last_name`),
...@@ -378,6 +380,7 @@ class DB ...@@ -378,6 +380,7 @@ class DB
'); ');
$sth->bindParam(':id', $user_id, PDO::PARAM_STR); $sth->bindParam(':id', $user_id, PDO::PARAM_STR);
$sth->bindParam(':is_bot', $is_bot, PDO::PARAM_INT);
$sth->bindParam(':username', $username, PDO::PARAM_STR, 255); $sth->bindParam(':username', $username, PDO::PARAM_STR, 255);
$sth->bindParam(':first_name', $first_name, PDO::PARAM_STR, 255); $sth->bindParam(':first_name', $first_name, PDO::PARAM_STR, 255);
$sth->bindParam(':last_name', $last_name, PDO::PARAM_STR, 255); $sth->bindParam(':last_name', $last_name, PDO::PARAM_STR, 255);
......
...@@ -35,6 +35,7 @@ namespace Longman\TelegramBot\Entities; ...@@ -35,6 +35,7 @@ namespace Longman\TelegramBot\Entities;
* @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat. * @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat.
* @method string getDescription() Optional. Description, for supergroups and channel chats. Returned only in getChat. * @method string getDescription() Optional. Description, for supergroups and channel chats. Returned only in getChat.
* @method string getInviteLink() Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat. * @method string getInviteLink() Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
* @method Message getPinnedMessage() Optional. Pinned message, for supergroups. Returned only in getChat.
*/ */
class Chat extends Entity class Chat extends Entity
{ {
...@@ -45,6 +46,7 @@ class Chat extends Entity ...@@ -45,6 +46,7 @@ class Chat extends Entity
{ {
return [ return [
'photo' => ChatPhoto::class, 'photo' => ChatPhoto::class,
'pinned_message' => Message::class,
]; ];
} }
......
...@@ -22,9 +22,11 @@ namespace Longman\TelegramBot\Entities; ...@@ -22,9 +22,11 @@ namespace Longman\TelegramBot\Entities;
* @method User getForwardFrom() Optional. For forwarded messages, sender of the original message * @method User getForwardFrom() Optional. For forwarded messages, sender of the original message
* @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel * @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel
* @method int getForwardFromMessageId() Optional. For forwarded channel posts, identifier of the original message in the channel * @method int getForwardFromMessageId() Optional. For forwarded channel posts, identifier of the original message in the channel
* @method string getForwardSignature() Optional. For messages forwarded from channels, signature of the post author if present
* @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time * @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time
* @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. * @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
* @method int getEditDate() Optional. Date the message was last edited in Unix time * @method int getEditDate() Optional. Date the message was last edited in Unix time
* @method string getAuthorSignature() Optional. Signature of the post author for messages in channels
* @method Audio getAudio() Optional. Message is an audio file, information about the file * @method Audio getAudio() Optional. Message is an audio file, information about the file
* @method Document getDocument() Optional. Message is a general file, information about the file * @method Document getDocument() Optional. Message is a general file, information about the file
* @method Sticker getSticker() Optional. Message is a sticker, information about the sticker * @method Sticker getSticker() Optional. Message is a sticker, information about the sticker
......
...@@ -16,6 +16,7 @@ namespace Longman\TelegramBot\Entities; ...@@ -16,6 +16,7 @@ namespace Longman\TelegramBot\Entities;
* @link https://core.telegram.org/bots/api#user * @link https://core.telegram.org/bots/api#user
* *
* @method int getId() Unique identifier for this user or bot * @method int getId() Unique identifier for this user or bot
* @method bool getIsBot() True, if this user is a bot
* @method string getFirstName() User's or bot’s first name * @method string getFirstName() User's or bot’s first name
* @method string getLastName() Optional. User's or bot’s last name * @method string getLastName() Optional. User's or bot’s last name
* @method string getUsername() Optional. User's or bot’s username * @method string getUsername() Optional. User's or bot’s username
......
CREATE TABLE IF NOT EXISTS `user` ( CREATE TABLE IF NOT EXISTS `user` (
`id` bigint COMMENT 'Unique user identifier', `id` bigint COMMENT 'Unique user identifier',
`is_bot` tinyint(1) DEFAULT 0 COMMENT 'True if this user is a bot',
`first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User''s first name', `first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User''s first name',
`last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s last name', `last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s last name',
`username` CHAR(191) DEFAULT NULL COMMENT 'User''s username', `username` CHAR(191) DEFAULT NULL COMMENT 'User''s username',
......
ALTER TABLE `user` ADD COLUMN `is_bot` tinyint(1) DEFAULT 0 COMMENT 'True if this user is a bot' AFTER `id`;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment