Guest User

Untitled

a guest
Mar 12th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.36 KB | None | 0 0
  1. <?php
  2.  
  3. ##############################
  4. ## BotNick IRC Bot PHP-Beta ##
  5. ##### Created by Dead-i ######
  6. ##############################
  7.  
  8. // Set no time limit; run forever
  9. set_time_limit(0);
  10.  
  11. // Get the start date incase of status
  12.  
  13. command
  14. $startseconds = time();
  15.  
  16. // Opening the socket to the freenode network
  17. $socket = fsockopen("irc.x10hosting.com", 6667);
  18.  
  19. // Send auth info
  20. fputs($socket,"USER BotNick tomtiger11 CM :BotNick\n");
  21. fputs($socket,"NICK
  22.  
  23. BotNick\n");
  24. fputs($socket,"NS IDENTIFY forkingninja2011\n");
  25.  
  26. // Join channelfputs($socket,"JOIN #paidhosting\n");
  27. fputs($socket,"JOIN #phstaff phstaff1\n");
  28. // Get the admin files
  29. $adminfile = file_get_contents('./admins.txt');
  30. $hostmasks = file_get_contents('./hostmasks.txt');$staffpass = 'botnickpass';
  31. mysql_connect('localhost', 'deadi_bots', 'phstaff1');
  32.  
  33. mysql_select_db('deadi_bots');
  34.  
  35. // Force an endless while
  36. while(1) {
  37.  
  38.  
  39.  
  40.     // Continue the rest of the script here
  41.     while($data = fgets($socket, 522)) {
  42.        
  43.         if ($argv[1] == 'debug') {
  44.             echo nl2br($data);
  45.         }
  46.         flush();
  47.  
  48.        
  49.  
  50. // Separate all data
  51.         $ex = explode(' ', $data);
  52.  
  53.         // Send PONG back to the server
  54.         if($ex[0] == "PING"){
  55.             fputs($socket, "PONG ".$ex[1]."\n");
  56.         }
  57.        
  58.         // Say something in the channel
  59.         $command = str_replace(array(chr(10), chr(13)), '', $ex[4]);
  60.        
  61.         // Get the value if any
  62.         $value = str_replace(array
  63.  
  64. (chr(10), chr(13)), '', $ex[5]);
  65.         if ($value == '@') $value = '';
  66.        
  67.         // Get the second value if any
  68.         $value2 = str_replace(array(chr(10), chr(13)), '', $ex[6]);
  69.        
  70.  
  71. $value2exploderand = explode($value2[0], '1234567890');
  72.         if (!isset($value2exploderand[1])) $value2 = '';
  73.        
  74.         // Explode the command; useful in many purposes
  75.         $explode =
  76.  
  77. explode(' ', $command);
  78.        
  79.         // Get the user's name; useful in many purposes
  80.         $userinfo = explode("!", $ex[0]);
  81.  
  82.  
  83.        
  84.         // Detect if the message was directed toward someone
  85.         $directionexplode = explode(' @ ', $data);
  86.         if (!isset($directionexplode[1])) {
  87.            
  88.  
  89. $recipient = $userinfo[0];
  90.         }else{
  91.             $recipient = ":".substr($directionexplode[1], 0, -2);
  92.         }
  93.  
  94.  
  95. // Auto-voice anyone joining #paidhosting
  96. if ($ex[1] == 'JOIN') {
  97. fputs($socket, "MODE #phstaff +v ".substr($userinfo[0], 1)."\n");
  98. If ($userinfo == ':BotNick') {
  99. mysql_query("UPDATE bots SET online='yes' WHERE title='BotNick';");
  100. }
  101.  
  102. If ($userinfo == 'DeadBot') {
  103. mysql_query("UPDATE bots SET online='yes' WHERE title='DeadBot';");
  104. }
  105. If ($userinfo == ':Delilah') {
  106. mysql_query("UPDATE bots SET online='yes' WHERE title='Delilah';");
  107. }
  108.      }
  109.  
  110.  
  111. If ($ex[1] == 'PART') {
  112. If ($userinfo == ':BotNick') {
  113. mysql_query("UPDATE bots SET online='no' WHERE title='BotNick';");
  114. }
  115. If ($userinfo == ':DeadBot') {
  116. mysql_query("UPDATE bots SET online='no' WHERE title='DeadBot';");
  117. }
  118. If ($userinfo == ':Delilah')
  119. mysql_query("UPDATE bots SET online='no' WHERE title='Delilah';");
  120. }
  121.     }
  122.        
  123.         // Detect if message is private
  124.         if ($ex[2] == 'botnick') {
  125.             $ex[2] = substr(strtolower($recipient), 1);
  126.         }
  127.        
  128.        
  129.  
  130. // Hostmask detection
  131.         $hostmask = explode('!', $data);
  132.         $hostmask = explode('@', $hostmask[1]);
  133.         $hostmask = explode(' ', $hostmask[1]);
  134.         $hostmask = $hostmask
  135.  
  136. [0];
  137.        
  138.         // Admin detection
  139.         $adminarray = explode(substr($userinfo[0], 1), $adminfile);
  140.         $hostsarray = explode($hostmask, $hostmasks);
  141.         if (isset
  142.  
  143. ($adminarray[1]) && isset($hostsarray[1])) {
  144.             $admin = 1;
  145.         }else{
  146.             $admin = 0;
  147.         }
  148.        
  149.         /*if (isset($this->$user) && $userinfo
  150.  
  151. [0] == ':NickServ') {
  152.             $adminstatus = explode('STATUS '.$this->$user.' ', $data);
  153.             $adminstatus = $adminstatus[1];
  154.             $adminstatus = $adminstatus[0];
  155.            
  156.  
  157. if ($adminstatus == '3') {
  158.                 $admin = 1;
  159.                 $this->$user = NULL;
  160.             }else{
  161.                 $admin = 0;
  162.            
  163.  
  164. }
  165.         }*/
  166.        
  167.         // Get the entire command
  168.         $entirecommandraw = explode(' :', $data);
  169.         $entirecommandraw = $entirecommandraw[1];
  170.        
  171.  
  172. $entirecommandraw = substr($entirecommandraw, 0, -2);
  173.        
  174.         // Get the start message for each command
  175.         $startmsg = "PRIVMSG ".$ex[2]." ".$recipient.":";
  176.  
  177.         // If the bot was
  178.  
  179. directed at
  180.         $direct = str_replace(array(chr(10), chr(13)), '', $ex[3]);
  181.         $direct = strtolower($direct);
  182.         if ($direct == ':botnick') {
  183.            
  184.             // Attempt to
  185.  
  186. detect excess flooding
  187.                                 // Attempt to detect excess flooding
  188. $current = date('ymdHis');
  189. if (($current - $lastmsg) > 2 && $abuser != $userinfo[0]) {
  190. // Get the commands
  191. if(strtolower($userinfo[0]) != ':zachary') {
  192. If ($hostmasks != '*windstream.net') { include 'cmd.php'; }
  193. }
  194. // End of flooding detection
  195. }
  196. $lastmsg = date('ymdHis');
  197. $abuser = $userinfo[0];
  198.            
  199.         }
  200.  
  201.        
  202.         // Get the sayings
  203.         include 'sayings.php';
  204.        
  205.         // Admin echo command
  206.         if ($admin == 1) {
  207.    
  208.  
  209.         $content = explode('echo ', $data);
  210.             $content = $content[1];
  211.             if ($ex[3] == ':echo') {
  212.                 if ($ex[2] != '#paidhosting') {
  213.            
  214.  
  215.         fputs($socket, "PRIVMSG #paidhosting :".$content."\n");
  216.                 }
  217.             }
  218.         }
  219.        
  220.         // Admin raw command
  221.        
  222.  
  223. if ($admin == 1) {
  224.             $content = explode('raw ', $data);
  225.             $content = $content[1];
  226.             if ($ex[3] == ':raw') {
  227.                 if ($ex[2] != '#tomtiger11') {
  228.    
  229.  
  230.                 fputs($socket, $content."\n");
  231.                 }
  232.             }
  233.         }
  234.        
  235.         // If BotNick is kicked
  236.        
  237.  
  238. $kick = explode('KICK', $data);
  239.         if (isset($kick[1])) {
  240.             $kickedby = explode('!', $data);
  241.             fputs($socket,"JOIN #paidhosting\n");
  242.         }
  243.        
  244.     }
  245.  
  246. }
  247. ?>
Add Comment
Please, Sign In to add comment