GithubHelp home page GithubHelp logo

Comments (9)

Eleirbag89 avatar Eleirbag89 commented on August 18, 2024

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.

mjavidm avatar mjavidm commented on August 18, 2024

Thank you
But how it works?
How to cal it...

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on August 18, 2024

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.

Eleirbag89 avatar Eleirbag89 commented on August 18, 2024

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.

mjavidm avatar mjavidm commented on August 18, 2024

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.

Eleirbag89 avatar Eleirbag89 commented on August 18, 2024

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.

mjavidm avatar mjavidm commented on August 18, 2024

OK Alright!
thank you very much
pleas put sample code of InlineQueryResultArticle completely
how to create InputMessageContent !! not work!

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on August 18, 2024

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.

mjavidm avatar mjavidm commented on August 18, 2024

yes, but not put "array"!
thank you

from telegrambotphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.