Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Anonymous
Saturday, June 10th, 2006 at 3:00:46pm MDT 

  1. <?php
  2. include_once('SmartIRC.php');
  3.  
  4. class mybot
  5. {
  6.         function help(&$irc, &$data) {
  7.                 $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, 'No help is available at this time.');
  8.         }
  9.  
  10.         function whoareyou(&$irc, &$data) {
  11.                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'All is well.');
  12.         }
  13.    
  14.         function master(&$irc, &$data) {
  15.                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Master created me.');
  16.         }
  17.        
  18.         function join(&$irc, &$data) {
  19.                 //need the channel
  20.                 if (isset($data->messageex[1])) {
  21.                         $channel = $data->channel;
  22.                         $irc->join($channel);
  23.                 } else {
  24.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'No valid channel has been specified.');
  25.                 }
  26.         }
  27.  
  28.         function kick(&$irc, &$data) {
  29.                 // we need the nickname parameter
  30.                 if(isset($data->messageex[1])) {
  31.                         $nickname = $data->messageex[1];
  32.                         $channel = $data->channel;
  33.                         $irc->kick($channel, $nickname);
  34.                 } else {
  35.                         $irc->message( $data->type, $data->nick, 'Wrong.' );
  36.                         $irc->message( $data->type, $data->nick, 'usage: !kick $nickname' );
  37.                 }
  38.         }
  39.  
  40.         function tell(&$irc, &$data) {
  41.                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->nick.' said "'.$data->message.'" to you!');
  42.                 $irc->message(SMARTIRC_TYPE_QUERY, $data->nick, 'I told everyone on #GWing what you said!');
  43.         }
  44.  
  45.         function onjoin_greeting(&$irc, &$data) {
  46.                 // if _we_ join, don't greet ourself, just jump out via return
  47.                 if ($data->nick == $irc->_nick)
  48.                         return;
  49.        
  50.                 // now check if this is the right channel
  51.               if ($data->channel == '#GWing')
  52.                 // it is, lets greet the joint user
  53.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Welcome '.$data->nick).'!';
  54.         }
  55.  
  56.         function fight(&$irc, &$data) {
  57.  
  58.                 $name = $data->nick;
  59.  
  60.                 $running = '0';
  61.  
  62.                 if(isset($data->messageex[1])) {
  63.  
  64.                         $timing = $data->messageex[1];
  65.  
  66.                         if ($running == '1') {
  67.                                 $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'I\'m already fighting!  Wait your turn!');
  68.                         } else {
  69.  
  70.                                 if ($timing <= '1000') {
  71.                                         $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'A second per line is quite fast, and it would cause me to flood the servers.');
  72.                                         $irc->message(SMART_IRC_TYPE_CHANNEL, '#GWing', 'So, in short... no.');
  73.  
  74.                                 } else {
  75.  
  76.                                 $running = '1';
  77.                
  78.                                 $fight = &new fight();
  79.                                 $irc->registerTimehandler($timing, $fight, 'training');
  80.                                 }
  81.                         }       
  82.                 } else {
  83.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Usage: !train <timing>');
  84.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Where <timing> is the amount of time in milliseconds between lines.');
  85.  
  86.                 }
  87.         }
  88.                
  89.         function insult(&$irc, &$data) {
  90.                 // we need the nickname parameter
  91.                 if (isset($data->messageex[1]) and $data->messageex[1]=="HAL") {
  92.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'I\'m sorry.  I can\'t do that right now.');
  93.                 } else if (isset($data->messageex[1])) {
  94.                         $randinsult = rand(1,4);
  95.                         if ($randinsult == 1) {
  96.                                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is a stinking rhinoceros pizzle.');
  97.                         }
  98.                         if ($randinsult == 2) {
  99.                                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' tends to pick his nose.');
  100.                         }
  101.                         if ($randinsult == 3) {
  102.                                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is in love with William Hung.');
  103.                         }
  104.                         if ($randinsult == 4) {
  105.                                 $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', $data->messageex[1].' is a dirty trash recepticle for sperm.');
  106.                         }
  107.                 } else {
  108.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'I\'m sorry.  You have not supplied the correct parameters, so I am unable to comply.');
  109.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Please try again.');
  110.                 }
  111.         }
  112.  
  113.         function shutdown(&$irc, &$data) {
  114.                 $password = $data->messageex[1];
  115.                 if($data->nick=='Master') {
  116.                         $irc->quit('Yes SIR!');
  117.                 } else {
  118.                         $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'You do not have the appropriate permissions to execute that command.');
  119.                 }
  120.         }
  121. }
  122.  
  123. class fight {
  124.         function training(&$irc, &$data) {
  125.  
  126.         $nick = $data->nick;
  127.  
  128.         if (!isset($type)) {
  129.  
  130.         $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', 'Roger that.  Commencing training session.');
  131.  
  132.         global $type = 1;
  133.  
  134.         } else {
  135.  
  136.         $randomline = rand(1,3);
  137.  
  138.                 if ($randomline == 1) {
  139.                         global $type = 1;
  140.                 }
  141.                 if ($randomline == 2) {
  142.                         global $type = 2;
  143.                 }
  144.                 if ($randomline == 3) {
  145.                 }
  146.         }
  147.                
  148.  
  149.         switch($type) {
  150.         case "1":
  151.                 $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= He would begin to move, slightly extending his words =-');
  152.                 break;
  153.         case "2":       
  154.                 $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= Comes forth to bring upwards his attack for the trainee =-');
  155.                 break;
  156.         case "3":
  157.                 $line = $irc->message(SMARTIRC_TYPE_CHANNEL, '#GWing', '-= Drives in to connect with his previous attack =-');
  158.                 break;
  159.         }
  160.  
  161.  
  162.         return $line;
  163.         }
  164. }
  165.    
  166. $bot = &new mybot();
  167. $irc = &new Net_SmartIRC();
  168. $irc->setDebug(SMARTIRC_DEBUG_ALL);
  169. $irc->setUseSockets(TRUE);
  170. $irc->setChannelSyncing(TRUE);
  171. $irc->registerActionhandler(SMARTIRC_TYPE_JOIN, 'GWingUser', $bot, 'onjoin_greeting');
  172. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!status', $bot, 'whoareyou');
  173. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!master', $bot, 'master');
  174. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!train', $bot, 'fight');
  175. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!shutdown', $bot, 'shutdown');
  176. $irc->registerActionhandler(SMARTIRC_TYPE_QUERY, '^!shutdown', $bot, 'shutdown');
  177. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!join', $bot, 'join');
  178. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!kick', $bot, 'kick');
  179. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!tell', $bot, 'tell');
  180. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!insult', $bot, 'insult');
  181. $irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '^!help', $bot, 'help');
  182. $irc->connect('irc.surrealchat.net', 6667);
  183. $irc->login('HAL', 'HALscript', 0, 'GWing', 'c0mputer');
  184. $irc->join(array('#GWing'));
  185. $irc->listen();
  186. $irc->disconnect();
  187. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation