Skip to content

Commit 580daf5

Browse files
committed
Support Bot API 4.4
Signed-off-by: Dmitriy Kuts <me@exileed.com>
1 parent 9dd4f67 commit 580daf5

File tree

11 files changed

+207
-19
lines changed

11 files changed

+207
-19
lines changed

src/Api.php

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,24 +1790,18 @@ public function createNewStickerSet(array $params)
17901790
* 'chat_id' => '',
17911791
* 'user_id' => '',
17921792
* 'until_date' => '',
1793-
* 'can_send_messages' => '',
1794-
* 'can_send_media_messages' => '',
1795-
* 'can_send_other_messages' => '',
1796-
* 'can_add_web_page_previews' => '',
1793+
* 'permissions' => [],
17971794
* ];
17981795
* </code>
17991796
*
18001797
* @link https://core.telegram.org/bots/api#restrictchatmember
18011798
*
18021799
* @param array $params
18031800
*
1804-
* @var int|string $params ['chat_id']
1805-
* @var int|string $params ['user_id']
1806-
* @var int $params ['until_date']
1807-
* @var bool $params ['can_send_messages']
1808-
* @var bool $params ['can_send_media_messages']
1809-
* @var bool $params ['can_send_other_messages']
1810-
* @var bool $params ['can_add_web_page_previews']
1801+
* @var int|string $params ['chat_id']
1802+
* @var int|string $params ['user_id']
1803+
* @var int $params ['until_date']
1804+
* @var Chat\ChatPermissions $params ['permissions']
18111805
*
18121806
* @throws TelegramSDKException
18131807
*
@@ -1864,6 +1858,34 @@ public function promoteChatMember(array $params)
18641858
return true;
18651859
}
18661860

1861+
1862+
/**
1863+
* Use this method to set default chat permissions for all members.
1864+
*
1865+
* <code>
1866+
* $params = [
1867+
* 'chat_id' => '',
1868+
* 'permissions' => [],
1869+
* </code>
1870+
*
1871+
* @link https://core.telegram.org/bots/api#setchatpermissions
1872+
*
1873+
* @param array $params
1874+
*
1875+
* @var int|string $params ['chat_id']
1876+
* @var Chat\ChatPermissions $params ['permissions']
1877+
*
1878+
* @throws TelegramSDKException
1879+
*
1880+
* @return bool
1881+
*/
1882+
public function setChatPermissions(array $params)
1883+
{
1884+
$this->post('setChatPermissions', $params);
1885+
1886+
return true;
1887+
}
1888+
18671889
/**
18681890
* Use this method to export an invite link to a supergroup or a channel.
18691891
*

src/Objects/Chat.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Telegram\Bot\Objects;
44

5+
use Telegram\Bot\Objects\Chat\ChatPermissions;
6+
57
/**
68
* Class Chat.
79
*
@@ -12,13 +14,16 @@
1214
* @method string getUsername() ( Optional ). Username, for private chats and channels if available
1315
* @method string getFirstName() ( Optional ). First name of the other party in a private chat
1416
* @method string getLastName() ( Optional ). Last name of the other party in a private chat
15-
* @method string getAllMembersAreAdministrators() ( Optional ). Last name of the other party in a private chat
1617
* @method ChatPhoto getPhoto() ( Optional ). Chat photo.
1718
* @method string getDescription() ( Optional ). Description, for supergroups and channel chats.
1819
* @method string getInviteLink() ( Optional ). Chat invite link, for supergroups and channel chats.
19-
* @method Message getPinnedMessage() (Optional). Pinned message, for supergroups. Returned only in getChat.
20-
* @method string getStickerSetName() (Optional). For supergroups, name of group sticker set. Returned only in getChat.
21-
* @method bool getCanSetStickerSet() (Optional). True, if the bot can change the group sticker set. Returned only in getChat.
20+
* @method Message getPinnedMessage() (Optional). Pinned message, for supergroups. Returned only in
21+
* getChat.
22+
* @method ChatPermissions getPermissions() (Optional) Default chat member permissions, for groups and supergroups.
23+
* @method string getStickerSetName() (Optional). For supergroups, name of group sticker set. Returned
24+
* only in getChat.
25+
* @method bool getCanSetStickerSet() (Optional). True, if the bot can change the group sticker set.
26+
* Returned only in getChat.
2227
*/
2328
class Chat extends BaseObject
2429
{
@@ -30,6 +35,7 @@ public function relations()
3035
return [
3136
'photo' => ChatPhoto::class,
3237
'pinned_message' => Message::class,
38+
'permissions' => ChatPermissions::class
3339
];
3440
}
3541

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Telegram\Bot\Objects\Chat;
4+
5+
use Telegram\Bot\Objects\BaseObject;
6+
7+
/**
8+
* Class ChatPermissions.
9+
*
10+
*
11+
* @method bool getCanSendMessages() (Optional) True, if the user is allowed to send text messages,
12+
* contacts, locations and venues.
13+
* @method bool getCanSendMediaMessages() (Optional) True, if the user is allowed to send audios, documents,
14+
* photos, videos, video notes and voice notes.
15+
* @method bool getCanSendPools() (Optional) True, if the user is allowed to send polls.
16+
* @method bool getCanSendOtherMessages() (Optional) True, if the user is allowed to send animations, games,
17+
* stickers and use inline bots.
18+
* @method bool getCanSendWebPagePreviews() (Optional) True, if the user is allowed to add web page previews to
19+
* their messages.
20+
* @method bool getCanChangeInfo() (Optional) True, if the user is allowed to change the chat title, photo
21+
* and other settings. Ignored in public supergroups.
22+
* @method bool getCanInviteUsers() (Optional) True, if the user is allowed to invite new users to the chat.
23+
* @method bool getCanPinMessages() (Optional) True, if the user is allowed to pin messages. Ignored in
24+
* public supergroups.
25+
*
26+
*/
27+
class ChatPermissions extends BaseObject
28+
{
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public function relations()
33+
{
34+
return [];
35+
}
36+
}

src/Objects/ChatMember.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* @method bool getIsMember() (Optional). Restricted only. True, if the user is a member of the chat at the moment of the request
2121
* @method bool getCanSendMessages() (Optional). Restricted only. True, if the user can send text messages, contacts, locations and venues
2222
* @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
23+
* @method bool getCanSendPoll() (Optional). Restricted only. True, if the user is allowed to
24+
* send polls.
2325
* @method bool getCanSendOtherMessages() (Optional). Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
2426
* @method bool getCanSendWebPagePreviews() (Optional). Restricted only. True, if user may add web page previews to his messages, implies can_send_media_messages
2527
*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Telegram\Bot\Objects\InlineKeyboard;
4+
5+
use Telegram\Bot\Objects\BaseObject;
6+
7+
/**
8+
* Class CallbackGame.
9+
*
10+
*
11+
* @method int getUserId() User identifier.
12+
* @method int getScore() New score, must be non-negative.
13+
* @method bool getForce() Pass True, if the high score is allowed to decrease.
14+
* @method bool getDisableEditMessage() Pass True, if the game message should not be automatically edited to
15+
* include the current scoreboard.
16+
* @method int getChatId() Unique identifier for the target chat.
17+
* @method int getMessageId() Identifier of the sent message.
18+
* @method string getInlineMessageId() Identifier of the inline message.
19+
*/
20+
class CallbackGame extends BaseObject
21+
{
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
public function relations()
26+
{
27+
return [];
28+
}
29+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Telegram\Bot\Objects\InlineKeyboard;
4+
5+
use Telegram\Bot\Objects\BaseObject;
6+
7+
/**
8+
* Class InlineKeyboardButton
9+
*
10+
*
11+
* @method string getText() Label text on the button.
12+
* @method string getUrl() (Optional). HTTP or tg:// url to be opened when button is
13+
* pressed.
14+
* @method LoginUrl getLoginUrl() (Optional). An HTTP URL used to automatically authorize the
15+
* user.
16+
* @method string getSwitchInlineQuery() (Optional) If set, pressing the button will prompt the user to
17+
* select one
18+
* of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field.
19+
* messages to the user.
20+
* @method string getSwitchInlineQueryCurrentChat() (Optional) If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field.
21+
* @method CallbackGame getCallbackGame() (Optional) Description of the game that will be launched when the user presses the button.
22+
* @method bool getPay() (Optional) Specify True, to send a Pay button.
23+
*/
24+
class InlineKeyboardButton extends BaseObject
25+
{
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
public function relations()
30+
{
31+
return [
32+
'login_url' => LoginUrl::class,
33+
'callback_game' => CallbackGame::class,
34+
];
35+
}
36+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Telegram\Bot\Objects\InlineKeyboard;
4+
5+
use Telegram\Bot\Objects\BaseObject;
6+
7+
/**
8+
* Class InlineKeyboardMarkup
9+
*
10+
* @method InlineKeyboardButton[] getInlineKeyboard() Button rows.
11+
*/
12+
class InlineKeyboardMarkup extends BaseObject
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public function relations()
18+
{
19+
return [
20+
'inline_keyboard' => InlineKeyboardButton::class,
21+
];
22+
}
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Telegram\Bot\Objects\InlineKeyboard;
4+
5+
use Telegram\Bot\Objects\BaseObject;
6+
7+
/**
8+
* Class LoginUrl.
9+
*
10+
*
11+
* @method string getUrl() An HTTP URL to be opened with user authorization data added to the query string when the button is pressed.
12+
* @method int getForwardText() (Optional). New text of the button in forwarded messages.
13+
* @method string getBotUsername() (Optional). Username of a bot, which will be used for user authorization.
14+
* @method string getRequestWriteAccess() (Optional). True to request the permission for your bot to send messages to the user.
15+
*/
16+
class LoginUrl extends BaseObject
17+
{
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function relations()
22+
{
23+
return [];
24+
}
25+
}

src/Objects/Message.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Telegram\Bot\Objects;
44

5+
use Telegram\Bot\Objects\InlineKeyboard\InlineKeyboardMarkup;
6+
use Telegram\Bot\Objects\Passport\PassportData;
7+
58
/**
69
* Class Message.
710
*
@@ -12,8 +15,10 @@
1215
* @method Chat getChat() Conversation the message belongs to.
1316
* @method User getForwardFrom() (Optional). For forwarded messages, sender of the original message.
1417
* @method Chat getForwardFromChat() (Optional). For messages forwarded from a channel, information about the original channel
15-
* @method string getForwardSignature() (Optional). For messages forwarded from channels, signature of the post author if present
16-
* @method string getForwardSenderName() (Optional). Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages
18+
* @method string getForwardSignature() (Optional). For messages forwarded from channels, signature
19+
* of the post author if present
20+
* @method string getForwardSenderName() (Optional). Sender's name for messages forwarded from users
21+
* who disallow adding a link to their account in forwarded messages
1722
* @method int getForwardDate() (Optional). For forwarded messages, date the original message was sent in Unix time.
1823
* @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.
1924
* @method int getEditDate() (Optional). Date the message was last edited in Unix time.
@@ -48,7 +53,8 @@
4853
* @method Invoice getInvoice() (Optional). Message is an invoice for a payment, information about the invoice.
4954
* @method SuccessfulPayment getSuccessfulPayment() (Optional). Message is a service message about a successful payment, information about the payment.
5055
* @method string getConnectedWebsite() (Optional). The domain name of the website on which the user has logged in.
51-
* @method PassportData getPassportData() (Optional). Telegram Passport data
56+
* @method PassportData getPassportData() (Optional). Telegram Passport data.
57+
* @method InlineKeyboardMarkup getReplyMarkup() (Optional). Inline keyboard attached to the message.
5258
*/
5359
class Message extends BaseObject
5460
{
@@ -82,7 +88,8 @@ public function relations()
8288
'pinned_message' => self::class,
8389
'invoice' => Invoice::class,
8490
'successful_payment' => SuccessfulPayment::class,
85-
'caption_entities' => MessageEntity::class
91+
'caption_entities' => MessageEntity::class,
92+
'passport_data' => PassportData::class,
8693
];
8794
}
8895

src/Objects/Sticker.php

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

0 commit comments

Comments
 (0)