function processMessage($message) { // process incoming message $message_id = $message['message_id']; $chat_id = $message['chat']['id']; if (isset($message['text'])) { // incoming text message $text = $message['text']; if (strpos($text, "/start") === 0) { apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => 'Hello', 'reply_markup' => array('keyboard' => array(array('Hello', 'Hi')), 'one_time_keyboard' => true, 'resize_keyboard' => true))); } else { if ($text === "Hello" || $text === "Hi") { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => 'Nice to meet you')); } else { if (strpos($text, "/stop") === 0) { // stop now } else { apiRequestWebhook("sendMessage", array('chat_id' => $chat_id, "reply_to_message_id" => $message_id, "text" => 'Cool')); } } } } else { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => 'I understand only text messages')); } }
function sendFindingLocationAction($chat_id) { $parameters = array("chat_id" => $chat_id, "action" => "find_location"); apiRequestJson("sendChatAction", $parameters); }
function processMessage($message) { $message_id = $message['message_id']; $chat_id = $message['chat']['id']; $user_name = $message['from']['first_name']; $msg_comandos = "Olá Campuseiro! Eu sou o @CPBR9_bot. Em que posso ajudar? \n\n"; $msg_comandos .= "/comandos - Exibe os comandos. \n"; $msg_comandos .= "/faq - Informações úteis sobre a #CPBR9. \n"; $msg_comandos .= "/sugestao - Tem alguma sugestão? Fala aí. \n"; $msg_comandos .= "/sobre - Exibe informações sobre mim. \n"; $msg_comandos .= "-----------------------------------------------------------\n"; $msg_comandos .= "GRUPO CPBR9: https://telegram.me/joinchat/Axikcz0uzvbjW9rV-eo78g"; $msg_faq = array(0 => array('pergunta' => 'Nada, deixa pra lá.', 'resposta' => 'Ok, sem problemas.'), array('pergunta' => 'Tenho outras dúvidas, o que eu faço?', 'resposta' => "Bom, você pode.. \n> Perguntar para o pessoal no grupo: https://telegram.me/joinchat/Axikcz0uzvbjW9rV-eo78g\n> Conferir aqui: http://brasil.campus-party.org/como-participar/seja-campuseiro"), array('pergunta' => 'Quanto tempo falta?', 'resposta' => quantotempofalta()), array('pergunta' => 'Sou Novato(a) e queria saber dicas sobre a #CPBR9...', 'resposta' => "Você pode conferir dicas sobre a Campus Party aqui:\nhttp://bit.ly/guiadocampuseirodasgalaxias"), array('pergunta' => 'Quero saber a agenda do evento.', 'resposta' => "http://brasil.campus-party.org/conteudos/agenda")); if (isset($message['text'])) { $text = $message['text']; switch ($text) { case stripos($text, '/start') !== false or stripos($text, '/comandos') !== false: sendMsg($chat_id, $msg_comandos); break; case strpos($text, '/sobre'): $msg_sobre = "Nome: CPBR9 BOT\n\nDesenvolvedor: @jaonoctus\nColaboração: @jppcel\n\nhttps://github.com/JaoNoctus/CPBR9_bot"; apiRequest('sendMessage', array('chat_id' => $chat_id, 'text' => $msg_sobre, 'disable_web_page_preview' => true)); break; case strpos($text, '/sugestao'): if ($text == '/sugestao' or $text == '/sugestao@CPBR9_bot') { $msg_sugestao = "{$user_name}, para enviar uma sugestão para nossos desenvolvedores, digite:\n\n/sugestao [sua mensagem]"; apiRequest('sendMessage', array('chat_id' => $chat_id, 'text' => $msg_sugestao)); } else { $user_username = $message['from']['username']; $text = str_replace('/sugestao', '', $text); $text = str_replace('@CPBR9_bot', '', $text); $msg_sugestao = "Sugestão de @{$user_username}:\n-------------------------------------\n{$text}\n-------------------------------------"; sendMsg(BOT_DEV_1, $msg_sugestao); sendMsg(BOT_DEV_2, $msg_sugestao); } break; case strpos($text, '/faq'): apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'text' => $user_name . ', o que você gostaria de saber sobre a #CPBR9?', 'reply_to_message_id' => $message_id, 'reply_markup' => array('keyboard' => array(array($msg_faq[2]['pergunta'], $msg_faq[4]['pergunta']), array($msg_faq[3]['pergunta']), array($msg_faq[1]['pergunta']), array($msg_faq[0]['pergunta'])), 'one_time_keyboard' => true, 'resize_keyboard' => true, 'selective' => true))); break; case $msg_faq[1]['pergunta']: apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'reply_to_message_id' => $message_id, 'reply_markup' => array('hide_keyboard' => true), 'text' => $msg_faq[1]['resposta'])); break; case $msg_faq[2]['pergunta']: apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'reply_to_message_id' => $message_id, 'reply_markup' => array('hide_keyboard' => true), 'text' => $msg_faq[2]['resposta'])); break; case $msg_faq[4]['pergunta']: apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'reply_to_message_id' => $message_id, 'reply_markup' => array('hide_keyboard' => true), 'text' => $msg_faq[4]['resposta'])); break; case $msg_faq[0]['pergunta']: apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'reply_to_message_id' => $message_id, 'reply_markup' => array('hide_keyboard' => true), 'text' => $msg_faq[0]['resposta'])); break; case $msg_faq[3]['pergunta']: apiRequestJson('sendMessage', array('chat_id' => $chat_id, 'reply_to_message_id' => $message_id, 'reply_markup' => array('hide_keyboard' => true), 'text' => $msg_faq[3]['resposta'])); break; case stripos($text, 'proximo') !== false or stripos($text, 'próximo') !== false: $stickers = array('BQADAQADEAEAAm-8_wKeTmVwt36EGAI'); $keys = array_keys($stickers); shuffle($keys); $random = array_rand($keys); apiRequest('sendSticker', array('chat_id' => $chat_id, 'sticker' => $stickers[$random])); sendMsg($chat_id, "Compre sua camisa da zoeira ou adesivos irados!\nproximooo.com.br"); break; case stripos($text, 'cafe') !== false or stripos($text, 'café') !== false: $stickers = array('BQADAQADigADc6QYA5uQxxPZmMZGAg', 'BQADAQADYQADC1TfAAHnb5n94sar6AI', 'BQADAgADgAADGgZFBBPEOyAbYERuAg', 'BQADAQADVgEAAtpxZgdD4Q1UGK41qgI'); $keys = array_keys($stickers); shuffle($keys); $random = array_rand($keys); apiRequest('sendSticker', array('chat_id' => $chat_id, 'sticker' => $stickers[$random])); break; case stripos($text, 'novato') !== false or stripos($text, 'novata') !== false: sendMsg($chat_id, "Você pode conferir dicas sobre a Campus Party aqui:\nhttp://bit.ly/guiadocampuseirodasgalaxias"); break; case stripos($text, 'bolacha') !== false: sendMsg($chat_id, "É biscoito!"); break; case stripos($text, 'biscoito') !== false: sendMsg($chat_id, "É bolacha!"); break; case stripos($text, 'resumo') !== false: sendMsg($chat_id, "De tempos em tempos o amigo @igor_mi solta resumo aqui: \n http://bit.ly/ResumoGrupoCampuseirosClubTelegram", true); break; case stripos($text, 'ooo') !== false: $gritos = array('OooOOOOOOOoooOoooooo', 'ooooooOOOOOoooOOOOooooo', 'oooooooOOOOOOOOoooooO', 'OooOOOOOOOoooo', 'OoooOoooOoOOO'); $keys = array_keys($gritos); shuffle($keys); $grito = array_rand($keys); apiRequest('sendMessage', array('chat_id' => $chat_id, 'text' => $gritos[$grito])); break; case stripos($text, 'pizza') !== false: $gritos = array('Pizzaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!!', 'PIZZAAAAAAA!', 'Pizzaaaaaaaaaaaaaaaaaaa!!'); $keys = array_keys($gritos); shuffle($keys); $grito = array_rand($keys); apiRequest('sendMessage', array('chat_id' => $chat_id, 'text' => $gritos[$grito])); break; case stripos($text, 'campus b') !== false or stripos($text, 'campusb') !== false: sendMsg($chat_id, "Alguém disse Campus B? 👀🎉🍻 Entre no grupo:\nhttps://telegram.me/joinchat/CRbtOwUf0O3BT8WI86JAfQ"); break; default: // NOTHING /* DEBUG: VIEW STICKER ID if (isset($message['sticker'])) { sendMsg($chat_id, "[DEBUG MODE]\n" . $message['sticker']['file_id']); } */ break; } } }
$message = $update['message']; $message_id = $message['message_id']; $chat_id = $message['chat']['id']; $text = strtolower($message['text']); $from = $message['from']['first_name']; $response = handleText($text, $from); if ($response && !isMuted()) { if (TEST) { echo $response; } else { $aux = explode(':', $response); if (count($aux) === 2 && $aux[0] === 'sticker') { // NO ANDA apiRequestJson("sendSticker", array('chat_id' => $chat_id, 'sticker' => $aux[1])); } else { apiRequestJson("sendMessage", array('chat_id' => $chat_id, 'text' => $response)); } } } } function handleTextWords($words, $from) { $needles = array('%mood%' => array('como', 'te', 'sentis'), '%setmood%' => array('/setmood'), 'forro sos vos hijode putea' => array('oso', 'forro'), 'dale men, hasta yo tengo foto de perfil' => array('belilos', 'foto'), 'yo me re prendo a una hackathon eh' => array('hackathon'), 'belilos es un cagón' => array('belilos'), "❤" => array('tkm'), 'de nada ameo' => array('gracias'), 'viva el mct' => array('mct'), '%hello%' => array('bimbo'), '%song%' => array('cantate'), '%love%' => array('te', 'amo'), 'que te pasa con fargo pelotudo' => array('fargo'), 'https://github.com/servani/bimbot' => array('repo'), '%pija%' => array('pija'), 'vamo a lo de piche a fumar unos' => array('droga'), 'vamo a lo de pichettoooo a fumar unos' => array('porro'), 'denme un ak47 ' => array('faso'), 'estoy re manija vamo a lo de facu a fumanchea' => array('fumar'), 'la que le gusta a tu hermana' => array('marihuana'), '%name%' => array('el', 'mas', 'puto'), 'mmmmmnnnnnnnnnmusaaaraña musaraña musaraña musaraña' => array('musa'), 'que sera que sera de la vida del gran yamid' => array('que', 'sera'), 'el tunel de monroe es una maaaaaasssssssaaa' => array('monroe'), 'ipad? si el que se gano el hijo de puta de belilos' => array('ipad'), 'aguante bluesmart' => array('bluesmart'), 'con esta pelotudo' => array('con', 'que'), 'sabes donde te podes meter el corazoncito?' => array('❤'), 'nada re tranki aca en pija' => array('que', 'pasando'), 'ni bigote ni manco, CRISTINA LOCO PORQUE NESTOR NO SE MURIO LO LLEVO EN EL CORAZON VIVA PERON HIJOS DE PUTA' => array('macri', 'scioli'), 'no soy un oso de mierda, soy un oso barrilete y vendehumo iiiiiiiiiiiiaja' => array('oso', 'mierda')); foreach ($needles as $message => $needle) { if (count(array_intersect($needle, $words)) === count($needle)) { $names = array('beli', 'miola', 'pato', 'guille', 'santi', 'facu', 'fede', 'la musa', 'luigi', 'erni', 'el forro de schattenhofer'); shuffle($names); if ($message === "%name%") { $message = $names[0]; } elseif ($message === "%love%") { $message = 'yo te amo a vos ' . strtolower($from);
Query2DB($query); $output = "Паролю " . file_get_contents("tmp_pass") . " присвоено имя \"" . $input['message'] . "\".\r\n"; break; case 'SetCalendar': $output = ToDoSomething('Scheldure', $input['message']); break; } unlink("promise." . $input['user_id']); } else { $output .= AnalizeMessage($input['message']); } if ($output != null) { AddInJournal($input); } $a = array('chat_id' => $input['chat_id'], 'text' => $output, 'parse_mode' => 'Markdown', 'reply_to_message_id' => $input['message_id'], 'disable_web_page_preview' => null); apiRequestJson("sendMessage", $a); function AnalizeMessage($text) { $output = null; $keywords = array('Greeterings' => array('доброе', 'добрый', 'приве', 'здравств', 'дрям', 'здоров', 'здаров'), 'WorkWithJournal' => array('журнал'), 'Passwords' => array('пароль'), 'MarkKing' => array('#узбек'), 'Amen' => array('гавн', 'говн', 'govn'), 'IntuitLink' => array('курсы', 'изуч'), 'Scheldure' => array('напомни', 'напоминай')); foreach ($keywords as $key => $value) { foreach ($value as $word) { if (mb_stripos($text, $word, 0, "utf-8") !== false) { $output .= ToDoSomething($key, $text); } } } return $output; } function ToDoSomething($keyword, $text) {