Post: PHP IRC Bot Shell
01-01-2010, 07:28 PM #1
TViYH
Gobble
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys Smile

I'm new here, I figured I may as well start out with an attempt to help.

Here's a PHP IRC Bot Shell I quickly wrote up for some of those people who are wanting to make one.

Note that this must be run via PHP-CLI.

I hope you enjoy it Smile Any questions, just post them here.

    <?php

$nick = "TestBot"; // What do you want the nick for the IRC Bot to be?

$server = "irc.rizon.net"; // What server do you want the IRC Bot to join?

$port = "6667"; // What port do you want the IRC Bot to connect to the server on?

$channel = "#tviyh"; // What channel do you want the IRC Bot to join?

$nickpass = "password"; // What is the bot's nickserv pass?


$s = fsockopen( $server , $port ); // Open a connection to the server

fputs( $s, "USER $nick $nick $nick $nick :$nick\n" ); // Send your user to the server, etc

fputs( $s, "NICK $nick\n" ); // Set your desired nick


while ( $data = fgets( $socket ) ) { // While the connection is open

flush(); // Flush the write buffers

$info = split( " ", $data ); // Split the raw message into an array separated by spaces

if ( $info[1] == "001" ) { // If the server sends us the Welcome message

fputs( $s, "PRIVMSG NickServ :identify $nickpass\n" ); // Send our nickserv pass

sleep(.75); // Wait 3/4 second

} elseif ( strstr( $data, "Password accepted" ) or strstr( $data, "You are already identified" ) or strstr( $data, "Your nick isn't registered" )) { // If NickServ recognized us as a user

fputs( $s, "JOIN $channel\n" ); // Join the desired channel

sleep(.75); // Wait 3/4 second

}

}


?>
(adsbygoogle = window.adsbygoogle || []).push({});

The following user thanked TViYH for this useful post:

farees10
01-02-2010, 03:35 AM #2
bmxdude9
Million Miles Of Fun!
just wondering when IRC connects and uses its sockets, it is HTTP correct? Now if so they need to switch to HTTPS or something as its still light and well people use IRC bots WAY to often to send corrupt packets(ddos). Nice work, quite simple define some conditions and functions and use if statements. (if...this...than else) btw I am curious on something?

I know in C++ its just else, in PHP its elseif?
01-03-2010, 05:11 AM #3
TViYH
Gobble
Yes, you can use elseif or a ternary operand.

And no, I don't think port 6667 is HTTP :/ It's the IRC Protocol port.


And this isn't supposed to be run from a webserver, but from command line.
01-03-2010, 01:35 PM #4
bmxdude9
Million Miles Of Fun!
well I do know about the command line as Ive seen other versions of these that basically give you a lot of control over the channel like kicking etc. What is the command line btw?
01-03-2010, 03:37 PM #5
Nice and hey TViYH Happy

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo