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\InternalFunctionality\TelegramRawData; |
11
|
|
|
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Use this method to send answers to an inline query. On success, True is returned. |
15
|
|
|
* No more than 50 results per query are allowed. |
16
|
|
|
* |
17
|
|
|
* Objects defined as-is july 2016 |
18
|
|
|
* |
19
|
|
|
* @see https://core.telegram.org/bots/api#answerinlinequery |
20
|
|
|
*/ |
21
|
|
|
class AnswerInlineQuery extends TelegramMethods |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Unique identifier for the answered query |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
public $inline_query_id = ''; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* A JSON-serialized array (of InlineQueryResult) of results for the inline query |
31
|
|
|
* @var array |
32
|
|
|
*/ |
33
|
|
|
public $results = []; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Optional. The maximum amount of time in seconds that the result of the inline query may be cached on the server. |
37
|
|
|
* Defaults to 300. |
38
|
|
|
* @var int |
39
|
|
|
*/ |
40
|
|
|
public $cache_time = 300; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Optional. Pass True, if results may be cached on the server side only for the user that sent the query. By |
44
|
|
|
* default, results may be returned to any user who sends the same query |
45
|
|
|
* @var bool |
46
|
|
|
*/ |
47
|
|
|
public $is_personal = false; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Optional. Pass the offset that a client should send in the next query with the same text to receive more results. |
51
|
|
|
* Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t |
52
|
|
|
* exceed 64 bytes. |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
public $next_offset = ''; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Optional. If passed, clients will display a button with specified text that switches the user to a private chat |
59
|
|
|
* with the bot and sends the bot a start message with the parameter switch_pm_parameter |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
public $switch_pm_text = ''; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Optional. Parameter for the start message sent to the bot when user presses the switch button |
66
|
|
|
* |
67
|
|
|
* Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to |
68
|
|
|
* adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the |
69
|
|
|
* results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in |
70
|
|
|
* doing so, passes a start parameter that instructs the bot to return an oauth link. Once done, the bot can offer a |
71
|
|
|
* switch_inline button so that the user can easily return to the chat where they wanted to use the bot's inline |
72
|
|
|
* capabilities. |
73
|
|
|
* |
74
|
|
|
* @var string |
75
|
|
|
*/ |
76
|
|
|
public $switch_pm_parameter = ''; |
77
|
|
|
|
78
|
1 |
|
public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
79
|
|
|
{ |
80
|
1 |
|
return new ResultBoolean($data->getResultBoolean(), $logger); |
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
public function performSpecialConditions(): TelegramMethods |
84
|
|
|
{ |
85
|
1 |
|
$this->results = json_encode($this->results); |
86
|
|
|
|
87
|
1 |
|
return parent::performSpecialConditions(); |
88
|
|
|
} |
89
|
|
|
|
90
|
1 |
|
public function getMandatoryFields(): array |
91
|
|
|
{ |
92
|
|
|
return [ |
93
|
1 |
|
'inline_query_id', |
94
|
|
|
'results', |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|