|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
|
6
|
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\RestrictMethodAliasInterface; |
|
8
|
|
|
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait; |
|
9
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
|
10
|
|
|
use TgBotApi\BotApiBase\Method\Traits\UserIdVariableTrait; |
|
11
|
|
|
use TgBotApi\BotApiBase\Type\ChatPermissionsType; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class RestrictChatMemberMethod. |
|
15
|
|
|
* |
|
16
|
|
|
* @see https://core.telegram.org/bots/api#restrictchatmember |
|
17
|
|
|
*/ |
|
18
|
|
|
class RestrictChatMemberMethod implements RestrictMethodAliasInterface |
|
19
|
|
|
{ |
|
20
|
|
|
use FillFromArrayTrait; |
|
21
|
|
|
use ChatIdVariableTrait; |
|
22
|
|
|
use UserIdVariableTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Optional. Date when the user will be unbanned, DateTimeInterface. |
|
26
|
|
|
* If user is banned for more than 366 days or less than 30 seconds |
|
27
|
|
|
* from the current time they are considered to be banned forever. |
|
28
|
|
|
* |
|
29
|
|
|
* @var \DateTimeInterface|null |
|
30
|
|
|
*/ |
|
31
|
|
|
public $untilDate; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Optional. Pass True, if the user can send text messages, contacts, locations and venues. |
|
35
|
|
|
* |
|
36
|
|
|
* @deprecated |
|
37
|
|
|
* |
|
38
|
|
|
* @var bool|null |
|
39
|
|
|
*/ |
|
40
|
|
|
public $canSendMessages; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Optional. Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, |
|
44
|
|
|
* implies can_send_messages. |
|
45
|
|
|
* |
|
46
|
|
|
* @deprecated |
|
47
|
|
|
* |
|
48
|
|
|
* @var bool|null |
|
49
|
|
|
*/ |
|
50
|
|
|
public $canSendMediaMessages; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Optional. Pass True, if the user can send animations, games, stickers and use inline bots, |
|
54
|
|
|
* implies can_send_media_messages. |
|
55
|
|
|
* |
|
56
|
|
|
* @deprecated |
|
57
|
|
|
* |
|
58
|
|
|
* @var bool|null |
|
59
|
|
|
*/ |
|
60
|
|
|
public $canSendOtherMessages; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Optional. Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. |
|
64
|
|
|
* |
|
65
|
|
|
* @deprecated |
|
66
|
|
|
* |
|
67
|
|
|
* @var bool|null |
|
68
|
|
|
*/ |
|
69
|
|
|
public $canAddWebPagePreviews; |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* New user permissions. |
|
73
|
|
|
* |
|
74
|
|
|
* @var ChatPermissionsType |
|
75
|
|
|
*/ |
|
76
|
|
|
public $permissions; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param $chatId |
|
80
|
|
|
* @param int $userId |
|
81
|
|
|
* @param array|null $data |
|
82
|
|
|
* |
|
83
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
|
84
|
|
|
* |
|
85
|
|
|
* @return RestrictChatMemberMethod |
|
86
|
|
|
* |
|
87
|
|
|
* @deprecated |
|
88
|
|
|
* @see https://core.telegram.org/bots/api#july-29-2019 |
|
89
|
|
|
*/ |
|
90
|
1 |
|
public static function createOld($chatId, int $userId, array $data = null): RestrictChatMemberMethod |
|
91
|
|
|
{ |
|
92
|
1 |
|
$instance = new static(); |
|
93
|
1 |
|
$instance->chatId = $chatId; |
|
94
|
1 |
|
$instance->userId = $userId; |
|
95
|
1 |
|
if ($data) { |
|
96
|
1 |
|
$instance->fill($data); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
1 |
|
return $instance; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param $chatId |
|
104
|
|
|
* @param int $userId |
|
105
|
|
|
* @param ChatPermissionsType $chatPermissionsType |
|
106
|
|
|
* @param array|null $data |
|
107
|
|
|
* |
|
108
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
|
109
|
|
|
* |
|
110
|
|
|
* @return RestrictChatMemberMethod |
|
111
|
|
|
*/ |
|
112
|
1 |
|
public static function create( |
|
113
|
|
|
$chatId, |
|
114
|
|
|
int $userId, |
|
115
|
|
|
ChatPermissionsType $chatPermissionsType, |
|
116
|
|
|
array $data = null |
|
117
|
|
|
): RestrictChatMemberMethod { |
|
118
|
1 |
|
$instance = new static(); |
|
119
|
1 |
|
$instance->chatId = $chatId; |
|
120
|
1 |
|
$instance->userId = $userId; |
|
121
|
1 |
|
$instance->permissions = $chatPermissionsType; |
|
122
|
1 |
|
if ($data) { |
|
123
|
1 |
|
$instance->fill($data); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
1 |
|
return $instance; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|