Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.37 KB | None | 0 0
  1. <?php
  2. #if (!file_exists("quote.php")) { die("File missing. Find it!"); }
  3. include("quote.php");
  4. ## Set by the owner.
  5. $name = 'Machinedramon'; # The nick.
  6. $pass = 'dfsrevenge';    # The nick's pass.
  7. $join = '#1';            # Join on connect.
  8. $prefix = '>';           # Command prefix.
  9. $server = "irc.squaddiversity.com"; #Server to connect to.
  10. $port = 6667;            # The server's port to use.
  11. $version = "v0.0.2";     # The Version of the bot.
  12. $master = ":Alias!is@not.known";# The master is who?
  13.  
  14.  
  15.  
  16.  
  17. global $socket;
  18. set_time_limit(0);
  19.  
  20. $socket = fsockopen($server,$port);
  21. $x = 1;
  22.  
  23.  
  24. #:irc.codealife.com 353 Machinedramon = #1 :@rapacity ~Alias +Brenden +XTV-Info %
  25. #Andrew[Away] %Google +Sneaky +_ashLeyrhodeS_ &Rose +Neo|Desktop +Brenden|iPod +L
  26. #iquid- +Sbot +tiger45 Machinedramon +Sy
  27.  
  28.  
  29. fputs($socket,"USER VirusType Digimon DigitalMonsters DarkMaster\n");
  30. fputs($socket,"NICK $name\n");
  31.  
  32. sleep(1);
  33. fwrite($socket,"privmsg nickserv :identify $pass\n");
  34. sleep(1);
  35. fwrite($socket,"privmsg hostserv :on\n");
  36.  
  37. sleep(1);
  38. fwrite($socket, "JOIN $join\n");
  39.  
  40. sleep(1);
  41. msg("$join","Prepare to die!\n");
  42.  
  43.  
  44. while(1)
  45. {
  46.     while ($data = fgets($socket, 254))
  47.     {
  48.         flush();
  49.         $ex = explode(' ', $data);
  50.        
  51.         // Send PONG back to the server
  52.         if($ex[0] == "PING"){
  53.             fputs($socket, "PONG :".$ex[1]."\n");
  54.         }
  55.         $user = explode('!', $ex[0]);
  56.         $user = $user[0];
  57.         $user = str_replace(":", "", $user);
  58.    
  59.         #echo nl2br($data);
  60.         echo $data;
  61.         #echo  $ex[2].'> '.$ex[0].'> '.exall(3);
  62.         if (isset($ex[2])) { $IRCChannel = $ex[2]; }
  63.         if (isset($ex[3])) {  $command = str_replace(array(chr(10), chr(13)), '', $ex[3]); }
  64.         if (isset($ex[4])) { $command2 = str_replace(array(chr(10), chr(13)), '', $ex[4]); }
  65. null;
  66.  
  67.  
  68.  
  69. #:irc.codealife.com 353 Machinedramon = #1 :@rapacity ~Alias +Brenden +XTV-Info %
  70. #Andrew[Away] %Google +Sneaky +_ashLeyrhodeS_ &Rose +Neo|Desktop +Brenden|iPod +L
  71. #iquid- +Sbot +tiger45 Machinedramon +Sy
  72.  
  73. if (($ex[0] == ":$server") && ($ex[1] == 353) && ($ex[2] == "$name"))
  74. {
  75. nick(5,$ex[4]);
  76. }
  77.  
  78.  
  79.         ##########
  80.         #
  81.         # Command listings.
  82.         #
  83.         if ((strcasecmp($command,":die") == 0) && ($ex[0] == $master))
  84.         {
  85.             msg($IRCChannel,"yes Sir, right away Sir!");
  86.             fputs($socket,"QUIT :This good Sir?\n");
  87.             die();
  88.         }
  89.         # :?VERSION?
  90.         if (strcasecmp($command,":".$prefix."act") == 0)
  91.         {
  92.             act($IRCChannel,exall(4));
  93.         }
  94.         if (strcasecmp($command,":".$prefix."say") == 0)
  95.         {
  96.             msg($IRCChannel,exall(4));
  97.         }
  98.         if (strcasecmp($command,":".$prefix."info") == 0)
  99.         {
  100.             msg($IRCChannel,"I have these commands: act say var quote");
  101.             msg($IRCChannel,"My command prefix is: '$prefix'");
  102.         }
  103.         if (strcasecmp($command,":".$prefix."var") == 0)
  104.         {
  105.             if (isset($ex[4])) { $varcommand = exall(4); }
  106.             msg($IRCChannel,"var is now ".$varcommand);
  107.         }
  108.         if ((strcasecmp($command,":".$prefix."join") == 0) && ($ex[0] == $master))
  109.         {
  110.             fputs($socket,"JOIN $command2\n");
  111.         }
  112.         if ((strcasecmp($command,":".$prefix."part") == 0) && ($ex[0] == $master))
  113.         {
  114.             fputs($socket,"PART $command2\n");
  115.         }
  116.         if ((strcasecmp($command,":".$prefix."notice") == 0) && ($ex[0] == $master))
  117.         {
  118.             msg($IRCChannel,exall(4));
  119.         }
  120.         if ((strcasecmp($command,":".$prefix."nick") == 0) && ($ex[0] == $master))
  121.         {
  122.             fputs($socket,"nick ".$command2." \n");
  123.             sleep(1);
  124.             fwrite($socket,"privmsg nickserv :identify $pass\n");
  125.         }
  126.         if (strcasecmp($command,":".$prefix."quote") == 0)
  127.         {
  128.             $quoteNumber = (int) rand(0, count($Quote));
  129.             $selectedQuote = $Quote[$quoteNumber];
  130.             msg($IRCChannel,$selectedQuote);
  131.         }
  132.         #(preg_match("/:\001VERSION\001/i",$command))
  133.         if (strcasecmp($command,":\001VERSION\001") == 0)
  134.         {
  135.             ctcp($user,"\001VERSION Machinedra $version (php)\001");
  136.         }
  137.         if (preg_match("/:\001TIME\001/i",$command))
  138.         {
  139.             ctcp($user,"\001TIME ".date("l F d H:i:s Y")."\001");
  140.         }
  141.         # mktime()
  142.         if (preg_match("/:\001PING/i",$command))
  143.         {
  144.             ctcp($user,"\001PING ".mktime()."\001"); # make the mktime $command2 later! ok?
  145.         }
  146.         if (preg_match("/:rawr/i",$command))
  147.         {
  148.             msg($IRCChannel,$command);
  149.         }
  150. NULL;
  151.         if (strcasecmp($command,":".$prefix."nicks") == 0)
  152.         {
  153.             if (isset($ex[4]))
  154.             {
  155.                 if (in_array($ex[4],$nicks))
  156.                 {
  157.                     msg($IRCChannel,'Yes');
  158.                 }
  159.                 else
  160.                 {
  161.                     msg($IRCChannel,'no');
  162.                 }
  163.             }
  164.             else
  165.             {
  166.                 msg($IRCChannel,'who?');
  167.             }
  168.         }
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.         #####
  177.         #
  178.         # Truth or dare scriptlets.
  179.         #
  180.         if (strcasecmp($command,":".$prefix."td") == 0)
  181.         {
  182.             if (isset($truth[$IRCChannel]['Status']))
  183.             {
  184.                 if ($truth[$IRCChannel]['Status'] == 0)
  185.                 {
  186.                     $truth[$IRCChannel]['Status'] = 1;
  187.                     msg($IRCChannel,"Truth or dare is now on.");
  188.                 }
  189.                 else
  190.                 {
  191.                     msg ($IRCChannel,'There is already a game of Truth or Dare for this channel.');
  192.                 }
  193.             }
  194.             else
  195.             {
  196.                 $truth[$IRCChannel]['Status'] = 1;
  197.                 msg($IRCChannel,"Truth or dare is now on.");
  198.             }
  199.         }
  200.         if (strcasecmp($command,":".$prefix."td-") == 0)
  201.         {
  202.             if (isset($truth[$IRCChannel]['Status']))
  203.             {
  204.                 if ($truth[$IRCChannel]['Status'] == 1)
  205.                 {
  206.                     $truth[$IRCChannel]['Status'] = 0;
  207.                     msg($IRCChannel,"Truth or dare is now off.");
  208.                 }
  209.                 else
  210.                 {
  211.                     msg ($IRCChannel,'There is no longer a game of Truth or Dare for this channel.');
  212.                 }
  213.             }
  214.             else
  215.             {
  216.                 $truth[$IRCChannel]['Status'] = 0;
  217.                 msg($IRCChannel,"Truth or dare is now off.");
  218.             }
  219.         }
  220.     }
  221.     sleep(2);
  222. }
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236. ##########
  237. #
  238. # Functions.
  239. #
  240. function ctcp($user,$ctcp)
  241. {
  242.     global $socket;
  243.     fputs($socket,"notice $user :".$ctcp."\n");
  244. }
  245. function msg($channel,$message)
  246. {
  247.     global $socket;
  248.     fputs($socket,"privmsg " . $channel . " :" . $message . " \n");
  249. }
  250. function not ($channel,$message)
  251. {
  252.     global $socket;
  253.     fputs($socket,"notice " . $channel . " :" . $message . " \n");
  254. }
  255. function act($channel,$message)
  256. {
  257.     global $socket;
  258.     fputs($socket,"privmsg " . $channel . " :\001ACTION " . $message . " \n");
  259. }
  260. # :?ACTION
  261. function fixStr($string, $min='', $max='')
  262. {
  263.   $string = preg_replace("/[^a-zA-Z0-9_ -]/", "", $string);
  264.   return $string;
  265. }
  266. function exall ($a)
  267. {
  268.     global $ex;
  269.     $return = '';
  270.     while (isset($ex[$a]))
  271.     {
  272.         $return .= ' '.$ex[$a];
  273.         ++$a;
  274.     }
  275.     return $return;
  276. }
  277. function nick ($a,$b)
  278. {
  279.     global $ex; global $nicks;
  280.     $count = 1;
  281.     while (isset($ex[$a]))
  282.     {
  283.         $nicks[$count] = str_replace(array("~","@","&","+","%",":"), "", $ex[$a]);
  284.         ++$a; ++$count;
  285.     }
  286. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement