BLACK BURN HACKER. Powered by Blogger.

Real Money Instantly


Saturday, January 28, 2012

[php] IRC Bot Skeleton

This is my little skeleton i worked on through out the day as i had time.

  Author:  Blosh or PaT
  Intention: IRC Bot Skeleton
         Start with this and you can create anything from a channel bot to a bot for a net.

  My Sites:
$bot_nick = "Blosh";
$nick = $bot_nick;//.randNum(1000,9999);
$chan = "#l3ot";
$master = "Blosh";
$masteru= "Blosh";

$s = stream_socket_client("tcp://", $eno, $estr, 45);
function randNum($low, $high){  
         return mt_rand($low, $high);
function cleanwhitespace($str){
  $a = str_replace("\r","", $str);
  $a = str_replace("\n","", $a);
  $a = str_replace("\t","", $a);

  return $a;
function commands($usr, $target, $msg, $fromNotice = false){
  global $s;
  if ($fromNotice == true){
   $action = "NOTICE";
   $action = "PRIVMSG";
  if ($msg == ";die"){
   fwrite($s, "$action $target :Goodbye.\n");
   die("kill by ".$usr['nick']);
  if ($msg == ";help"){
   fwrite($s, "$action $target :For help on a certain command: ;help (COMMAND)\n");
   fwrite($s, "$action $target :For a list of availible commands: ;commands\n");
  }elseif(substr($msg, 0, 6) == ";help "){
   $a = explode(";help ", $msg);
   $cmd = $a[1];
        case "die";
         fwrite($s, "$action $target :HELP - COMMAND: $cmd - Closes irc connection and kills self.\n"); 
         fwrite($s, "$action $target :USAGE: ;die\n");  

  if($msg == ";commands"){
   fwrite($s, "$action $target :COMMAND: die - Closes irc connection and kills self.\n");       
   fwrite($s, "$action $target :USAGE: ;die\n");        
   fwrite($s, "$action $target :COMMAND: help - Closes irc connection and kills self.\n");      
   fwrite($s, "$action $target :USAGE: ;help [command]\n");     
   fwrite($s, "$action $target :COMMAND: commands - Lists all availible commands.\n");  
   fwrite($s, "$action $target :USAGE: ;commands\n");   
if (!$s){
  echo "error\r\n";
  echo "\r\n\r\nconnected\r\n\r\n";
  fwrite($s, "NICK $nick\n");
  fwrite($s, "USER $nick \"\" \"\" :$nick\n");
  fwrite($s, "JOIN $chan\n");
  while (!feof($s)) {
   $d = fgets($s, 2048);
   echo $d;
   if( preg_match("/^PING :(?<pong>.*)$/i", $d, $m) ){
        fwrite($s, "PONG :".$m['pong']."\n");
   :Blosh! $action #l3ot :;die
   $d = cleanwhitespace($d);
   if( preg_match("/^:(?<nick>.*)!(?<usr>.*)@(?<usrhost>.*) PRIVMSG (?<chan>.*) :(?<msg>.*)$/i", $d, $m) ){
        $usr = array(
                "nick" => $m['nick'], "user" => $m['usr'], "host" => $m['host']
        if ( $usr['nick'] == $master ){
         if ( $usr['user'] == $masteru ){
          if ($m['chan'] == $nick){ $m['chan'] = $usr['nick']; }
          commands($usr, $m['chan'], $m['msg'], false);
   }elseif (preg_match("/^:(?<nick>.*)!(?<usr>.*)@(?<usrhost>.*) NOTICE (?<chan>.*) :(?<msg>.*)$/i", $d, $m)) {
        $usr = array(
                "nick" => $m['nick'], "user" => $m['usr'], "host" => $m['host']
        if ( $usr['nick'] == $master ){
         if ( $usr['user'] == $masteru ){
          commands($usr, $m['nick'], $m['msg'], true);
  } //end while

  echo "\r\n\r\nclosed\r\n\r\n";

©2011, copyright BLACK BURN


  1. IRCFOrumlari is an independent organization from all individuals which is being given service about Turkish ircd and IRC Forums.



7 Years Earning Experience

The Earning Source You Can Trust

Follow by Email