WhatPulse Forums » Community » General Discussion v » my IRC bot Welcome back, Guest.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
my IRC bot
03-20-2009, 05:14 PM
Post: #1
my IRC bot
It accepts one command, !stats USERID_HERE, it requires the user_parse.php from the download sections on that whatpulse site.
Code:
<?php
# USER CONFIGURATION

$server = 'irc.server.net';
$port = 6667;
$Owner = 'Shawn!Shawns@bunny.army.is.preparing.for.world.domination';
$mynick = 'WhatPulse';
$rlname = 'WhatPulse Stats Bot';
$mynickpass = 'fjdlsdFASfjkljaSDAFAEWAsd';
$channel = '#Testing';
$uModes ='+pBT';

# END OF CONFIGURATION

set_time_limit(0);
require("user_parse.php");
$socket = fsockopen($server,$port);
stream_set_timeout($socket,600);
fputs($socket,"USER $mynick somestuff here :$rlname\n");
fputs($socket,"NICK $mynick\n");
fputs($socket,"MODE $mynick $uModes\n");
fputs($socket,"PRIVMSG NickServ :IDENTIFY $mynickpass\n");
fputs($socket,"JOIN $channel\n");
while($data = fgets($socket)) {
   flush();
   $ex = explode(' ', $data);
   $command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
   if($ex[0] == 'PING'){ fputs($socket, "PONG :$ex[1]\n"); }
   if(($command == ':!die')&&($ex[0] == ":$Owner")){ die(); }
   if((preg_match("/(!stats)/Si",$command) == 1)&&($ex[4])){
      if(preg_match("/([0-9]+)/",$ex[4]) == 1) {
         PulseStats($ex[4], &$socket, &$channel);
      } else {
         fputs($socket,"PRIVMSG $channel :Please use the UserID of the person, not the account name. Ex: !stats 227041\n");
      }
   }
}
function PulseStats($StatID, &$socket, &$channel){
   $WP_stats = new WP_stats;
   $stats = $WP_stats->get($StatID);
   fputs($socket,"PRIVMSG $channel :[$stats->AccountName]: [Total Keys: $stats->TotalKeyCount/Total Clicks: $stats->TotalMouseClicks/Total Miles: $stats->TotalMiles/Rank: $stats->Rank] [Team: $stats->TeamName/Team Rank: $stats->TeamRank]\n");
}
?>

GitHub
Wishlist - Have I helped you in some way? Thank me by buying something on my wishlist! (There's even cheap things I need so you don't have to break your bank thanking me :3)
[Image: 227041.jpg]
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)