Skip to content

Commit 2461779

Browse files
committed
Method answerCallbackQuery
1 parent f368bc3 commit 2461779

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/telegram/TelegramBotApi.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use php\net\URLConnection;
1818
use telegram\exception\TelegramError;
1919
use telegram\exception\TelegramException;
20+
use telegram\query\TAnswerCallbackQuery;
2021
use telegram\query\TForwardMessageQuery;
2122
use telegram\query\TGetFileQuery;
2223
use telegram\query\TGetMeQuery;
@@ -163,6 +164,13 @@ function getUpdates(){
163164
return new TGetUpdatesQuery($this);
164165
}
165166

167+
/**
168+
* @return TAnswerCallbackQuery
169+
*/
170+
function answerCallbackQuery(){
171+
return new TAnswerCallbackQuery($this);
172+
}
173+
166174

167175
function setProxy(?Proxy $proxy){
168176
$this->proxy = $proxy;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
namespace telegram\query;
3+
4+
5+
use telegram\TelegramBotApi;
6+
use telegram\exception\TelegramException;
7+
use telegram\object\TMessage;
8+
use telegram\object\markup\AbstractMarkup;
9+
10+
/**
11+
* --EN--
12+
* Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
13+
*
14+
* --RU--
15+
* Метод для ответа на callbackQuery, поступающий при нажатии на кнопку InlineKeyboard
16+
*
17+
* @see https://core.telegram.org/bots/api#answercallbackquery
18+
*/
19+
class TAnswerCallbackQuery extends TBaseQuery {
20+
public function __construct(TelegramBotApi $api){
21+
parent::__construct($api, 'answerCallbackQuery', false);
22+
}
23+
24+
/**
25+
* --EN--
26+
* Unique identifier for the query to be answered
27+
*
28+
* @param string $value
29+
* @return TAnswerCallbackQuery
30+
*/
31+
public function callback_query_id(string $value){
32+
return $this->put(__FUNCTION__, $value);
33+
}
34+
35+
/**
36+
* --EN--
37+
* Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
38+
*
39+
* @param string $value
40+
* @return TAnswerCallbackQuery
41+
*/
42+
public function text(string $value){
43+
return $this->put(__FUNCTION__, $value);
44+
}
45+
46+
/**
47+
* --EN--
48+
* URL that will be opened by the user's client.
49+
*
50+
* @param string $value
51+
* @return TAnswerCallbackQuery
52+
*/
53+
public function url(string $value){
54+
return $this->put(__FUNCTION__, $value);
55+
}
56+
57+
/**
58+
* --EN--
59+
* If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
60+
*
61+
* @param string $value
62+
* @return TAnswerCallbackQuery
63+
*/
64+
public function show_alert(bool $value){
65+
return $this->put(__FUNCTION__, $value);
66+
}
67+
68+
/**
69+
* --EN--
70+
* The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
71+
*
72+
* @param string $value
73+
* @return TAnswerCallbackQuery
74+
*/
75+
public function cache_time(int $value){
76+
return $this->put(__FUNCTION__, $value);
77+
}
78+
}

0 commit comments

Comments
 (0)