skittles irc script

By jsg55 on Jan 14, 2010

basically connects to whatever irc server you choose and hands out skittles when the command is used :).. i realize that it would be much easier to make a script like this in msl but i need experience with perl. apologies for any problems with it.

 #!/usr/bin/perl
$server = "irc.whateverserver.net";  # you change everything from server to pass 
$port = 6667;    
$nick = "yournick";    
$ident = "yourident";   
$realname = "yourrealname";       
$chan = "#yourchannel";           
$pass = "yourpass";                       
use IO::Socket;
$irc=IO::Socket::INET->new(
           PeerAddr=>$server,
           PeerPort=>$port,
           Proto=>'tcp')or die "DEAD!";                
                 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.yournetwork.net :identify $pass\n"; #you change this
                 print $irc "join $chan\n";                           
                    while(defined($in=<$irc>)){                                                                                        
if($in=~/PING(.*)/){print $irc "PONG :$1\n";} 
print "$in\n";    
if($in=~/!skittle/){
$x = int(1 + rand 20);
if ($x == 1){ print $irc "PRIVMSG $chan :gives a 9lime skittle to $'\n";}
elsif ($x == 2){ print $irc "PRIVMSG $chan :gives a 6grape skittle to $'\n";}
elsif ($x == 3){ print $irc "PRIVMSG $chan :gives a 8lemon skittle to $'\n";}
elsif ($x == 4){ print $irc "PRIVMSG $chan :gives a 7orange skittle to $'\n";}
elsif ($x == 5){ print $irc "PRIVMSG $chan :gives a 12raspberry skittle to $'\n";}
elsif ($x == 6){ print $irc "PRIVMSG $chan :gives a 5wild cherry skittle to $'\n";}
elsif ($x == 7){ print $irc "PRIVMSG $chan :gives a 5berry punch skittle to $'\n";}
elsif ($x == 8){ print $irc "PRIVMSG $chan :gives a 3melon berry skittle to $'\n";}
elsif ($x == 9){ print $irc "PRIVMSG $chan :gives a 8banana berry skittle to $'\n";}
elsif ($x == 10){ print $irc "PRIVMSG $chan :gives a 9kiwi lime skittle to $'\n";}
elsif ($x == 11){ print $irc "PRIVMSG $chan :gives a 7mango tangelo skittle to $'\n";}
elsif ($x == 12){ print $irc "PRIVMSG $chan :gives a 11pineapple passionfruit skittle to $'\n";}
elsif ($x == 13){ print $irc "PRIVMSG $chan :gives a 4strawberry starfruit skittle to $'\n";}
elsif ($x == 14){ print $irc "PRIVMSG $chan :gives a 8lemon berry skittle to $'\n";}
elsif ($x == 15){ print $irc "PRIVMSG $chan :gives a 14mixed berry skittle to $'\n";}
elsif ($x == 16){ print $irc "PRIVMSG $chan :gives a 13peach pear skittle to $'\n";}
elsif ($x == 17){ print $irc "PRIVMSG $chan :gives a 7orange mango skittle to $'\n";}
elsif ($x == 18){ print $irc "PRIVMSG $chan :gives a 13strawberry banana skittle to $'\n";}
elsif ($x == 19){ print $irc "PRIVMSG $chan :gives a 5chocolate skittle to $'\n";}
else { print $irc "PRIVMSG $chan :gives a 4strawberry skittle to $'\n";}
   }
}                                                                
close($irc);

Comments

Sign in to comment.
gooshie   -  Apr 11, 2010

Good Place for an @array. Also, changed it to return as an action with the nick of the person requesting the skittle. Added a variable for NickServ. You should not use NickServ's full mask only it's nickname.

#!/usr/bin/perl

# change values between $server and $pass

########################################################################################################################

$server = 'irc.whateverserver.com';
$port = 6667;
$nick = 'yournick';
$ident = 'yourident';
$realname = "your real name";
$chan = '#yourchannel';
$nickserv = 'NickServ';
$pass = 'yourpass';

@flavor = (
'9lime',
'6grape',
'8lemon',
'7orange',
'12raspberry',
'5wild cherry',
'5berry punch',
'3melon berry',
'8banana berry',
'9kiwi lime',
'7mango tangelo',
'11pineapple passionfruit',
'4strawberry starfruit',
'8lemon berry',
'14mixed berry',
'13peach pear',
'7orange mango',
'13strawberry banana',
'5chocolate',
'4strawberry',
);

use IO::Socket;
$irc=IO::Socket::INET->new(PeerAddr=>"$server:tcp($port)");or die "DEAD!\n";
print $irc "NICK $nick\n"; print $irc "USER $ident 8 * :$realname\n";
print $irc "PRIVMSG $nickserv :identify $pass\n"; print $irc "join $chan\n";
print "$nick has connected to $server on $chan\n";

while(defined($in = <$irc>)){
    if($in =~ /^PING(.*)/) { print $irc "PONG :$1\n" }
    print "$in\n";
    if($in =~ /^:(.+)!.+ PRIVMSG $chan :!skittles?\r$/) {
        print $irc "PRIVMSG $chan :\x01ACTION gives a \x03".$flavor[int(rand @flavor)]."\x03 skittle to $1\x01\n";
    }
}

close($irc);
 Respond  
jsg55   -  Jan 31, 2010

hm well tyvm for the input :)

 Respond  
^Neptune   -  Jan 29, 2010

I like using Net::IRC for Perl IRC bots, but this works as well. Never looked into use Socket, but good job on providing some variety around here. :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.