Closed mjavidm closed 7 years ago
This is an example i used for a gamebot:
if ($data["inline_query"] !== null && $data["inline_query"] != "") {
$query = $data["inline_query"]["query"];
if (strpos("testText", $query) !== false) {
$results = json_encode(array( array('type' => "game", 'id'=> "1", 'game_short_name' => "game_name") ) );
$content = array('inline_query_id' => $data["inline_query"]["id"], 'results' => $results );
$reply = $telegram->answerInlineQuery($content);
}
}
Thank you But how it works? How to cal it...
first follow this steps: https://core.telegram.org/bots/api#inline-mode
then in any chat you should be able to write a message like @botusername testText and the if should trigger. You need of course to change $resulto your inline query result (https://core.telegram.org/bots/api#inlinequeryresult), idk what you want to do. Example of InlineQueryResultGif $results = json_encode(array( array('type' => "gif", 'id'=> "1", 'gif_url' => "http://gifUrl.gif", 'thumb_url'=>"http://thumburl.gif") ) );
Example 4 gifs:
if ($data["inline_query"] !== null && $data["inline_query"] != "") {
$query = $data["inline_query"]["query"];
if (strpos("testText", $query) !== false) {
$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") ) );
$content = array('inline_query_id' => $data["inline_query"]["id"], 'results' => $results );
$reply = $telegram->answerInlineQuery($content);
}
if (strpos("dance", $query) !== false) {
$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") ) );
$content = array('inline_query_id' => $data["inline_query"]["id"], 'results' => $results );
$reply = $telegram->answerInlineQuery($content);
}
}
Try it on cowmooobot: @cowmooobot dance
Thank you not work :( I set "dance" command /setinline in @botfother and put code in hook.php
and in other chat calling bot nothing , not work
but call @cowmooobot dance and show gif dancing ...
Be sure your Telegram.php is update. Also can you post some the code of your bot, just the part where you manage the telegram's incoming messages ?
OK Alright! thank you very much pleas put sample code of InlineQueryResultArticle completely how to create InputMessageContent !! not work!
did you try
$results = json_encode(array( array('type' => "article", 'id'=> "1", 'title' => "The title", 'input_message_content'=>array('message_text' => "Text message") ) ) );
?
yes, but not put "array"! thank you
hi, plz put sample code of InlineQuery I looked but not found