#!/usr/bin/perl # v0.1 use IO::Socket; $server = "irc.spot.com"; $channel = "#chan"; $nick = "nick"; $user = "name somethin.org * :realname"; $pass = ""; $verbose = 0; # override defaults if( $ARGV[0] ) { $channel = $ARGV[0] } if( $ARGV[1] ) { $server = $ARGV[1] } if( $ARGV[2] ) { $nick = $ARGV[2] } # open connection $sock = new IO::Socket::INET( PeerAddr => $server, PeerPort => 6667, Proto => 'tcp' ) or die "Can't connect\n"; print $sock "PASS $pass\r\n"; print $sock "USER $user\r\n"; print $sock "NICK $nick\r\n"; while( $input = <$sock> ) { if( $input =~ /^PING(.*)$/i ) { print $sock "PONG $1\r\n"; } elsif ($input =~ /004/) { last; } elsif ($input =~ /433/) { die "Nickname is already in use."; } } print $sock "JOIN $channel\r\n"; # monitor input while( my $input = <$sock> ) { chop $input; if( $input =~ /^PING(.*)$/i ) { print $sock "PONG $1\r\n"; } @in = split(" ", $input); $host = shift(@in); @you = split("!", $host); $yrnick = $you[0]; $yrnick =~ s/^://; $type = shift(@in); $chan = shift(@in); $data = join(" ", @in); $data =~ s/^://; if( ($type eq "PRIVMSG") && ($chan eq $nick) ) { priv(); } if( ($type eq "PRIVMSG") && ($chan ne $nick) ) { pub(); } if( $verbose ) { print "$input\n" } } sub priv { # start a matching channel for matching nick if( $data =~ /^special word ([^ ]+)$/ ) { if( $1 eq "off" ) { print $sock "PRIVMSG $channel #$match turned off\r\n"; $match = ""; } else { $match = $1; $match =~ s/[^A-Za-z0-9_]//g; print $sock "PRIVMSG $channel $match now playing in #$match\r\n"; } } } sub pub { if( $data eq "shut up $nick" ) { $i = 0 } if( $data eq "wake up $nick" ) { $i = 1 } if( $yrnick =~ /$match/ ) { print $sock "PRIVMSG #$match $data\r\n"; } if( ($data =~ /poop/i) && ( $i == 1) ) { print $sock "PRIVMSG $channel lol poop\r\n"; } }