Skip to content

Commit de4fe32

Browse files
authored
Merge pull request #14 from devrabie/bot-api-9.3-updates-13406599450393388176
Update Bot API to version 9.3 (including 8.3-9.2 features)
2 parents b7f47de + 804bec6 commit de4fe32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1521
-16
lines changed

src/Entities/AcceptedGiftTypes.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class AcceptedGiftTypes
7+
*
8+
* This object describes the types of gifts that can be gifted to a user or a chat.
9+
*
10+
* @link https://core.telegram.org/bots/api#acceptedgifttypes
11+
*
12+
* @method bool getUnlimitedGifts() True, if unlimited regular gifts are accepted
13+
* @method bool getLimitedGifts() True, if limited regular gifts are accepted
14+
* @method bool getUniqueGifts() True, if unique gifts or gifts that can be upgraded to unique for free are accepted
15+
* @method bool getPremiumSubscription() True, if a Telegram Premium subscription is accepted
16+
* @method bool getGiftsFromChannels() True, if transfers of unique gifts from channels are accepted
17+
*/
18+
class AcceptedGiftTypes extends Entity
19+
{
20+
}

src/Entities/AffiliateInfo.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class AffiliateInfo
7+
*
8+
* Contains information about the affiliate that received a commission via this transaction.
9+
*
10+
* @link https://core.telegram.org/bots/api#affiliateinfo
11+
*
12+
* @method User getAffiliateUser() Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
13+
* @method Chat getAffiliateChat() Optional. The chat that received an affiliate commission if it was received by a chat
14+
* @method int getCommissionPerMille() The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users
15+
* @method int getAmount() Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds
16+
* @method int getNanostarAmount() Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds
17+
*/
18+
class AffiliateInfo extends Entity
19+
{
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
protected function subEntities(): array
24+
{
25+
return [
26+
'affiliate_user' => User::class,
27+
'affiliate_chat' => Chat::class,
28+
];
29+
}
30+
}

src/Entities/BusinessBotRights.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class BusinessBotRights
7+
*
8+
* Represents the rights of a business bot.
9+
*
10+
* @link https://core.telegram.org/bots/api#businessbotrights
11+
*
12+
* @method bool getCanReply() Optional. True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours
13+
* @method bool getCanReadMessages() Optional. True, if the bot can mark incoming private messages as read
14+
* @method bool getCanDeleteSentMessages() Optional. True, if the bot can delete messages sent by the bot
15+
* @method bool getCanDeleteAllMessages() Optional. True, if the bot can delete all private messages in managed chats
16+
* @method bool getCanEditName() Optional. True, if the bot can edit the first and last name of the business account
17+
* @method bool getCanEditBio() Optional. True, if the bot can edit the bio of the business account
18+
* @method bool getCanEditProfilePhoto() Optional. True, if the bot can edit the profile photo of the business account
19+
* @method bool getCanEditUsername() Optional. True, if the bot can edit the username of the business account
20+
* @method bool getCanChangeGiftSettings() Optional. True, if the bot can change the privacy settings pertaining to gifts for the business account
21+
* @method bool getCanViewGiftsAndStars() Optional. True, if the bot can view gifts and the amount of Telegram Stars owned by the business account
22+
* @method bool getCanConvertGiftsToStars() Optional. True, if the bot can convert regular gifts owned by the business account to Telegram Stars
23+
* @method bool getCanTransferAndUpgradeGifts() Optional. True, if the bot can transfer and upgrade gifts owned by the business account
24+
* @method bool getCanTransferStars() Optional. True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts
25+
* @method bool getCanManageStories() Optional. True, if the bot can post, edit and delete stories on behalf of the business account
26+
*/
27+
class BusinessBotRights extends Entity
28+
{
29+
}

src/Entities/BusinessConnection.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@
2323
* @method int getDate() Date the connection was established in Unix time
2424
* @method bool getCanReply() True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours
2525
* @method bool getIsEnabled() True, if the business connection is active
26+
* @method BusinessBotRights getRights() Optional. Rights of the business bot
2627
*/
2728
class BusinessConnection extends Entity
2829
{
29-
30+
/**
31+
* {@inheritdoc}
32+
*/
33+
protected function subEntities(): array
34+
{
35+
return [
36+
'user' => User::class,
37+
'rights' => BusinessBotRights::class,
38+
];
39+
}
3040
}

src/Entities/Chat.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method string getFirstName() Optional. First name of the other party in a private chat
2929
* @method string getLastName() Optional. Last name of the other party in a private chat
3030
* @method bool getIsForum() Optional. True, if the supergroup chat is a forum (has topics enabled)
31+
* @method bool getIsDirectMessages() Optional. True, if the chat is the direct messages chat of a channel
3132
* @method int getAccentColorId() Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details.
3233
* @method ChatPhoto getPhoto() Optional. Chat photo. Returned only in getChat.
3334
* @method string[] getActiveUsernames() Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.

src/Entities/ChatAdministratorRights.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @method bool getCanEditStories() Optional. True, if the administrator can edit stories posted by other users; channels only
2121
* @method bool getCanDeleteStories() Optional. True, if the administrator can delete stories posted by other users; channels only
2222
* @method bool getCanManageTopics() Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
23+
* @method bool getCanManageDirectMessages() Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only
2324
*
2425
* @method $this setIsAnonymous(bool $is_anonymous) True, if the user's presence in the chat is hidden
2526
* @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
@@ -36,6 +37,7 @@
3637
* @method $this setCanEditStories(bool $can_edit_stories) Optional. True, if the administrator can edit stories posted by other users; channels only
3738
* @method $this setCanDeleteStories(bool $can_delete_stories) Optional. True, if the administrator can delete stories posted by other users; channels only
3839
* @method $this setCanManageTopics(bool $can_manage_topics) Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
40+
* @method $this setCanManageDirectMessages(bool $can_manage_direct_messages) Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only
3941
*/
4042
class ChatAdministratorRights extends Entity
4143
{

src/Entities/ChatFullInfo.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@
3333
* @method bool getCanSetStickerSet() Optional. True, if the bot can change the group sticker set. Returned only in getChat.
3434
* @method string getCustomEmojiStickerSetName() Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group.
3535
* @method int getLinkedChatId() Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. Returned only in getChat.
36+
* @method Chat getParentChat() Optional. Information about the corresponding channel chat; for direct messages chats only
3637
* @method ChatLocation getLocation() Optional. For supergroups, the location to which the supergroup is connected. Returned only in getChat.
38+
* @method UserRating getRating() Optional. For private chats, the rating of the user if any
39+
* @method UniqueGiftColors getUniqueGiftColors() Optional. The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews
3740
* @method int getMaxReactionCount() Optional. The maximum number of reactions that can be set on a message in the chat
41+
* @method AcceptedGiftTypes getAcceptedGiftTypes() Optional. Information about types of gifts that are accepted by the chat or by the corresponding user for private chats
42+
* @method bool getCanSendPaidMedia() Optional. True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.
43+
* @method int getPaidMessageStarCount() Optional. The number of Telegram Stars a general user have to pay to send a message to the chat
3844
*/
3945
class ChatFullInfo extends Chat
4046
{
@@ -44,11 +50,10 @@ class ChatFullInfo extends Chat
4450
protected function subEntities(): array
4551
{
4652
return array_merge(parent::subEntities(), [
47-
// Properties already defined in Chat.php and handled by its subEntities are inherited.
48-
// Add or override here if ChatFullInfo has different types or new sub-entities.
49-
// For example, if PinnedMessage in ChatFullInfo could be a different class than in Chat,
50-
// or if new properties in ChatFullInfo are entities themselves.
51-
// Based on the current structure, most of these are already covered by Chat.php
53+
'parent_chat' => Chat::class,
54+
'rating' => UserRating::class,
55+
'unique_gift_colors' => UniqueGiftColors::class,
56+
'accepted_gift_types' => AcceptedGiftTypes::class,
5257
]);
5358
}
5459
}

src/Entities/ChatMember/ChatMemberAdministrator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method bool getCanEditStories() Optional. True, if the administrator can edit stories posted by other users; channels only
2929
* @method bool getCanDeleteStories() Optional. True, if the administrator can delete stories posted by other users; channels only
3030
* @method bool getCanManageTopics() Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups only
31+
* @method bool getCanManageDirectMessages() Optional. True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only
3132
* @method string getCustomTitle() Custom title for this user
3233
*/
3334
class ChatMemberAdministrator extends Entity implements ChatMember

src/Entities/Checklist.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class Checklist
7+
*
8+
* Describes a checklist.
9+
*
10+
* @link https://core.telegram.org/bots/api#checklist
11+
*
12+
* @method string getTitle() Title of the checklist
13+
* @method MessageEntity[] getTitleEntities() Optional. Special entities that appear in the checklist title
14+
* @method ChecklistTask[] getTasks() List of tasks in the checklist
15+
* @method bool getOthersCanAddTasks() Optional. True, if users other than the creator of the list can add tasks to the list
16+
* @method bool getOthersCanMarkTasksAsDone() Optional. True, if users other than the creator of the list can mark tasks as done or not done
17+
*/
18+
class Checklist extends Entity
19+
{
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
protected function subEntities(): array
24+
{
25+
return [
26+
'title_entities' => [MessageEntity::class],
27+
'tasks' => [ChecklistTask::class],
28+
];
29+
}
30+
}

src/Entities/ChecklistTask.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities;
4+
5+
/**
6+
* Class ChecklistTask
7+
*
8+
* Describes a task in a checklist.
9+
*
10+
* @link https://core.telegram.org/bots/api#checklisttask
11+
*
12+
* @method int getId() Unique identifier of the task
13+
* @method string getText() Text of the task
14+
* @method MessageEntity[] getTextEntities() Optional. Special entities that appear in the task text
15+
* @method User getCompletedByUser() Optional. User that completed the task; omitted if the task wasn't completed by a user
16+
* @method Chat getCompletedByChat() Optional. Chat that completed the task; omitted if the task wasn't completed by a chat
17+
* @method int getCompletionDate() Optional. Point in time (Unix timestamp) when the task was completed; 0 if the task wasn't completed
18+
*/
19+
class ChecklistTask extends Entity
20+
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
protected function subEntities(): array
25+
{
26+
return [
27+
'text_entities' => [MessageEntity::class],
28+
'completed_by_user' => User::class,
29+
'completed_by_chat' => Chat::class,
30+
];
31+
}
32+
}

0 commit comments

Comments
 (0)