Jump to content

PHP IRC bot welcome message?


ChrisMartino

Recommended Posts

Ok, So i have my php bot working on my vps, It connects to the server :D, it logs in just doesn't do anything yet haha, How would i make it send welcome messages to people that join?, Heres the code:

 

<?php
// Prevent PHP from stopping the script after 30 sec
set_time_limit(0);

// Edit these settings
$chan = "#Christopher";
$server = "irc.gtanet.com";
$port = 6667;
$nick = "MrRobot";
$pass = "password"; 

// STOP EDITTING NOW.
$socket = fsockopen("$server", $port);
fputs($socket,"USER $nick $nick $nick $nick :$nick\n");
fputs($socket,"NICK $nick\n");
fputs($socket,"identify $pass\n");
fputs($socket,"JOIN ".$chan."\n");

while(1) {
while($data = fgets($socket)) {
        	echo nl2br($data);
        flush();

        	$ex = explode(' ', $data);
	$rawcmd = explode(':', $ex[3]);
	$oneword = explode('<br>', $rawcmd);
        $channel = $ex[2];
	$nicka = explode('@', $ex[0]);
	$nickb = explode('!', $nicka[0]);
	$nickc = explode(':', $nickb[0]);

	$host = $nicka[1];
	$nick = $nickc[1];
        if($ex[0] == "PING"){
        		fputs($socket, "PONG ".$ex[1]."\n");
        }

	$args = NULL; for ($i = 4; $i < count($ex); $i++) { $args .= $ex[$i] . ' '; }

        	if ($rawcmd[1] == "!sayit") {
	        fputs($socket, "PRIVMSG ".$channel." :".$args." \n");
        }
	elseif ($rawcmd[1] == "!md5") {
		fputs($socket, "PRIVMSG ".$channel." :MD5 ".md5($args)."\n");
	}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/188271-php-irc-bot-welcome-message/
Share on other sites

dude if a user joins the channel the server will tell you he joins, find out how you can figure out how to know when a user joins and then parse the information and use it in php :) I'm gonna make a php IRC bot I was gonna make one in mIRC(mSL) but I forgot it, so imma make mine pro n stuff in php lol

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.