Skip to content

Commit 7ebce6a

Browse files
authored
Merge pull request #990 from noplanman/bot_api_4.4
Bot API 4.4 (Animated stickers, `ChatPermissions`)
2 parents f55fd1c + b02f18d commit 7ebce6a

File tree

9 files changed

+63
-35
lines changed

9 files changed

+63
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
77
### Notes
88
- [:ledger: View file changes][Unreleased]
99
### Added
10+
- Bot API 4.4 (Animated stickers, `ChatPermissions`).
1011
### Changed
1112
### Deprecated
1213
### Removed

README.md

Lines changed: 2 additions & 2 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-4.3%20%28May%202019%29-32a2da.svg)](https://core.telegram.org/bots/api#may-31-2019)
10+
[![API Version](https://img.shields.io/badge/Bot%20API-4.4%20%28July%202019%29-32a2da.svg)](https://core.telegram.org/bots/api#july-29-2019)
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

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

7575
The Bot can:
7676
- Retrieve updates with [webhook][#webhook-installation] and [getUpdates][#getupdates-installation] methods.
77-
- Supports all types and methods according to Telegram API 4.3 (May 2019).
77+
- Supports all types and methods according to Telegram API 4.4 (July 2019).
7878
- Supports supergroups.
7979
- Handle commands in chat with other bots.
8080
- Manage Channel from the bot admin interface.

src/Entities/Chat.php

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,22 @@
1515
*
1616
* @link https://core.telegram.org/bots/api#chat
1717
*
18-
* @property int $id Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
19-
* @property string $type Type of chat, can be either "private", "group", "supergroup" or "channel"
20-
* @property string $title Optional. Title, for channels and group chats
21-
* @property string $username Optional. Username, for private chats, supergroups and channels if available
22-
* @property string $first_name Optional. First name of the other party in a private chat
23-
* @property string $last_name Optional. Last name of the other party in a private chat
24-
* @property bool $all_members_are_administrators Optional. True if a group has ‘All Members Are Admins’ enabled.
25-
* @property ChatPhoto $photo Optional. Chat photo. Returned only in getChat.
26-
* @property string $description Optional. Description, for supergroups and channel chats. Returned only in getChat.
27-
* @property string $invite_link Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
28-
* @property string $sticker_set_name Optional. For supergroups, name of Group sticker set. Returned only in getChat.
29-
* @property bool $can_set_sticker_set Optional. True, if the bot can change group the sticker set. Returned only in getChat.
30-
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
31-
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
32-
* @method string getTitle() Optional. Title, for channels and group chats
33-
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
34-
* @method string getFirstName() Optional. First name of the other party in a private chat
35-
* @method string getLastName() Optional. Last name of the other party in a private chat
36-
* @method bool getAllMembersAreAdministrators() Optional. True if a group has ‘All Members Are Admins’ enabled.
37-
* @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat.
38-
* @method string getDescription() Optional. Description, for supergroups and channel chats. Returned only in getChat.
39-
* @method string getInviteLink() Optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
40-
* @method Message getPinnedMessage() Optional. Pinned message, for supergroups. Returned only in getChat.
41-
* @method string getStickerSetName() Optional. For supergroups, name of Group sticker set. Returned only in getChat.
42-
* @method bool getCanSetStickerSet() Optional. True, if the bot can change group the sticker set. Returned only in getChat.
18+
* @property string type Type of chat, can be either "private ", "group", "supergroup" or "channel"
19+
*
20+
* @method int getId() Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
21+
* @method string getType() Type of chat, can be either "private ", "group", "supergroup" or "channel"
22+
* @method string getTitle() Optional. Title, for channels and group chats
23+
* @method string getUsername() Optional. Username, for private chats, supergroups and channels if available
24+
* @method string getFirstName() Optional. First name of the other party in a private chat
25+
* @method string getLastName() Optional. Last name of the other party in a private chat
26+
* @method bool getAllMembersAreAdministrators() Optional. True if a group has ‘All Members Are Admins’ enabled. {@deprecated} {@see Chat::getPermissions()}
27+
* @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat.
28+
* @method string getDescription() Optional. Description, for groups, supergroups and channel chats. Returned only in getChat.
29+
* @method string getInviteLink() Optional. Chat invite link, for groups, supergroups and channel chats. Each administrator in a chat generates their own invite links, so the bot must first generate the link using exportChatInviteLink. Returned only in getChat.
30+
* @method Message getPinnedMessage() Optional. Pinned message, for groups, supergroups and channels. Returned only in getChat.
31+
* @method ChatPermissions getPermissions() Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
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.
4334
*/
4435
class Chat extends Entity
4536
{
@@ -51,6 +42,7 @@ protected function subEntities()
5142
return [
5243
'photo' => ChatPhoto::class,
5344
'pinned_message' => Message::class,
45+
'permissions' => ChatPermissions::class,
5446
];
5547
}
5648

src/Entities/ChatMember.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@
1919
* @method string getStatus() The member's status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”
2020
* @method int getUntilDate() Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, unix time
2121
* @method bool getCanBeEdited() Optional. Administrators only. True, if the bot is allowed to edit administrator privileges of that user
22-
* @method bool getCanChangeInfo() Optional. Administrators only. True, if the administrator can change the chat title, photo and other settings
2322
* @method bool getCanPostMessages() Optional. Administrators only. True, if the administrator can post in the channel, channels only
2423
* @method bool getCanEditMessages() Optional. Administrators only. True, if the administrator can edit messages of other users, channels only
2524
* @method bool getCanDeleteMessages() Optional. Administrators only. True, if the administrator can delete messages of other users
26-
* @method bool getCanInviteUsers() Optional. Administrators only. True, if the administrator can invite new users to the chat
2725
* @method bool getCanRestrictMembers() Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
28-
* @method bool getCanPinMessages() Optional. Administrators only. True, if the administrator can pin messages, supergroups only
2926
* @method bool getCanPromoteMembers() Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
27+
* @method bool getCanChangeInfo() Optional. Administrators and restricted only. True, if the user is allowed to change the chat title, photo and other settings
28+
* @method bool getCanInviteUsers() Optional. Administrators and restricted only. True, if the user is allowed to invite new users to the chat
29+
* @method bool getCanPinMessages() Optional. Administrators and restricted only. True, if the user is allowed to pin messages; groups and supergroups only
3030
* @method bool getIsMember() Optional. Restricted only. True, if the user is a member of the chat at the moment of the request
3131
* @method bool getCanSendMessages() Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues
3232
* @method bool getCanSendMediaMessages() Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
33+
* @method bool getCanSendPolls() Optional. Restricted only. True, if the user is allowed to send polls
3334
* @method bool getCanSendOtherMessages() Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
3435
* @method bool getCanAddWebPagePreviews() Optional. Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages
3536
*/

src/Entities/ChatPermissions.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBot package.
4+
*
5+
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Longman\TelegramBot\Entities;
12+
13+
/**
14+
* Class ChatPermissions
15+
*
16+
* @link https://core.telegram.org/bots/api#chatpermissions
17+
*
18+
* @method bool getCanSendMessages() Optional. True, if the user is allowed to send text messages, contacts, locations and venues
19+
* @method bool getCanSendMediaMessages() Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
20+
* @method bool getCanSendPolls() Optional. True, if the user is allowed to send polls, implies can_send_messages
21+
* @method bool getCanSendOtherMessages() Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
22+
* @method bool getCanAddWebPagePreviews() Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
23+
* @method bool getCanChangeInfo() Optional. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups
24+
* @method bool getCanInviteUsers() Optional. True, if the user is allowed to invite new users to the chat
25+
* @method bool getCanPinMessages() Optional. True, if the user is allowed to pin messages. Ignored in public supergroups
26+
*/
27+
class ChatPermissions extends Entity
28+
{
29+
30+
}

src/Entities/ChatPhoto.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*
1616
* @link https://core.telegram.org/bots/api#chatphoto
1717
*
18-
* @method string getSmallFileId() Unique file identifier of small(160x160) chat photo. This file_id can be used only for photo download.
19-
* @method string getBigFileId() Unique file identifier of big(640x640) chat photo. This file_id can be used only for photo download.
18+
* @method string getSmallFileId() Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.
19+
* @method string getBigFileId() Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.
2020
*/
2121
class ChatPhoto extends Entity
2222
{

src/Entities/Sticker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @method string getFileId() Unique identifier for this file
1919
* @method int getWidth() Sticker width
2020
* @method int getHeight() Sticker height
21+
* @method bool getIsAnimated() True, if the sticker is animated
2122
* @method PhotoSize getThumb() Optional. Sticker thumbnail in .webp or .jpg format
2223
* @method string getEmoji() Optional. Emoji associated with the sticker
2324
* @method string getSetName() Optional. Name of the sticker set to which the sticker belongs

src/Entities/StickerSet.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
* @method string getName() Sticker set name
1919
* @method string getTitle() Sticker set title
20+
* @method bool getIsAnimated() True, if the sticker set contains animated stickers
2021
* @method bool getContainsMasks() True, if the sticker set contains masks
2122
* @method Sticker[] getStickers() List of all set stickers
2223
*/

src/Request.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@
4848
* @method static ServerResponse getFile(array $data) Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
4949
* @method static ServerResponse kickChatMember(array $data) Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
5050
* @method static ServerResponse unbanChatMember(array $data) Use this method to unban a previously kicked user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. Returns True on success.
51-
* @method static ServerResponse restrictChatMember(array $data) Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
51+
* @method static ServerResponse restrictChatMember(array $data) Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.
5252
* @method static ServerResponse promoteChatMember(array $data) Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success.
53-
* @method static ServerResponse exportChatInviteLink(array $data) Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
53+
* @method static ServerResponse setChatPermissions(array $data) Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members admin rights. Returns True on success.
54+
* @method static ServerResponse exportChatInviteLink(array $data) Use this method to generate a new invite link for a chat; any previously generated link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as String on success.
5455
* @method static ServerResponse setChatPhoto(array $data) Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
5556
* @method static ServerResponse deleteChatPhoto(array $data) Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
5657
* @method static ServerResponse setChatTitle(array $data) Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
57-
* @method static ServerResponse setChatDescription(array $data) Use this method to change the description of a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
58+
* @method static ServerResponse setChatDescription(array $data) Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
5859
* @method static ServerResponse pinChatMessage(array $data) Use this method to pin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
5960
* @method static ServerResponse unpinChatMessage(array $data) Use this method to unpin a message in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the channel. Returns True on success.
6061
* @method static ServerResponse leaveChat(array $data) Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
@@ -176,6 +177,7 @@ class Request
176177
'unbanChatMember',
177178
'restrictChatMember',
178179
'promoteChatMember',
180+
'setChatPermissions',
179181
'exportChatInviteLink',
180182
'setChatPhoto',
181183
'deleteChatPhoto',

0 commit comments

Comments
 (0)