Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 02-18-2007, 06:06 AM IRC Script !!!
Average Talker

Posts: 28
Trades: 1
If someone know a nice IRC Open Source script then please do share it to me.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
pulikuttann is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-18-2007, 10:00 AM Re: IRC Script !!!
TyR
TyR's Avatar
Super Talker

Posts: 139
Location: Frei - Norway
Trades: 0
Here's a IRC bot I worked on a few years back. Worked fine back then.
Never finished it, but I just thought I'd share

PHP Code:
<?php
// By Thomas "TyR" Pedersen
// license: http://www.gnu.org/licenses/gpl.txt
// www.n1studios.net
class Bot {

var 
$nickname "Weehbot";
var 
$server "irc.quakenet.org"//Quakenet don't work anymore (protection)
var $port="6667";
var 
$connected=0;
var 
$socket;
var 
$password "pennyless";
var 
$received;
var 
$string;
var 
$privarray;

function 
bot(){
    
$this->bot_send_out();
}
function 
bot_send_out(){

echo 
"Connecting to server...\n";

if (
$this->socket=fsockopen($this->server$this->port)) {
    
$this->connected 1;
    echo 
"Connected to ".gethostbyname($this->server)."\n";
    
$this->bot_send("PASS " $this->password);
    
$this->bot_send("NICK " $this->nickname);
    
$this->bot_send("USER guest 0 * :Botboy");
    
$this->bot_send("JOIN #weehbot");
    
$this->bot_send("PRIVMSG #weehbot Hia!");

}
else
{
    echo 
"Connection failed\n";
}
}

function 
bot_send($string){
    
fputs($this->socket,$string."\r\n");
}

function 
bot_receive(){
    if (
$this->connected){
        
$this->received=fgets($this->socket,520);
        
$this->received=$this->bot_format_content($this->received);
        return 
$this->received;
    }
}

function 
bot_format_content($string){

    switch (
$string){
        case 
eregi("PRIVMSG"$string)==true:
            
$privmsg=explode(" ",$string);
            
$this->bot_commands($privmsg[3],$privmsg[2]);
        break;

        case 
substr($string,0,4)=="PING":
            
$string=str_replace("PING","PONG",$string);
            
$this->bot_send($string);
            
$string="<-- PING\n -->PONG \n";
        break;
    }

    return 
$string;
}
function 
bot_commands($string,$to){
    
$string=trim(substr($string,1,strlen($string)));
    switch (
$string){
        case 
"Hello":
            
$this->bot_send("PRIVMSG $to Hi there ^-^\r\n");
        break;
        case 
"!bye":
        
$this->connected=0;
        break;
        case 
"!join":
            echo 
"moo";
            
$this->bot_send("JOIN #weeh\r\n");
        break;
        case 
"MODE $this->nickname +i":
            echo 
"moo";
            
$this->bot_send("JOIN #weeh\r\n");
        break;
    }
}
}

echo 
"\-----------------------------------------\  \n";
echo 
" \ IRC BOT v0.1 by Thomas Pedersen aka TyR \  \n";
echo 
"  \-----------------------------------------\  \n";
$bott = new Bot;
while(
$bott->connected)
{
echo 
$bott->bot_receive();
}
?>
EDIT:
I just tested the script and it didn't work 100% now.
But it still connects to irc and can receive private messages etc... it just wont join any channels.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by TyR; 02-18-2007 at 10:24 AM..
TyR is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to IRC Script !!!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10639 seconds with 12 queries