1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Method; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Interfaces\EditMethodAliasInterface; |
8
|
|
|
use TgBotApi\BotApiBase\Method\Traits\EditMessageVariablesTrait; |
9
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
10
|
|
|
use TgBotApi\BotApiBase\Type\InputMedia\InputMediaType; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class EditMessageMediaMethod. |
14
|
|
|
* |
15
|
|
|
* @see https://core.telegram.org/bots/api#editmessagemedia |
16
|
|
|
*/ |
17
|
|
|
class EditMessageMediaMethod implements EditMethodAliasInterface |
18
|
|
|
{ |
19
|
|
|
use FillFromArrayTrait; |
20
|
|
|
use EditMessageVariablesTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* A JSON-serialized object for a new media content of the message. |
24
|
|
|
* |
25
|
|
|
* @var InputMediaType |
26
|
|
|
*/ |
27
|
|
|
public $media; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param int|string $chatId |
31
|
|
|
* @param int $messageId |
32
|
|
|
* @param InputMediaType $media |
33
|
|
|
* @param array|null $data |
34
|
|
|
* |
35
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
36
|
|
|
* |
37
|
|
|
* @return EditMessageMediaMethod |
38
|
|
|
*/ |
39
|
1 |
|
public static function create( |
40
|
|
|
$chatId, |
41
|
|
|
int $messageId, |
42
|
|
|
InputMediaType $media, |
43
|
|
|
array $data = null |
44
|
|
|
): EditMessageMediaMethod { |
45
|
1 |
|
$instance = new static(); |
46
|
1 |
|
$instance->chatId = $chatId; |
47
|
1 |
|
$instance->media = $media; |
48
|
1 |
|
$instance->messageId = $messageId; |
49
|
1 |
|
if ($data) { |
50
|
1 |
|
$instance->fill($data, ['chatId', 'media', 'messageId', 'caption']); |
51
|
|
|
} |
52
|
|
|
|
53
|
1 |
|
return $instance; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $inlineMessageId |
58
|
|
|
* @param InputMediaType $media |
59
|
|
|
* @param array|null $data |
60
|
|
|
* |
61
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
62
|
|
|
* |
63
|
|
|
* @return EditMessageMediaMethod |
64
|
|
|
*/ |
65
|
3 |
|
public static function createInline( |
66
|
|
|
string $inlineMessageId, |
67
|
|
|
InputMediaType $media, |
68
|
|
|
array $data = null |
69
|
|
|
): EditMessageMediaMethod { |
70
|
3 |
|
$instance = new static(); |
71
|
3 |
|
$instance->inlineMessageId = $inlineMessageId; |
72
|
3 |
|
$instance->media = $media; |
73
|
3 |
|
if ($data) { |
74
|
3 |
|
$instance->fill($data, ['chatId', 'media', 'messageId', 'caption']); |
75
|
|
|
} |
76
|
|
|
|
77
|
3 |
|
return $instance; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|