Skip to content

Commit a99576f

Browse files
committed
Add examples for inline and callback
1 parent cccd3ad commit a99576f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bot examples/webhook/update.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,34 @@
2020
$text = $telegram->Text();
2121
$chat_id = $telegram->ChatID();
2222

23+
// Test CallBack
24+
$callback_query = $telegram->Callback_Query();
25+
if ($callback_query !== null && $callback_query != "") {
26+
$reply = "Callback value ".$telegram->Callback_Data();
27+
$content = array('chat_id' => $telegram->Callback_ChatID(), 'text' => $reply);
28+
$telegram->sendMessage($content);
29+
30+
$content = array('callback_query_id' => $telegram->Callback_ID(), 'text' => $reply, 'show_alert' => true);
31+
$telegram->answerCallbackQuery($content);
32+
}
33+
34+
//Test Inline
35+
$data = $telegram->getData();
36+
if ($data["inline_query"] !== null && $data["inline_query"] != "") {
37+
// GIF Examples
38+
if (strpos("testText", $query) !== false) {
39+
$results = json_encode(array( array('type' => "gif", 'id'=> "1", 'gif_url' => "http://i1260.photobucket.com/albums/ii571/LMFAOSPEAKS/LMFAO/113481459.gif", 'thumb_url'=>"http://i1260.photobucket.com/albums/ii571/LMFAOSPEAKS/LMFAO/113481459.gif") ) );
40+
$content = array('inline_query_id' => $data["inline_query"]["id"], 'results' => $results );
41+
$reply = $telegram->answerInlineQuery($content);
42+
}
43+
44+
if (strpos("dance", $query) !== false) {
45+
$results = json_encode(array( array('type' => "gif", 'id'=> "1", 'gif_url' => "https://media.tenor.co/images/cbbfdd7ff679e2ae442024b5cfed229c/tenor.gif", 'thumb_url'=>"https://media.tenor.co/images/cbbfdd7ff679e2ae442024b5cfed229c/tenor.gif") ) );
46+
$content = array('inline_query_id' => $data["inline_query"]["id"], 'results' => $results );
47+
$reply = $telegram->answerInlineQuery($content);
48+
}
49+
}
50+
2351
// Check if the text is a command
2452
if(!is_null($text) && !is_null($chat_id)){
2553
if ($text == "/test") {

0 commit comments

Comments
 (0)