Created
June 25, 2020 13:23
-
-
Save luizmarcus/c7adbd66543eeb8f21129aade2528d16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
'reply_markup' => array('inline_keyboard' => array( | |
//linha 1 | |
array( | |
array('text'=>'Mega-Sena','url'=>'http://g1.globo.com/loterias/megasena.html'), //botão 1 | |
array('text'=>'Quina','url'=>'http://g1.globo.com/loterias/quina.html')//botão 2 | |
), | |
//linha 2 | |
array( | |
array('text'=>'Lotofácil','url'=>'http://g1.globo.com/loterias/lotofacil.html'), //botão 3 | |
array('text'=>'Lotomania','url'=>'http://g1.globo.com/loterias/lotomania.html')//botão 4 | |
), | |
//linha 3 - Essa linha possui botão com comportamento customizado | |
array( | |
array('text'=>'Ver Lotofacil','callback_data'=>'lotofacil'), //botão 3 | |
array('text'=>'Ver Lotomania','callback_data'=>'lotomania')//botão 4 | |
) | |
) | |
))); | |
if (isset($update["message"])) { | |
processMessage($update["message"]); | |
}else if (isset($update["callback_query"])) { //Nessa linha você checa se é um resposta ao clique do botão | |
/* | |
Quando você obtem o callback_query (https://core.telegram.org/bots/api#callbackquery), | |
você precisa responder com um answercallbackquery (https://core.telegram.org/bots/api#answercallbackquery). | |
Isso serve para o telegram entender que a soliticação do usuário foi recebida e respondida. | |
*/ | |
sendMessage("answerCallbackQuery", array('callback_query_id' => $update["callback_query"]["id"], 'text' => '')); | |
/* | |
Aqui nessa segunda linha seu bot responde de acordo com o que o usuário enviou através do clique no botão. O dado | |
ficar armazenado no parâmetro 'data' do objeto 'callback_query'. | |
*/ | |
sendMessage("sendMessage", array('chat_id' => $update["callback_query"]["from"]["id"], "text" => getResult($update["callback_query"]["data"], $update["callback_query"]["data"]))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment