okay its a bit long though, its about 550 lines :s and it uses a lot of includes to make it simple. [code]<?PHP //add sripos if (!function_exists("stripos")) { function stripos($str,$needle) { return strpos(strtolower($str),strtolower($needle)); } } //connect to IRC set_time_limit(0); //set vars $host = 'irc.barafranca.com'; $port = '6667'; $nickname = "bot"; $channel = file('../bot/channels.txt'); //open data.txt $savedline = file('../image/data.txt'); $savedline[3] = $savedline[2]; $savedline[2] = $savedline[1]; $savedline[1] = $savedline[0]; $killmode['#chan'] = 'on'; $ks = array(); //connect $socket = fsockopen($host, $port); stream_set_timeout($socket, 60*60*24*365); fwrite($socket, "NICK ".$nickname."\r\n"); fwrite($socket, "USER ".$nickname." 8 * :nick's Bot\r\n"); fwrite($socket, "MODE ".$nickname." +B\r\n"); while ($line=fgets($socket)) { if (strpos($line, "433")>0) die(); if (strpos($line, "004")>0) { $chancount = count($channel); fwrite($socket, "PRIVMSG nickserv :IDENTIFY bot hello123\r\n"); for ($i = 0; $i < $chancount; $i++) { fwrite($socket, "JOIN ".$channel[$i]."\r\n"); } break; } } //fuctions while ($line=fgets($socket)) { $chan = explode("PRIVMSG ", $line); $chan = explode(" :", $chan[1]); $chan = explode("#", $chan[0]); $chan = "#".$chan[1]; $nick = explode(":", $line); $nick = explode("!", $nick[1]); $nick = $nick[0]; $tempstuff = explode("\r\n", $line); if (stripos($line, ":@")>0) { $tempstuff = explode(":@", $tempstuff[0]); } else { $tempstuff = explode(":!", $tempstuff[0]); } $tempstuff = explode(" ", $tempstuff[1]); $two = $tempstuff[1]; $three = $tempstuff[2]; $four = $tempstuff[3]; ?>[/code] and then the scripts are like these [code]if (stripos($line, ":hello bot")>0) { fwrite($socket, "PRIVMSG $chan :hello $nick\r\n"); }[/code]