Comments (9)
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);
}
}
from telegrambotphp.
Thank you
But how it works?
How to cal it...
from telegrambotphp.
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") ) );
from telegrambotphp.
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
from telegrambotphp.
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 ...
from telegrambotphp.
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 ?
from telegrambotphp.
OK Alright!
thank you very much
pleas put sample code of InlineQueryResultArticle completely
how to create InputMessageContent !! not work!
from telegrambotphp.
did you try
$results = json_encode(array( array('type' => "article", 'id'=> "1", 'title' => "The title", 'input_message_content'=>array('message_text' => "Text message") ) ) );
?
from telegrambotphp.
yes, but not put "array"!
thank you
from telegrambotphp.
Related Issues (20)
- Unable to get phone number HOT 1
- Telegram::getChatMembersCount() method
- [BUG]
- Hi~~ @Eleirbag89 pls delete this issue,thanks!
- Web Apps HOT 8
- UpdateCount[BUG] HOT 2
- payment function HOT 1
- you have any video for this bot like tutorial ? HOT 1
- How to make wait for answer HOT 2
- Can you create .phar file for this project HOT 9
- [BUG]
- ErrorException Undefined array key "message" when using funtion UserID() HOT 3
- Formatting options HOT 3
- sendMediaGroup not working! HOT 1
- How to get user_id of the message of a user I reply to? HOT 1
- Add API Support for up to API 6.9 (22.09.2023) HOT 1
- Please Add Forward From Username HOT 1
- My button not a have actions
- how to send sticker HOT 2
- Failed to connect to api.telegram.org port 443 after 21043 ms: Timed out HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegrambotphp.