Esempio n. 1
0
 function location_manager_inline($inline_query, $telegram, $data)
 {
     $data = new getdata();
     $trovate = 0;
     $res = [];
     $id = "";
     $i = 0;
     $idx = [];
     $distanza = [];
     $id3 = "";
     $id1 = "";
     $inline = "";
     $id = $inline_query['id'];
     $lat = $inline_query["location"]['latitude'];
     $lon = $inline_query["location"]['longitude'];
     $nome = $data->get_stations($lat, $lon);
     $option1 = explode("\n", $nome);
     if ($nome == "Non ci sono stazioni") {
         //  $content = array('chat_id' => $chat_id, 'text' => $nome,'disable_web_page_preview'=>true);
         $id3 = $telegram->InlineQueryResultLocation($id . "/0", $lat, $lon, "Nessuna stazione in questo luogo\nNo Rail Station around you in this place");
         $res = array($id3);
         $content = array('inline_query_id' => $inline_query['id'], 'results' => json_encode($res));
         $telegram->answerInlineQuery($content);
         $this->create_keyboard($telegram, $chat_id);
         exit;
     } else {
         //    $content = array('chat_id' => 69668132,'text' => json_encode($inline_query["location"]));
         //     $telegram->sendMessage($content);
         //  $option = array($option1);
         //  $optionf=array([]);
         for ($i = 0; $i < count($option1) - 1; $i++) {
             //    array_push($optionf,[" ".$option1[$i]]);
             //    $location =preg_replace('/\s+?(\S+)?$/', '', substr(trim($option1[$i]), 0, 45));
             $idx[$i] = $telegram->InlineQueryResultArticle($id . "/" . $i, $option1[$i], array('message_text' => $option1[$i], 'disable_web_page_preview' => true), "http://www.piersoft.it/transportchbot/bus.png");
             array_push($res, $idx[$i]);
         }
         $content = array('inline_query_id' => $inline_query['id'], 'results' => json_encode($res));
         $telegram->answerInlineQuery($content);
     }
 }