OUTLAW3D Posted November 1, 2007 Share Posted November 1, 2007 Ok, so I am making an IRC bot in PHP and I want it to perform an action like /me slaps you but I can't get it to work. A friend said to do this: fputs($socket, "PRIVMSG ".$ex[2]." :\001ACTION".$ex[4]." :\001\r\n"); That doesn't work though. I want the bot to accept a name and then perform an action like I say "!slap that_guy" and the bot will say "bot slaps that_guy". Here is my source so far: <?php set_time_limit(0); $socket = fsockopen("irc.thedefaced.org", 6667); fputs($socket, "USER mini-me dark-coders.co.uk MM :mini-me\n"); fputs($socket, "NICK mini-me\n"); fputs($socket, "JOIN #Dark-Coders\n"); while(1) { while($data = fgets($socket, 128)) { echo nl2br($data); flush(); $ex = explode(' ', $data); if($ex[0] == "PING") { fputs($socket, "PONG ".$ex[1]."\n"); } $command = str_replace(array(chr(10), chr(13)), '', $ex[3]); if($command == ":!quit") { fputs($socket, "PRIVMSG ".$ex[2]." :Later guys!\n"); die(); } $md5 = md5($ex[4]); if($command == ":!md5") { fputs($socket, "PRIVMSG ".$ex[2]." :$md5\n"); } $say = $ex[4]; if($command == ":!say") { fputs($socket, "PRIVMSG ".$ex[2]." :$say\n"); } } } ?> If you understand what I'm asking, do you think you could help me out? Quote Link to comment https://forums.phpfreaks.com/topic/75596-irc-bot/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.