Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- coded by rieqyns13
- thanks to all devilzc0de members
- */
- set_time_limit(0);
- class rieqyns13{
- public $consumer_key;
- public $consumer_secret;
- public $access_token;
- public $access_token_secret;
- public $simi_type;
- public $file_id;
- public $file_log;
- public $delay;
- public $fls_komen;
- public $post_waktu;
- private $user_sender;
- private $user_mention;
- function oauth(){
- require_once("twitteroauth.php");
- $con = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret);
- return $con;
- }
- function tweet(){
- $con = $this->oauth();
- $data = $con->get("statuses/mentions_timeline");
- return $data;
- }
- function tweet2(){
- $con = $this->oauth();
- foreach($this->tweet() as $twit){
- if($this->cekId($twit->id_str)==true){
- $user_mention = explode(" ", $twit->entities->user_mentions[0]->name);
- $this->user_mention = $user_mention[0];
- $user_sender = explode(" ", $twit->user->name);
- $this->user_sender = $user_sender[0];
- if($this->post_waktu==true) $waktu = $this->waktu();
- else $waktu = null;
- if($this->simi_type==true) $data = "@".$twit->user->screen_name." ".$this->simsimi($twit->text).$waktu;
- else{
- if(preg_match("/@nama_depan/is", $this->fls_komen)) $msg = str_ireplace("@nama_depan", $this->user_sender, $this->fls_komen);
- else $msg = $this->fls_komen;
- if(preg_match("/@nama_saya/is", $msg)) $msg = str_ireplace("@nama_saya", $this->user_mention, $msg);
- else $msg = $msg;
- $data = "@".$twit->user->screen_name." ".$msg.$waktu;
- }
- echo "[+]Menangkap mention dari @".$twit->user->screen_name.": ".$twit->text."\n";
- echo "[+]Mencoba membalas: ";
- $post = $con->post("statuses/update", array("status" => $data, "in_reply_to_status_id" => $twit->id_str));
- if(!empty($post->text)){
- $status = "Sukes -> ".$post->text."\n";
- echo $status;
- $this->simpan($this->file_log, $status);
- $this->simpan($this->file_id, $twit->id_str."\n");
- }elseif(!empty($post->errors[0]->message)){
- $status = "Gagal -> ".$post->errors[0]->message."\n";
- echo $status;
- $this->simpan($this->file_log, $status);
- }
- }else{
- continue;
- }
- }
- }
- function waktu(){
- if(function_exists('date_default_timezone_set')) date_default_timezone_set("Asia/Jakarta");
- $hari=date('w');
- $tgl =date('d');
- $bln =date('m');
- $thn =date('Y');
- $jam =date("H:i:s");
- switch($hari){
- case 0 : {$hari='Minggu';}break;
- case 1 : {$hari='Senin';}break;
- case 2 : {$hari='Selasa';}break;
- case 3 : {$hari='Rabu';}break;
- case 4 : {$hari='Kamis';}break;
- case 5 : {$hari="Jum'at";}break;
- case 6 : {$hari='Sabtu';}break;
- default: {$hari='UnKnown';}break;
- }
- switch($bln){
- case 1 : {$bln='Januari';}break;
- case 2 : {$bln='Februari';}break;
- case 3 : {$bln='Maret';}break;
- case 4 : {$bln='April';}break;
- case 5 : {$bln='Mei';}break;
- case 6 : {$bln="Juni";}break;
- case 7 : {$bln='Juli';}break;
- case 8 : {$bln='Agustus';}break;
- case 9 : {$bln='September';}break;
- case 10 : {$bln='Oktober';}break;
- case 11 : {$bln='November';}break;
- case 12 : {$bln='Desember';}break;
- default: {$bln='UnKnown';}break;
- }
- $waktu = "\n[".$hari.", ".$tgl." ".$bln." ".$thn." ".$jam."]";
- return $waktu;
- }
- function simsimi($str){
- $header = array("Host: www.simsimi.com",
- "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0",
- "Accept: application/json, text/javascript, */*; q=0.01",
- "Accept-Language: id,en-us;q=0.7,en;q=0.3",
- "Accept-Encoding: gzip, deflate",
- "Content-Type: application/json; charset=utf-8",
- "X-Requested-With: XMLHttpRequest",
- "Referer: http://www.simsimi.com/talk.htm",
- "Cookie: JSESSIONID=F24E259994B7E921A09EB02C5EEC8F89; Path=/; HttpOnly",
- "Connection: keep-alive",
- "HTTP/1.1 200 OK");
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://www.simsimi.com/func/req?msg=".urlencode($str)."&lc=id&sagree=true");
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $exec = curl_exec($ch);
- curl_close($ch);
- $dec = json_decode($exec, true);
- if(empty($dec)){
- $simi = "apa itu kak ? ane gak pernah denger #botmaho";
- return $simi;
- }else{
- if(!empty($dec['response'])){
- $dat = $dec['response'];
- if(preg_match("/is tired/is", $dat)){
- if(preg_match("/@nama_depan/is", $this->fls_komen)) $msg = str_ireplace("@nama_depan", $this->user_sender, $this->fls_komen);
- else $msg = $this->fls_komen;
- if(preg_match("/@nama_saya/is", $msg)) $msg = str_ireplace("@nama_saya", $this->user_mention, $msg);
- else $msg = $msg;
- $simi = $msg;
- }
- else $simi=$dat;
- }else return "gak ada infomasi :P #botmaho";
- $preg = preg_replace("/simsimi|simi|.simi|sim/is", "ane", $simi);
- return $preg;
- }
- }
- function simpan($file, $data){
- $fp = fopen($file, "a");
- fwrite($fp, $data);
- fclose($fp);
- }
- function cekId($id){
- if(!file_exists($this->file_id)){
- $this->simpan($this->file_id, "");
- }
- if(file_exists($this->file_id)){
- $file = file($this->file_id);
- $file = str_replace(array("\n", "\r", "\r\n"), "", $file);
- $file = array_unique($file);
- if(in_array($id, $file)==true){
- return false;
- }else{
- return true;
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment