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 only the reply markup of messages sent by the bot or via the bot (for inline bots). On |
18
|
|
|
* success, if edited 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#editmessagereplymarkup |
23
|
|
|
*/ |
24
|
|
|
class EditMessageReplyMarkup 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
|
|
|
* Optional. A JSON-serialized object for an inline keyboard. |
47
|
|
|
* @var Markup |
48
|
|
|
*/ |
49
|
|
|
public $reply_markup; |
50
|
|
|
|
51
|
|
|
public function getMandatoryFields(): array |
52
|
|
|
{ |
53
|
|
|
$returnValue = []; |
54
|
|
|
return $this->mandatoryUserOrInlineMessageId($returnValue); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
58
|
|
|
{ |
59
|
|
|
$typeOfResult = $data->getTypeOfResult(); |
60
|
|
|
switch ($typeOfResult) { |
61
|
|
|
case 'array': |
62
|
|
|
return new Message($data->getResult(), $logger); |
63
|
|
|
case 'boolean': |
64
|
|
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
65
|
|
|
default: |
66
|
|
|
throw new InvalidResultType('Result is of type: %s. Expecting one of array or boolean'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|