1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Sysbot\Telegram\ExtendedTypes; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use GuzzleHttp\Promise\PromiseInterface; |
8
|
|
|
|
9
|
|
|
trait User |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
use BaseChat; |
13
|
|
|
|
14
|
|
|
public function ban(int|string $chatId, ?int $untilDate = null, ?bool $revokeMessages = null): PromiseInterface |
15
|
|
|
{ |
16
|
|
|
return $this->api->banChatMember( |
17
|
|
|
chatId: $chatId, |
18
|
|
|
userId: $this->id, |
19
|
|
|
untilDate: $untilDate, |
20
|
|
|
revokeMessages: $revokeMessages |
21
|
|
|
); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function unban(int|string $chatId, ?bool $onlyIfBanned = null): PromiseInterface |
25
|
|
|
{ |
26
|
|
|
return $this->api->unbanChatMember( |
27
|
|
|
chatId: $chatId, |
28
|
|
|
userId: $this->id, |
29
|
|
|
onlyIfBanned: $onlyIfBanned |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function promote( |
34
|
|
|
int|string $chatId, |
35
|
|
|
?bool $isAnonymous = null, |
36
|
|
|
?bool $canManageChat = null, |
37
|
|
|
?bool $canPostMessages = null, |
38
|
|
|
?bool $canEditMessages = null, |
39
|
|
|
?bool $canDeleteMessages = null, |
40
|
|
|
?bool $canManageVoiceChats = null, |
41
|
|
|
?bool $canRestrictMembers = null, |
42
|
|
|
?bool $canPromoteMembers = null, |
43
|
|
|
?bool $canChangeInfo = null, |
44
|
|
|
?bool $canInviteUsers = null, |
45
|
|
|
?bool $canPinMessages = null |
46
|
|
|
): PromiseInterface { |
47
|
|
|
return $this->api->promoteChatMember( |
48
|
|
|
chatId: $chatId, |
49
|
|
|
userId: $this->id, |
50
|
|
|
isAnonymous: $isAnonymous, |
51
|
|
|
canManageChat: $canManageChat, |
52
|
|
|
canPostMessages: $canPostMessages, |
53
|
|
|
canEditMessages: $canEditMessages, |
54
|
|
|
canDeleteMessages: $canDeleteMessages, |
55
|
|
|
canManageVoiceChats: $canManageVoiceChats, |
56
|
|
|
canRestrictMembers: $canRestrictMembers, |
57
|
|
|
canPromoteMembers: $canPromoteMembers, |
58
|
|
|
canChangeInfo: $canChangeInfo, |
59
|
|
|
canInviteUsers: $canInviteUsers, |
60
|
|
|
canPinMessages: $canPinMessages |
61
|
|
|
); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function demote(int|string $chatId): PromiseInterface |
65
|
|
|
{ |
66
|
|
|
return $this->promote(chatId: $chatId); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function restrict( |
70
|
|
|
int|string $chatId, |
71
|
|
|
\Sysbot\Telegram\Types\ChatPermissions $permissions, |
72
|
|
|
?int $untilDate = null |
73
|
|
|
): PromiseInterface { |
74
|
|
|
return $this->api->restrictChatMember( |
75
|
|
|
chatId: $chatId, |
76
|
|
|
userId: $this->id, |
77
|
|
|
permissions: $permissions, |
78
|
|
|
untilDate: $untilDate |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function unrestrict(int|string $chatId): PromiseInterface |
83
|
|
|
{ |
84
|
|
|
return $this->promote(chatId: $chatId); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |