|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Greenplugin\TelegramBot\Method; |
|
6
|
|
|
|
|
7
|
|
|
use Greenplugin\TelegramBot\Method\Traits\FillFromArrayTrait; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class AnswerCallbackQueryMethod. |
|
11
|
|
|
* |
|
12
|
|
|
* Use this method to send answers to callback queries sent from inline keyboards. |
|
13
|
|
|
* The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. |
|
14
|
|
|
* On success, True is returned. |
|
15
|
|
|
* |
|
16
|
|
|
* @see https://core.telegram.org/bots/api#answercallbackquery |
|
17
|
|
|
*/ |
|
18
|
|
|
class AnswerCallbackQueryMethod |
|
19
|
|
|
{ |
|
20
|
|
|
use FillFromArrayTrait; |
|
21
|
|
|
/** |
|
22
|
|
|
* Unique identifier for the query to be answered. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
public $callbackQueryId; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Optional. Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters. |
|
30
|
|
|
* |
|
31
|
|
|
* @var string|null |
|
32
|
|
|
*/ |
|
33
|
|
|
public $text; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Optional. If true, an alert will be shown by the client instead of a notification at the top of the chat screen. |
|
37
|
|
|
* Defaults to false. |
|
38
|
|
|
* |
|
39
|
|
|
* @var bool|null |
|
40
|
|
|
*/ |
|
41
|
|
|
public $showAlert; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Optional. URL that will be opened by the user's client. |
|
45
|
|
|
* If you have created a Game and accepted the conditions via @Botfather, |
|
46
|
|
|
* specify the URL that opens your game – note that this will only work |
|
47
|
|
|
* if the query comes from a callback_game button. |
|
48
|
|
|
* |
|
49
|
|
|
* Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. |
|
50
|
|
|
* |
|
51
|
|
|
* @var string|null |
|
52
|
|
|
*/ |
|
53
|
|
|
public $url; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Optional. The maximum amount of time in seconds that the result of the callback query may be cached client-side. |
|
57
|
|
|
* Telegram apps will support caching starting in version 3.14. Defaults to 0. |
|
58
|
|
|
* |
|
59
|
|
|
* @var int|null |
|
60
|
|
|
*/ |
|
61
|
|
|
public $cacheTime; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $callbackQueryId |
|
65
|
|
|
* @param array|null $data |
|
66
|
|
|
* |
|
67
|
|
|
* @throws \Greenplugin\TelegramBot\Exception\BadArgumentException |
|
68
|
|
|
*/ |
|
69
|
|
|
public function __construct(string $callbackQueryId, array $data = null) |
|
70
|
|
|
{ |
|
71
|
|
|
$this->callbackQueryId = $callbackQueryId; |
|
72
|
|
|
if ($data) { |
|
73
|
|
|
$this->fill($data); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|