momodrock

autoreply

Oct 21st, 2013
7,926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.56 KB | None | 0 0
  1. <?php
  2. /*
  3. coded by rieqyns13
  4. thanks to all devilzc0de members
  5. */
  6. set_time_limit(0);
  7. class rieqyns13{
  8. public $consumer_key;
  9. public $consumer_secret;
  10. public $access_token;
  11. public $access_token_secret;
  12. public $simi_type;
  13. public $file_id;
  14. public $file_log;
  15. public $delay;
  16. public $fls_komen;
  17. public $post_waktu;
  18. private $user_sender;
  19. private $user_mention;
  20. function oauth(){
  21. require_once("twitteroauth.php");
  22. $con = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $this->access_token, $this->access_token_secret);
  23. return $con;
  24. }
  25. function tweet(){
  26. $con = $this->oauth();
  27. $data = $con->get("statuses/mentions_timeline");
  28. return $data;
  29. }
  30. function tweet2(){
  31. $con = $this->oauth();
  32. foreach($this->tweet() as $twit){
  33. if($this->cekId($twit->id_str)==true){
  34. $user_mention = explode(" ", $twit->entities->user_mentions[0]->name);
  35. $this->user_mention = $user_mention[0];
  36. $user_sender = explode(" ", $twit->user->name);
  37. $this->user_sender = $user_sender[0];
  38.  
  39. if($this->post_waktu==true) $waktu = $this->waktu();
  40. else $waktu = null;
  41. if($this->simi_type==true) $data = "@".$twit->user->screen_name." ".$this->simsimi($twit->text).$waktu;
  42. else{
  43. if(preg_match("/@nama_depan/is", $this->fls_komen)) $msg = str_ireplace("@nama_depan", $this->user_sender, $this->fls_komen);
  44. else $msg = $this->fls_komen;
  45. if(preg_match("/@nama_saya/is", $msg)) $msg = str_ireplace("@nama_saya", $this->user_mention, $msg);
  46. else $msg = $msg;
  47. $data = "@".$twit->user->screen_name." ".$msg.$waktu;
  48. }
  49. echo "[+]Menangkap mention dari @".$twit->user->screen_name.": ".$twit->text."\n";
  50. echo "[+]Mencoba membalas: ";
  51. $post = $con->post("statuses/update", array("status" => $data, "in_reply_to_status_id" => $twit->id_str));
  52. if(!empty($post->text)){
  53. $status = "Sukes -> ".$post->text."\n";
  54. echo $status;
  55. $this->simpan($this->file_log, $status);
  56. $this->simpan($this->file_id, $twit->id_str."\n");
  57. }elseif(!empty($post->errors[0]->message)){
  58. $status = "Gagal -> ".$post->errors[0]->message."\n";
  59. echo $status;
  60. $this->simpan($this->file_log, $status);
  61. }
  62. }else{
  63. continue;
  64. }
  65. }
  66. }
  67. function waktu(){
  68. if(function_exists('date_default_timezone_set')) date_default_timezone_set("Asia/Jakarta");
  69. $hari=date('w');
  70. $tgl =date('d');
  71. $bln =date('m');
  72. $thn =date('Y');
  73. $jam =date("H:i:s");
  74. switch($hari){
  75. case 0 : {$hari='Minggu';}break;
  76. case 1 : {$hari='Senin';}break;
  77. case 2 : {$hari='Selasa';}break;
  78. case 3 : {$hari='Rabu';}break;
  79. case 4 : {$hari='Kamis';}break;
  80. case 5 : {$hari="Jum'at";}break;
  81. case 6 : {$hari='Sabtu';}break;
  82. default: {$hari='UnKnown';}break;
  83. }
  84. switch($bln){
  85. case 1 : {$bln='Januari';}break;
  86. case 2 : {$bln='Februari';}break;
  87. case 3 : {$bln='Maret';}break;
  88. case 4 : {$bln='April';}break;
  89. case 5 : {$bln='Mei';}break;
  90. case 6 : {$bln="Juni";}break;
  91. case 7 : {$bln='Juli';}break;
  92. case 8 : {$bln='Agustus';}break;
  93. case 9 : {$bln='September';}break;
  94. case 10 : {$bln='Oktober';}break;
  95. case 11 : {$bln='November';}break;
  96. case 12 : {$bln='Desember';}break;
  97. default: {$bln='UnKnown';}break;
  98. }
  99. $waktu = "\n[".$hari.", ".$tgl." ".$bln." ".$thn." ".$jam."]";
  100. return $waktu;
  101.  
  102. }
  103. function simsimi($str){
  104. $header = array("Host: www.simsimi.com",
  105. "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0",
  106. "Accept: application/json, text/javascript, */*; q=0.01",
  107. "Accept-Language: id,en-us;q=0.7,en;q=0.3",
  108. "Accept-Encoding: gzip, deflate",
  109. "Content-Type: application/json; charset=utf-8",
  110. "X-Requested-With: XMLHttpRequest",
  111. "Referer: http://www.simsimi.com/talk.htm",
  112. "Cookie: JSESSIONID=F24E259994B7E921A09EB02C5EEC8F89; Path=/; HttpOnly",
  113. "Connection: keep-alive",
  114. "HTTP/1.1 200 OK");
  115. $ch = curl_init();
  116. curl_setopt($ch, CURLOPT_URL, "http://www.simsimi.com/func/req?msg=".urlencode($str)."&lc=id&sagree=true");
  117. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  118. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  119. $exec = curl_exec($ch);
  120. curl_close($ch);
  121. $dec = json_decode($exec, true);
  122. if(empty($dec)){
  123. $simi = "apa itu kak ? ane gak pernah denger #botmaho";
  124. return $simi;
  125. }else{
  126. if(!empty($dec['response'])){
  127. $dat = $dec['response'];
  128. if(preg_match("/is tired/is", $dat)){
  129. if(preg_match("/@nama_depan/is", $this->fls_komen)) $msg = str_ireplace("@nama_depan", $this->user_sender, $this->fls_komen);
  130. else $msg = $this->fls_komen;
  131. if(preg_match("/@nama_saya/is", $msg)) $msg = str_ireplace("@nama_saya", $this->user_mention, $msg);
  132. else $msg = $msg;
  133. $simi = $msg;
  134. }
  135. else $simi=$dat;
  136. }else return "gak ada infomasi :P #botmaho";
  137. $preg = preg_replace("/simsimi|simi|.simi|sim/is", "ane", $simi);
  138. return $preg;
  139. }
  140. }
  141. function simpan($file, $data){
  142. $fp = fopen($file, "a");
  143. fwrite($fp, $data);
  144. fclose($fp);
  145. }
  146. function cekId($id){
  147. if(!file_exists($this->file_id)){
  148. $this->simpan($this->file_id, "");
  149. }
  150. if(file_exists($this->file_id)){
  151. $file = file($this->file_id);
  152. $file = str_replace(array("\n", "\r", "\r\n"), "", $file);
  153. $file = array_unique($file);
  154. if(in_array($id, $file)==true){
  155. return false;
  156. }else{
  157. return true;
  158. }
  159. }
  160. }
  161. }
  162. ?>
Advertisement
Add Comment
Please, Sign In to add comment