Example #1
0
 private function web($endpoint, $request)
 {
     $text = Utils::get_url_web($request);
     return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
 }
Example #2
0
 private function cuantoHaPerdidoRiojas($endpoint, $request, $urlApi)
 {
     $result = Utils::quien_ha_perdido_mas($endpoint, $request, $urlApi);
     $humano = Utils::get_humano_name($request->get_from_id());
     $this->log->debug("Humano: " . $humano . " - " . $request->get_from_id());
     switch ($result) {
         case 0:
             $text = $humano . ', de momento llevas más pasta que el cocacolitas, sigue así';
             return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
             break;
         case 1:
             $insulto = Utils::aleatorio(['Maldito', 'Jodido', 'Estúpido', 'Condenado', 'Retrasado', 'Podemita']);
             $text = $insulto . ' ' . $humano . ', si has perdido más pasta tú ';
             return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
             break;
         case 2:
             $text = 'Pero mira que eres bobo gelete... No sabes ni lo que has perdido. Eres el Pedro Sánchez de las apuestas.';
             return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
             break;
         case 4:
             $text = 'No se ni quién eres, mejor que ni me hables muerto de hambre.';
             return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
             break;
         default:
             $text = 'Ni más ni menos que tú, parguela';
             return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
             break;
     }
 }
Example #3
0
 private function crearApuesta($endpoint, $request, $currentCMD)
 {
     $grupo = $currentCMD['grupo'];
     $grupoDAO = new GrupoDAO();
     $grupoVO = $grupoDAO->select($currentCMD['grupo']);
     $urlApi = $grupoVO->url_api;
     $jsonTokenUser = Utils::callApi($request, 'tokenusuario/' . $request->get_chat_id() . '?token=' . TOKEN_API_BOT, $urlApi);
     $tokenUsuario = json_decode($jsonTokenUser, true);
     //Si hay token de usuario del chat, se invoca el comando con el token
     if ($tokenUsuario[0]['token']) {
         $this->log->debug("Hay token.");
         $idUsuario = $tokenUsuario[0]['id'];
         $apostarCMDDAO = new ApostarCMDDAO();
         $cmd = $apostarCMDDAO->select($request->get_chat_id());
         $data = array("token" => $tokenUsuario[0]['token'], "idpartido" => $cmd['partido'], "idapostante" => $idUsuario, "importe" => $cmd['importe'], "desc" => $cmd['descrip']);
         $data_string = json_encode($data);
         //Esto se podría meter en el utils
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $urlApi . '/apuestas/partido');
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
         curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
         $result = curl_exec($curl);
         $apuesta = json_decode($result);
         if (isset($apuesta->error)) {
             return $apuesta->error->text;
         }
         return null;
     } else {
         $this->log->debug("No hay token");
         $emoji_alert = Utils::convert_emoji(0x26a0);
         $text = $emoji_alert . '*Error:*' . PHP_EOL . 'Se ha producido un error';
         return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
     }
 }
Example #4
0
 private function emitirmensaje($endpoint, $request)
 {
     global $TOKEN;
     $params = $request->get_command_params();
     if (count($params) < 3) {
         $texto = 'Uso /emitirmensaje token destino mensaje';
     } else {
         if ($params[0] != $TOKEN) {
             $texto = 'Token invalido';
         } else {
             $texto = implode(" ", array_slice($params, 2));
             $chat_id = $params[1];
         }
     }
     $chat_id = isset($chat_id) ? $chat_id : $request->get_chat_id();
     return Response::create_text_response($endpoint, $chat_id, $texto);
 }
Example #5
0
 private function españa($endpoint, $request, $insulto)
 {
     $emoji_e = Utils::convert_emoji(0x1f1ea);
     $emoji_s = Utils::convert_emoji(0x1f1f8);
     $text = $emoji_e . $emoji_s;
     return Response::create_text_response($endpoint, $request->get_chat_id(), $text);
 }