if ($type == 'private') { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => "Vamos começar?\nPara que eu possa receber os novos membros em seu grupo, basta me adicionar lá 😄")); } else { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => "Você já me adicionou aqui 😄\nSempre que um novo membro entrar, darei boas vindas a ele.")); } } else { if (stripos($text, "puta")) { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => "Sua mãe que é uma puta! Quer cair na mão? Perdeu a noção do perigo?")); } else { if (stripos($text, "koee") || stripos($text, "falae") || stripos($text, "blz") || stripos($text, "beleza") || stripos($text, "bem")) { apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => "Koee, " . $member_name . "\nBeleza?")); } } } } } define('WEBHOOK_URL', 'SEU LINK AQUI'); if (php_sapi_name() == 'cli') { // if run from console, set or delete webhook apiRequest('setWebhook', array('url' => isset($argv[1]) && $argv[1] == 'delete' ? '' : WEBHOOK_URL)); exit; } $content = file_get_contents("php://input"); $update = json_decode($content, true); if (!$update) { // receive wrong update, must not happen exit; } if (isset($update["message"])) { processMessage($update["message"]); }
$originalUrl = "?since_id=4028479400&q=" . urlencode($search); $baseUrl = "http://search.twitter.com/search"; $firstRun = true; $refreshUrl = $originalUrl; while (1) { $source = file("{$baseUrl}{$refreshUrl}&refresh=true"); if ($source) { $json = json_decode(implode('', $source)); if ($json && isset($json->refresh_url)) { $refreshUrl = $json->refresh_url; if ($firstRun) { $firstRun = false; continue; } foreach ($json->results as $result) { if ($message = processMessage($result->text, $filters, $translateTo)) { print "{$result->from_user}: {$message}\n"; } } } else { // On error, reset to front page and retry $refreshUrl = $originalUrl; } } sleep(30); } function processMessage($string, $filters, $lang) { // Resolve shortened URL's to the full thing for filtering preg_match_all('/http:\\/\\/[^ $)]+/i', $string, $urls); if ($urls) {
$astdb = new AsteriskDB(); $xmpp_client = new JAXL(array('jid' => 'pbx', 'pass' => '123456', 'host' => 'avanpbx:5222')); $xmpp_client->require_xep(array('0199')); $connected = true; $xmpp_client->add_cb('on_auth_failure', function ($reason) { global $xmpp_client; $xmpp_client->send_end_stream(); _info("CALLBACK! got on_auth_failure cb with reason {$reason}"); }); $xmpp_client->add_cb('on_connect_error', function ($reason) { _info("connect error {$reason}"); }); $xmpp_client->add_cb('on_auth_success', function () { _info("connected!!"); global $xmpp_client; $xmpp_client->set_status("available!", "dnd", 10); }); $xmpp_client->add_cb('on_disconnect', function () { _info("disconnected!!"); // _info("reconnecting"); // global $xmpp_client; // $xmpp_client->con(); // global $xmpp_client; // $xmpp_client->set_status("available!", "dnd", 10); }); $xmpp_client->add_cb('on_headline_message', function ($stanza) { global $xmpp_client; // var_dump($stanza); processMessage($stanza); }); $xmpp_client->start(array('--with-unix-sock' => true), $pamiClient);
$recvd = ""; $continue = true; while ($continue) { $size = socket_recv($data_socket, $recvd_a, 1024, 0); $recvd .= $recvd_a; if (preg_match("/.*\\:EOD\$/", $recvd)) { // we have a full string... break out $continue = false; break; } } $xps = explode(":", $recvd); $component = unserialize(base64_decode($xps[1])); $msg_type = $component["type"]; $msg = $component["data"]; $data_returned = processMessage($msg_type, $msg); $d_comp["type"] = $msg_type; $d_comp["data"] = $data_returned; $realdata_returning = "AS:" . base64_encode(serialize($d_comp)) . ":EOD"; socket_send($data_socket, $realdata_returning, strlen($realdata_returning), 0); socket_close($data_socket); } } } } } function processMessage($msg_type, $msg) { global $MESSAGES; $function = $MESSAGES[$msg_type] . "_server"; if (function_exists($function)) {
$file = fopen('backlog.txt', 'a'); $events = array(); logFirstDelivered(); #logOnlineOrder(); logRegistrations(); #logFirstReview(); logReviews(); logDelivered(); $date_array = array(); foreach ($events as $key => $row) { $date_array[$key] = $row['date']; } array_multisort($date_array, SORT_ASC, $events); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); foreach ($events as $event) { processMessage($event['message'], $db); } /** * @param unknown_type $message * @param Db $db * @return void|boolean */ function processMessage($message, $db) { //$message = Tools::jsonDecode('{"id_event":5,"date_event":"2012-03-14 13:07:18","reference":"274","id_customer":"10687"}', true); //$message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $message = Tools::jsonDecode($message, true); $id_event = $message['id_event']; if ($id_event == ONLINE_ORDER) { VBRewards::addRewardPoints($message['id_customer'], $id_event, 0, 100, 'Online payment bonus - Order no ' . $message['reference'], $message['reference'], $message['date_event']); return;
case "NEUTRINO": $profanityCheck = check_for_profanity_neutrinoapi($messageText); break; case "WEBPURIFY": $profanityCheck = check_for_profanity_WebPurify($messageText); break; default: //default turn off profanity check $profanityCheck == false; break; } if (!$profanityCheck) { logEntry("Message: " . $messageText . " PASSED"); // $gv->sendSMS($from,$REPLY_TEXT); $subject = ""; processMessage($from, $messageText); sendResponse($from, $REPLY_TEXT, $from, $subject); sleep(1); } else { $subject = ""; logEntry("message: " . $messageText . " FAILED"); $PROFANITY_REPLY_TEXT = "Your message contains profanity, sorry. More messages like these will ban your phone number"; $subject = ""; sendResponse($from, $PROFANITY_REPLY_TEXT, $from, $subject); sleep(1); } } } /* close the connection */ imap_close($mbox); lockHelper::unlock();
<?php error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); require "lib/config.php"; require "lib/functions.php"; require "lib/message.php"; $content = file_get_contents("php://input"); $update = json_decode($content, true); /*$fh = fopen("log-update.txt", 'a') or die("can't open file"); $stringData = $content.chr(10); fwrite($fh, $stringData); fclose($fh);*/ if (!$update) { // receive wrong update, must not happen exit; } if (isset($update["message"])) { // mensaje recibido, proceso el mensaje processMessage($update["message"], $update); }
require 'config.php'; require 'chatter-bot-api/php/chatterbotapi.php'; $getUpdates = $website . "getUpdates"; $factory = new ChatterBotFactory(); $bot1 = $factory->create(ChatterBotType::CLEVERBOT); $bot1session = $bot1->createSession(); $bot2 = $factory->create(ChatterBotType::CLEVERBOT); $bot2session = $bot2->createSession(); $text = 'Hi.'; while (true) { $result = file_get_contents($getUpdates); $result = json_decode($result, true); $result = $result["result"]; if (isset($result[0])) { foreach ($result as $message) { processMessage($result); $result = file_get_contents($getUpdates); $result = json_decode($result, true); $result = $result["result"]; } } sendMessage($text, 1); checkIfEnglish($text); $text = $bot2session->think($text); sendMessage($text, 2); checkIfEnglish($text); $text = $bot1session->think($text); } function processMessage($result) { global $getUpdates;
<?php require "lib.php"; require $entry_file; if (function_exists("processMessage")) { processMessage(new Message($message_json)); }
<?php define('_PS_ADMIN_DIR_', getcwd()); define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility include PS_ADMIN_DIR . '/../config/config.inc.php'; include PS_ADMIN_DIR . '/functions.php'; $sqs = new AmazonSQS(); $sqs->set_region(AmazonSQS::REGION_APAC_SE1); $db = Db::getInstance(_PS_USE_SQL_SLAVE_); for ($count = 1; $count < 10; $count++) { $response = $sqs->receive_message(INVITE_QUEUE); if (!$response->body->ReceiveMessageResult->Message) { sleep(5); } else { if (processMessage($response, $db)) { } $handle = $response->body->ReceiveMessageResult->Message->ReceiptHandle; $sqs->delete_message(INVITE_QUEUE, $handle); } } /** * @param unknown_type $response * @param Db $db * @return boolean */ function processMessage($response, $db) { echo $response->body->ReceiveMessageResult->Message->Body . PHP_EOL; $message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $id_customer = $message['id_customer'];
$originalUrl = "?since_id=4028479400&q=" . urlencode($search); $baseUrl = "http://search.twitter.com/search"; $firstRun = true; $refreshUrl = $originalUrl; while (1) { $source = file("{$baseUrl}{$refreshUrl}&refresh=true"); if ($source) { $json = json_decode(implode('', $source)); if ($json && isset($json->refresh_url)) { $refreshUrl = $json->refresh_url; if ($firstRun) { $firstRun = false; continue; } foreach ($json->results as $result) { if ($message = processMessage($result->text, $filters, $translateTo, $translationService)) { print "{$result->from_user}: {$message}\n"; } } } else { // On error, reset to front page and retry $refreshUrl = $originalUrl; } } sleep(30); } function processMessage($string, $filters, $lang, $service) { // Resolve shortened URL's to the full thing for filtering preg_match_all('/http:\\/\\/[^ $)]+/i', $string, $urls); if ($urls) {
function processUpdate($json) { global $debug; $debug = False; $update = json_decode($json, true); if (!empty($json)) { if (isset($update['message'])) { processMessage($update['message']); } else { if (isset($update['edited_message'])) { processMessage($update['edited_message']); } else { if (isset($update['callback_query'])) { processCallbakQuery($update['callback_query']); } else { //inline_query or chosen_inline_result logData($update, False); } } } } else { exit; } }
<?php include 'functions.php'; include 'mongodbHelper.php'; include 'config.php'; include 'configapikey.php'; $content = file_get_contents("php://input"); $update = json_decode($content, true); $mongodbHelper = new mongodbHelper(); if (!$update) { // receive wrong update, must not happen exit; } if (isset($update["message"])) { processMessage($update["message"], $mongodbHelper); }