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 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. An HTTP URL used to automatically authorize the user. |
34
|
|
|
* Can be used as a replacement for the Telegram Login Widget. |
35
|
|
|
* |
36
|
|
|
* @var LoginUrlType | null |
37
|
|
|
*/ |
38
|
|
|
public $loginUrl; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. |
42
|
|
|
* |
43
|
|
|
* @var string|null |
44
|
|
|
*/ |
45
|
|
|
public $callbackData; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and |
49
|
|
|
* insert the bot‘s username and the specified inline query in the input field. |
50
|
|
|
* Can be empty, in which case just the bot’s username will be inserted. |
51
|
|
|
* |
52
|
|
|
* Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a |
53
|
|
|
* private chat with it. Especially useful when combined with switch_pm… actions – in this case the user |
54
|
|
|
* will be automatically returned to the chat they switched from, skipping the chat selection screen. |
55
|
|
|
* |
56
|
|
|
* @var string|null |
57
|
|
|
*/ |
58
|
|
|
public $switchInlineQuery; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the |
62
|
|
|
* current chat's input field. Can be empty, in which case only the bot’s username will be inserted. |
63
|
|
|
* |
64
|
|
|
* This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting |
65
|
|
|
* something from multiple options. |
66
|
|
|
* |
67
|
|
|
* @var string|null |
68
|
|
|
*/ |
69
|
|
|
public $switchInlineQueryCurrentChat; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Optional. Description of the game that will be launched when the user presses the button. |
73
|
|
|
* |
74
|
|
|
* NOTE: This type of button must always be the first button in the first row. |
75
|
|
|
* |
76
|
|
|
* @var CallbackGameType|null |
77
|
|
|
*/ |
78
|
|
|
public $callbackGame; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Specify True, to send a Pay button. |
82
|
|
|
* |
83
|
|
|
* NOTE: This type of button must always be the first button in the first row. |
84
|
|
|
* |
85
|
|
|
* @var bool|null |
86
|
|
|
*/ |
87
|
|
|
public $pay; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Optional. Description of the Web App that will be launched when the user presses the button. |
91
|
|
|
* The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. |
92
|
|
|
* Available only in private chats between a user and the bot. |
93
|
|
|
* |
94
|
|
|
* @var WebAppInfoType|null |
95
|
|
|
*/ |
96
|
|
|
public $webApp; |
97
|
19 |
|
|
98
|
|
|
/** |
99
|
19 |
|
* @param string $text |
100
|
19 |
|
* @param array|null $data |
101
|
19 |
|
* |
102
|
19 |
|
* @throws \TgBotApi\BotApiBase\Exception\BadArgumentException |
103
|
|
|
* |
104
|
|
|
* @return InlineKeyboardButtonType |
105
|
19 |
|
*/ |
106
|
|
|
public static function create(string $text, array $data = null): InlineKeyboardButtonType |
107
|
|
|
{ |
108
|
|
|
$instance = new static(); |
109
|
|
|
$instance->text = $text; |
110
|
|
|
if ($data) { |
111
|
|
|
$instance->fill($data); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $instance; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|