|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace unreal4u\TelegramAPI\Telegram\Methods; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
|
8
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramMethods; |
|
9
|
|
|
use unreal4u\TelegramAPI\Abstracts\TelegramTypes; |
|
10
|
|
|
use unreal4u\TelegramAPI\Exceptions\InvalidResultType; |
|
11
|
|
|
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData; |
|
12
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; |
|
13
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Inline\Keyboard\Markup; |
|
14
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Message; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited |
|
18
|
|
|
* message is sent by the bot, the edited Message is returned, otherwise True is returned. |
|
19
|
|
|
* |
|
20
|
|
|
* Objects defined as-is july 2016 |
|
21
|
|
|
* |
|
22
|
|
|
* @see https://core.telegram.org/bots/api#editmessagecaption |
|
23
|
|
|
*/ |
|
24
|
|
|
class EditMessageCaption extends TelegramMethods |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target |
|
28
|
|
|
* channel (in the format @channelusername) |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
public $chat_id = ''; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Required if inline_message_id is not specified. Unique identifier of the sent message |
|
35
|
|
|
* @var int |
|
36
|
|
|
*/ |
|
37
|
|
|
public $message_id = 0; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Required if chat_id and message_id are not specified. Identifier of the inline message |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
public $inline_message_id = ''; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* New caption of the message |
|
47
|
|
|
* @var string |
|
48
|
|
|
*/ |
|
49
|
|
|
public $caption = ''; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Optional. A JSON-serialized object for an inline keyboard. |
|
53
|
|
|
* @var Markup |
|
54
|
|
|
*/ |
|
55
|
|
|
public $reply_markup; |
|
56
|
|
|
|
|
57
|
|
|
public function getMandatoryFields(): array |
|
58
|
|
|
{ |
|
59
|
|
|
$returnValue = []; |
|
60
|
|
|
return $this->mandatoryUserOrInlineMessageId($returnValue); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
|
64
|
|
|
{ |
|
65
|
|
|
$typeOfResult = $data->getTypeOfResult(); |
|
66
|
|
|
switch ($typeOfResult) { |
|
67
|
|
|
case 'array': |
|
68
|
|
|
return new Message($data->getResult(), $logger); |
|
69
|
|
|
case 'boolean': |
|
70
|
|
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
|
71
|
|
|
default: |
|
72
|
|
|
throw new InvalidResultType('Result is of type: %s. Expecting one of array or boolean'); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|