|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Greenplugin\TelegramBot\Type; |
|
6
|
|
|
|
|
7
|
|
|
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class InlineKeyboardButtonType. |
|
11
|
|
|
* |
|
12
|
|
|
* @see https://core.telegram.org/bots/api#inlinekeyboardbutton |
|
13
|
|
|
*/ |
|
14
|
|
|
class InlineKeyboardButtonType |
|
15
|
|
|
{ |
|
16
|
|
|
use FillFromArrayTrait; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Label text on the button. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
public $text; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Optional. HTTP or tg:// url to be opened when button is pressed. |
|
27
|
|
|
* |
|
28
|
|
|
* @var string|null |
|
29
|
|
|
*/ |
|
30
|
|
|
public $url; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. |
|
34
|
|
|
* |
|
35
|
|
|
* @var string|null |
|
36
|
|
|
*/ |
|
37
|
|
|
public $callbackData; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and |
|
41
|
|
|
* insert the bot‘s username and the specified inline query in the input field. |
|
42
|
|
|
* Can be empty, in which case just the bot’s username will be inserted. |
|
43
|
|
|
* |
|
44
|
|
|
* Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a |
|
45
|
|
|
* private chat with it. Especially useful when combined with switch_pm… actions – in this case the user |
|
46
|
|
|
* will be automatically returned to the chat they switched from, skipping the chat selection screen. |
|
47
|
|
|
* |
|
48
|
|
|
* @var string|null |
|
49
|
|
|
*/ |
|
50
|
|
|
public $switchInlineQuery; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the |
|
54
|
|
|
* current chat's input field. Can be empty, in which case only the bot’s username will be inserted. |
|
55
|
|
|
* |
|
56
|
|
|
* This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting |
|
57
|
|
|
* something from multiple options. |
|
58
|
|
|
* |
|
59
|
|
|
* @var string|null |
|
60
|
|
|
*/ |
|
61
|
|
|
public $switchInlineQueryCurrentChat; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Optional. Description of the game that will be launched when the user presses the button. |
|
65
|
|
|
* |
|
66
|
|
|
* NOTE: This type of button must always be the first button in the first row. |
|
67
|
|
|
* |
|
68
|
|
|
* @var CallbackGameType|null |
|
69
|
|
|
*/ |
|
70
|
|
|
public $callbackGame; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Specify True, to send a Pay button. |
|
74
|
|
|
* |
|
75
|
|
|
* NOTE: This type of button must always be the first button in the first row. |
|
76
|
|
|
* |
|
77
|
|
|
* @var bool|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public $pay; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* InlineKeyboardButtonType constructor. |
|
83
|
|
|
* |
|
84
|
|
|
* @param string $text |
|
85
|
|
|
* @param array|null $data |
|
86
|
|
|
* |
|
87
|
|
|
* @throws \Greenplugin\TelegramBot\Exception\BadArgumentException |
|
88
|
|
|
*/ |
|
89
|
|
|
public function __construct(string $text, array $data = null) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->text = $text; |
|
92
|
|
|
if ($data) { |
|
93
|
|
|
$this->fill($data); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|