1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\HasParseModeVariableInterface; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\SendMethodAliasInterface; |
9
|
|
|
use TgBotApi\BotApiBase\Method\Traits\CaptionVariablesTrait; |
10
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
11
|
|
|
use TgBotApi\BotApiBase\Method\Traits\SendToChatVariablesTrait; |
12
|
|
|
use TgBotApi\BotApiBase\Type\InputFileType; |
13
|
|
|
use TgBotApi\BotApiBase\Type\Traits\CaptionEntitiesFieldTrait; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class SendPhotoMethod. |
17
|
|
|
* |
18
|
|
|
* @see https://core.telegram.org/bots/api#sendphoto |
19
|
|
|
*/ |
20
|
|
|
class SendPhotoMethod implements HasParseModeVariableInterface, SendMethodAliasInterface |
21
|
|
|
{ |
22
|
|
|
use FillFromArrayTrait; |
23
|
|
|
use SendToChatVariablesTrait; |
24
|
|
|
use CaptionVariablesTrait; |
25
|
|
|
use CaptionEntitiesFieldTrait; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), |
29
|
|
|
* pass an HTTP URL as a String for Telegram to get a photo from the Internet, |
30
|
|
|
* or upload a new photo using multipart/form-data. |
31
|
|
|
* |
32
|
|
|
* @var InputFileType|string |
33
|
|
|
*/ |
34
|
|
|
public $photo; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param int|string $chatId |
38
|
|
|
* @param InputFileType|string $photo |
39
|
|
|
* |
40
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
41
|
|
|
*/ |
42
|
2 |
|
public static function create($chatId, $photo, array $data = null): SendPhotoMethod |
43
|
|
|
{ |
44
|
2 |
|
$instance = new static(); |
45
|
2 |
|
$instance->chatId = $chatId; |
46
|
2 |
|
$instance->photo = $photo; |
47
|
2 |
|
if ($data) { |
48
|
1 |
|
$instance->fill($data); |
49
|
|
|
} |
50
|
|
|
|
51
|
2 |
|
return $instance; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|