1.

Solve : [Perl] IRC Bot ":roc.esper.net 451 * liam-BOT :Register first."?

Answer»

I am SIMPLY trying to create a bot that connects to a server and runs some simple scripts for an IRC channel my friend runs --

-- i ripped the CODE from a site so it's not exactly mine, but I can't seem to get it working with roc.esper.net. -- Heres the code, it's a single file so you can simply throw it in your own core.pl.

Code: [Select]#!/usr/bin/perl
#perl ircbot by netcomm


#lets set some varibles

$server = "roc.esper.net"; #server
$port = 5555;              #port
$NICK = "liam-BOT";         #nick
$ident = "liam-BOT";        #ident
$realname = "LiamsBot";  #realname
$chan = "#testirc";        #channel
$pass = "";                #pass
$su = "liam";              #super user
$OWNERS = "liam";          #owners




use IO::Socket;

$irc=IO::Socket::INET->new(
                PeerAddr=>$server,
                PeerPort=>$port,
                Proto=>'tcp')or die "DEAD!";
               
                                print "PerlBot by netcomm\n";
                                print "$nick has connected to $server on $chan\n";
                                print $irc "USER $ident $ident $ident $ident :$realname\n";
                                print $irc "NICK $nick\n";
                                print $irc "PRIVMSG nickserv//services.dal.net :identify $pass\n";
                                print $irc "join $chan\n";
                                print $irc "PRIVMSG $owners :$nick is online\n";
                           
                           while(defined($in=<$irc>)){
                                         
                                               
                                               
                                                 
                                                        ### Start of commands   
                                               



if($in=~/^:(.+)\!.+ JOIN\b/){print $irc "PRIVMSG $1 :hello $1 welcome to $chan\n";}
if($in=~/PING(.*)/){print $irc "PONG :$1\n";} # MUST LEAVE THIS LINE
print "$in\n"; # AND THIS ONE



next unless $in =~ /^:$owners\b/; #makes bot only respond to owner
 

sub about {
if($in=~/!about/)
{print $irc "PRIVMSG $chan :I am a ircbot written in perl by netcomm\n";}
}

sub opdeop {
if($in=~/!op /)
{print $irc "MODE $chan +o $'\n";}
if($in=~/!deop /)
{print $irc "MODE $chan -o $'\n";}
}

sub joinpart {
if($in=~/!join / & $in=~/$su/)
{print $irc "join :$'\n";}
if($in=~/!part / & $in=~/$su/)
{print $irc "part :$'\n";}
}
                               
sub kickban {
if($in=~/!kickban /)
{print $irc "kick $chan $' :TXTbot ownz da world\n";}
if($in=~/!kickban /)
{print $irc "mode $chan +b $'\n";}
}

sub kick {
if($in=~/!kick /)
{print $irc "kick $chan $' :TXTbot ownz da world\n";}
}

sub raw {
if($in=~/!raw / & $in=~/$su/)
{print $irc " $'\n";}
}


sub say {
if($in=~/!say /)
{print $irc "PRIVMSG $chan :$'\n";}
}
 
sub quit {
if($in=~/!quit/ & $in=~/$su/)
{print $irc "PRIVMSG $chan :Seya\n";}
if($in=~/!quit/)
{print $irc "QUIT\n";}
}

sub name {
if($in=~/!nick / & $in=~/$su/)
{print $irc "nick :$'\n";}
}

sub rehash {
if($in=~/!rehash/ & $in=~/$su/)
{print $irc "PRIVMSG $chan :Rehashing...\n";}
if($in=~/!rehash/ & $in=~/$su/)
{print $irc "QUIT\n";}
if($in=~/!rehash/ & $in=~/$su/){
system("bot.pl");}
if($in=~/!rehash/ & $in=~/$su/){
print $irc "join $chan";}
}

sub viewusers {
if($in=~/!users/)
{print $irc "PRIVMSG $chan :Current Users:$owners\n";}
}


#sub calls

&viewusers;
&rehash;
&raw;
&kickban;
&say;
&name;
&kick;
&about;
&opdeop;
&joinpart;
&quit;

}
close($irc);



Discussion

No Comment Found