|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
|
6
|
|
|
|
|
7
|
|
|
use Generator; |
|
8
|
|
|
use Psr\Log\LoggerInterface; |
|
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
|
10
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
|
11
|
|
|
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse; |
|
12
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile; |
|
13
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be |
|
17
|
|
|
* an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success |
|
18
|
|
|
* |
|
19
|
|
|
* Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Admins’ setting is |
|
20
|
|
|
* off in the target group |
|
21
|
|
|
* |
|
22
|
|
|
* Objects defined as-is july 2017 |
|
23
|
|
|
* |
|
24
|
|
|
* @see https://core.telegram.org/bots/api#setchatphoto |
|
25
|
|
|
*/ |
|
26
|
|
|
class SetChatPhoto extends TelegramMethods |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Unique identifier for the target chat or username of the target supergroup or channel (in the format |
|
30
|
|
|
* @channelusername) |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
public $chat_id = ''; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* New chat photo, uploaded using multipart/form-data |
|
37
|
|
|
* @var InputFile |
|
38
|
|
|
*/ |
|
39
|
|
|
public $photo; |
|
40
|
|
|
|
|
41
|
|
|
public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes |
|
42
|
|
|
{ |
|
43
|
|
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getMandatoryFields(): array |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
|
|
'chat_id', |
|
50
|
|
|
'photo', |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function hasLocalFiles(): bool |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->photo instanceof InputFile; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getLocalFiles(): Generator |
|
60
|
|
|
{ |
|
61
|
|
|
yield 'photo' => $this->photo; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|