1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace TgBotApi\BotApiBase\Type; |
6
|
|
|
|
7
|
|
|
use TgBotApi\BotApiBase\Method\Traits\FillFromArrayTrait; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class ReplyKeyboardMarkupType. |
11
|
|
|
* |
12
|
|
|
* @see https://core.telegram.org/bots/api#replykeyboardmarkup |
13
|
|
|
* @see https://core.telegram.org/bots#keyboards |
14
|
|
|
*/ |
15
|
|
|
class ReplyKeyboardMarkupType |
16
|
|
|
{ |
17
|
|
|
use FillFromArrayTrait; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Array of button rows, each represented by an Array of KeyboardButton objects. |
21
|
|
|
* |
22
|
|
|
* @var KeyboardButtonType[][] |
23
|
|
|
*/ |
24
|
|
|
public $keyboard; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller |
28
|
|
|
* if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always |
29
|
|
|
* of the same height as the app's standard keyboard. |
30
|
|
|
* |
31
|
|
|
* @var bool|null |
32
|
|
|
*/ |
33
|
|
|
public $resizeKeyboard; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, |
37
|
|
|
* but clients will automatically display the usual letter-keyboard in the chat – the user can press a special |
38
|
|
|
* button in the input field to see the custom keyboard again. Defaults to false. |
39
|
|
|
* |
40
|
|
|
* @var bool|null |
41
|
|
|
*/ |
42
|
|
|
public $oneTimeKeyboard; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users |
46
|
|
|
* that are @mentioned in the text of the MessageType object; |
47
|
|
|
* 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. |
48
|
|
|
* |
49
|
|
|
* Example: A user requests to change the bot‘s language, bot replies to the request with a keyboard to |
50
|
|
|
* select the new language. Other users in the group don’t see the keyboard. |
51
|
|
|
* |
52
|
|
|
* @var bool|null |
53
|
|
|
*/ |
54
|
|
|
public $selective; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param KeyboardButtonType[][] $keyboard |
58
|
|
|
* @param array|null $data |
59
|
|
|
* |
60
|
|
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
61
|
|
|
* |
62
|
|
|
* @return ReplyKeyboardMarkupType |
63
|
|
|
*/ |
64
|
12 |
|
public static function create(array $keyboard, array $data = null): ReplyKeyboardMarkupType |
65
|
|
|
{ |
66
|
12 |
|
$instance = new static(); |
67
|
12 |
|
$instance->keyboard = $keyboard; |
68
|
12 |
|
if ($data) { |
69
|
12 |
|
$instance->fill($data); |
70
|
|
|
} |
71
|
|
|
|
72
|
12 |
|
return $instance; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|