Skip to content

Commit dba9442

Browse files
authored
Merge pull request #153 from DJTommek/pr/api-type-updates
TelegramTypes updates
2 parents b0f7eff + d453691 commit dba9442

File tree

7 files changed

+368
-7
lines changed

7 files changed

+368
-7
lines changed

src/Telegram/Types/ChatInviteLink.php

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace unreal4u\TelegramAPI\Telegram\Types;
6+
7+
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8+
9+
/**
10+
* Represents an invite link for a chat.
11+
*
12+
* @see https://core.telegram.org/bots/api#chatinvitelink
13+
*/
14+
class ChatInviteLink extends TelegramTypes
15+
{
16+
/**
17+
* The invite link. If the link was created by another chat administrator, then the second part of the link will be
18+
* replaced with “…”.
19+
* @var string
20+
*/
21+
public $invite_link;
22+
23+
/**
24+
* Creator of the link
25+
* @var User
26+
*/
27+
public $creator;
28+
29+
/**
30+
* True, if users joining the chat via the link need to be approved by chat administrators
31+
* @var bool
32+
*/
33+
public $creates_join_request = false;
34+
35+
/**
36+
* True, if the link is primary
37+
* @var bool
38+
*/
39+
public $is_primary = false;
40+
41+
/**
42+
* True, if the link is revoked
43+
* @var bool
44+
*/
45+
public $is_revoked = false;
46+
47+
/**
48+
* Optional. Invite link name
49+
* @var string
50+
*/
51+
public $name;
52+
53+
/**
54+
* Optional. Point in time (Unix timestamp) when the link will expire or has been expired
55+
* @var int
56+
*/
57+
public $expire_date;
58+
59+
/**
60+
* Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat via
61+
* this invite link; 1-99999
62+
* @var int
63+
*/
64+
public $member_limit;
65+
66+
/**
67+
* Optional. Number of pending join requests created using this link
68+
* @var int
69+
*/
70+
public $pending_join_request_count;
71+
72+
public function mapSubObjects(string $key, array $data): TelegramTypes
73+
{
74+
switch ($key) {
75+
case 'creator':
76+
return new User($data, $this->logger);
77+
}
78+
79+
return parent::mapSubObjects($key, $data);
80+
}
81+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace unreal4u\TelegramAPI\Telegram\Types;
6+
7+
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8+
9+
/**
10+
* Represents a join request sent to a chat.
11+
*
12+
* @see https://core.telegram.org/bots/api#chatjoinrequest
13+
*/
14+
class ChatJoinRequest extends TelegramTypes
15+
{
16+
/**
17+
* Chat to which the request was sent
18+
*
19+
* @var Chat
20+
*/
21+
public $chat;
22+
23+
/**
24+
* User that sent the join request
25+
*
26+
* @var User
27+
*/
28+
public $from;
29+
30+
/**
31+
* Identifier of a private chat with the user who sent the join request. The bot can use this identifier
32+
* for 24 hours to send messages until the join request is processed, assuming no other administrator contacted
33+
* the user.
34+
*
35+
* @var int
36+
*/
37+
public $user_chat_id;
38+
39+
/**
40+
* Date the request was sent in Unix time
41+
*
42+
* @var int
43+
*/
44+
public $date;
45+
46+
/**
47+
* Optional. Bio of the user.
48+
*
49+
* @var string
50+
*/
51+
public $bio;
52+
53+
/**
54+
* Optional. Chat invite link that was used by the user to send the join request
55+
*
56+
* @var ChatInviteLink
57+
*/
58+
public $invite_link;
59+
60+
public function mapSubObjects(string $key, array $data): TelegramTypes
61+
{
62+
switch ($key) {
63+
case 'chat':
64+
return new Chat($data, $this->logger);
65+
case 'from':
66+
return new User($data, $this->logger);
67+
case 'invite_link':
68+
return new ChatInviteLink($data, $this->logger);
69+
}
70+
71+
return parent::mapSubObjects($key, $data);
72+
}
73+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace unreal4u\TelegramAPI\Telegram\Types;
6+
7+
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
8+
9+
/**
10+
* This object represents changes in the status of a chat member.
11+
*
12+
* @see https://core.telegram.org/bots/api#chatmemberupdated
13+
*/
14+
class ChatMemberUpdated extends TelegramTypes
15+
{
16+
/**
17+
* Chat the user belongs to
18+
* @var Chat
19+
*/
20+
public $chat;
21+
22+
/**
23+
* Performer of the action, which resulted in the change
24+
* @var User
25+
*/
26+
public $from;
27+
28+
/**
29+
* Date the change was done in Unix time
30+
* @var int
31+
*/
32+
public $date;
33+
34+
/**
35+
* Previous information about the chat member
36+
* @var ChatMember
37+
*/
38+
public $old_chat_member;
39+
40+
/**
41+
* New information about the chat member
42+
* @var ChatMember
43+
*/
44+
public $new_chat_member;
45+
46+
/**
47+
* Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
48+
* @var ChatInviteLink
49+
*/
50+
public $invite_link;
51+
52+
/**
53+
* Optional. True, if the user joined the chat via a chat folder invite link
54+
* @var bool
55+
*/
56+
public $via_chat_folder_invite_link;
57+
58+
public function mapSubObjects(string $key, array $data): TelegramTypes
59+
{
60+
switch ($key) {
61+
case 'chat':
62+
return new Chat($data, $this->logger);
63+
case 'from':
64+
return new User($data, $this->logger);
65+
case 'old_chat_member':
66+
case 'new_chat_member':
67+
return new ChatMember($data, $this->logger);
68+
case 'invite_link':
69+
return new ChatInviteLink($data, $this->logger);
70+
}
71+
72+
return parent::mapSubObjects($key, $data);
73+
}
74+
}

src/Telegram/Types/ChatPermissions.php

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace unreal4u\TelegramAPI\Telegram\Types;
66

@@ -27,9 +27,52 @@ class ChatPermissions extends TelegramTypes
2727
* implies can_send_messages
2828
*
2929
* @var bool
30+
* @deprecated Use more granual permissions instead (Bot API 6.5, February 3, 2023 https://core.telegram.org/bots/api-changelog#february-3-2023)
3031
*/
3132
public $can_send_media_messages;
3233

34+
/**
35+
* Optional. True, if the user is allowed to send audios
36+
*
37+
* @var bool
38+
*/
39+
public $can_send_audios;
40+
41+
/**
42+
* Optional. True, if the user is allowed to send documents
43+
*
44+
* @var bool
45+
*/
46+
public $can_send_documents;
47+
48+
/**
49+
* Optional. True, if the user is allowed to send photos
50+
*
51+
* @var bool
52+
*/
53+
public $can_send_photos;
54+
55+
/**
56+
* Optional. True, if the user is allowed to send videos
57+
*
58+
* @var bool
59+
*/
60+
public $can_send_videos;
61+
62+
/**
63+
* Optional. True, if the user is allowed to send video notes
64+
*
65+
* @var bool
66+
*/
67+
public $can_send_video_notes;
68+
69+
/**
70+
* Optional. True, if the user is allowed to send voice notes
71+
*
72+
* @var bool
73+
*/
74+
public $can_send_voice_notes;
75+
3376
/**
3477
* Optional. True, if the user is allowed to send polls, implies can_send_messages
3578
*
@@ -74,4 +117,12 @@ class ChatPermissions extends TelegramTypes
74117
* @var bool
75118
*/
76119
public $can_pin_messages;
120+
121+
/**
122+
* Optional. True, if the user is allowed to create forum topics. If omitted defaults to the
123+
* value of can_pin_messages
124+
*
125+
* @var bool
126+
*/
127+
public $can_manage_topics;
77128
}

src/Telegram/Types/Sticker.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
*/
1616
class Sticker extends TelegramTypes
1717
{
18+
public const TYPE_REGULAR = 'regular';
19+
public const TYPE_MASK = 'mask';
20+
public const TYPE_CUSTOM_EMOJI = 'custom_emoji';
21+
1822
/**
19-
* Unique identifier for this file
23+
* Identifier for this file, which can be used to download or reuse the file
2024
* @var string
2125
*/
2226
public $file_id = '';
@@ -29,6 +33,14 @@ class Sticker extends TelegramTypes
2933
*/
3034
public $file_unique_id = '';
3135

36+
/**
37+
* Type of the sticker, currently one of “regular”, “mask”, “custom_emoji”. The type of the sticker is independent
38+
* from its format, which is determined by the fields is_animated and is_video.
39+
*
40+
* @var string
41+
*/
42+
public $type = '';
43+
3244
/**
3345
* Photo width
3446
* @var int
@@ -49,6 +61,14 @@ class Sticker extends TelegramTypes
4961
*/
5062
public $is_animated = false;
5163

64+
/**
65+
* True, if the sticker is video sticker
66+
* @see https://telegram.org/blog/video-stickers-better-reactions
67+
*
68+
* @var bool
69+
*/
70+
public $is_video = false;
71+
5272
/**
5373
* Optional. Sticker thumbnail in .webp or .jpg format
5474
* @var PhotoSize
@@ -73,12 +93,31 @@ class Sticker extends TelegramTypes
7393
*/
7494
public $set_name = '';
7595

96+
/**
97+
* Optional. For premium regular stickers, premium animation for the sticker
98+
* @var File
99+
*/
100+
public $premium_animation = '';
101+
76102
/**
77103
* Optional. For mask stickers, the position where the mask should be placed
78104
* @var MaskPosition
79105
*/
80106
public $mask_position;
81107

108+
/**
109+
* Optional. For custom emoji stickers, unique identifier of the custom emoji
110+
* @var string
111+
*/
112+
public $custom_emoji_id = '';
113+
114+
/**
115+
* Optional. True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium
116+
* badge in emoji status, white color on chat photos, or another appropriate color in other places
117+
* @var bool
118+
*/
119+
public $needs_repainting = false;
120+
82121
/**
83122
* Optional. File size
84123
* @var int

0 commit comments

Comments
 (0)