Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send picture after user press inline button #39

Closed
FrankAmini opened this issue Oct 31, 2016 · 5 comments
Closed

send picture after user press inline button #39

FrankAmini opened this issue Oct 31, 2016 · 5 comments

Comments

@FrankAmini
Copy link

hi
first of all ,appreciate for develop this useful class,and thank you share it for us
i have problem in catch inline button and send answer

here is my code
$option = array(
array( $telegram->buildInlineKeyboardButton($text="One","",$callback_data="One",""),$telegram->buildInlineKeyboardButton($text="Two","",$callback_data="Two","") )

 );

$keyb = $telegram->buildInlineKeyBoard($option);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "One Or Two ?");
$telegram->sendMessage($content);

i want send different picture after user press (One or Two) buttons
how can i do it ?

Regards,Frank

@Eleirbag89
Copy link
Owner

Eleirbag89 commented Oct 31, 2016

after you parse the telegram's reply, right before the message content parsing, do:

if ($callback_query !== null && $callback_query != "") {
    $callback = $telegram->Callback_Data();
        if ($callback == "One") {
            //send Picture 1
         } else if ($callback == "Two") {
             //send Picture 2
         }  
}

@avaresaneh
Copy link

this code above not work
what is get callback_query in bot code
this not work me? why?!

@Mohsen322
Copy link
Contributor

Mohsen322 commented Jan 14, 2017

@Eleirbag89 hi bro.
how can i use that code? doesnt work seems...
call back data i mean

@Eleirbag89
Copy link
Owner

Eleirbag89 commented Jan 14, 2017

The same code works in CowBot (you can try the /inline command and choose the Test2 button).

$telegram = new Telegram($bot_id);
$text = $telegram->Text();
$chat_id = $telegram->ChatID();
$data = $telegram->getData();
$callback_query = $telegram->Callback_Query();
if ($callback_query !== null && $callback_query != "") {
    $reply = "Callback data value".$telegram->Callback_Data();
    $content = array('chat_id' => $telegram->Callback_ChatID(), 'text' => $reply);
    $telegram->sendMessage($content);
   
    $content = array('callback_query_id' => $telegram->Callback_ID(), 'text' => $reply, 'show_alert' => true);
    $telegram->answerCallbackQuery($content);
    
}
if ($text == "/inline") {
    $option = array( array( $telegram->buildInlineKeyboardButton("Test", $url="http://google.it"), $telegram->buildInlineKeyboardButton($text="Test2","","Callback","") ) );
    $keyb = $telegram->buildInlineKeyBoard($option);
    $content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "Welcome to CowBot \xF0\x9F\x90\xAE \nPlease type /cowsay or click the Cow button !");
    $telegram->sendMessage($content);
}

@Mohsen322
Copy link
Contributor

Mohsen322 commented Jan 14, 2017

very very thanks @Eleirbag89
great support, work like a boss!

thanks again, my wrong was i used codes in wrong place.
anyway now anything work great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants