All pastes #89852 Raw Edit

Stuff

public text v1 · immutable
#89852 ·published 2006-07-17 02:42 UTC
rendered paste body
#Min0ria coded b Ph4d3  

  use strict;
  use warnings;
  use IO::Socket;
                                            
  my $nick = "Min0ria";
  my $user = "Min0ria 0 0 :Min0ria V_1";
  my $server = "irc.zirc.org"; 
  my $port = 6667; 
  my $chan = "#Min0ria"; 
  my $quitmsg = ""; 
 
  my $sock = new IO::Socket::INET (PeerAddr => "$server",
                                                  PeerPort => $port,
                                                  Proto => 'tcp') or die "Cannot create socket!"; 
  print $sock "NICK $nick\n"; 
  print $sock "USER $user\n";
 
  while (my $input = <$sock>) {
        chomp $input;
        $input =~ s/\r//;
        my @myin = split(/ /, $input); 
        my $usernick = $myin[0];
        my $usermask = $myin[0];
        $usernick =~ s/^://;
        $usermask =~ s/^://;
        $usernick =~ s/!\S+@\S+$//; 
        $usermask =~ s/^\S+!//; 
        if ("$myin[0]" eq "PING") {
              print $sock "PONG $myin[1]\n"; 
        }
        elsif ("$myin[1]" eq "001") {   
              print $sock "JOIN $chan\n"; 
        }     
        elsif ("$myin[1]" eq "PRIVMSG" && $myin[3] =~ /^:!/) { 
              my $cmdplace = "$myin[2]"; 
              my $cmd = "$myin[3]"; 
              $cmd =~ s/^:!//; 
              $cmd =~ s/\r|\n//g; 
              my $cmdjunk;
              if (exists($myin[4])) { 
                    foreach (@myin[4..$#myin]) { $cmdjunk .= "$_ "; }
                    $cmdjunk =~ s/\r|\n//g;
                    $cmdjunk =~ s/ $//; 
              }
              if ("$cmdplace" eq "$nick") {
                    $cmdplace = $usernick;
              }          
              if ("$cmd" eq "quit") {
                    &quit;
              }
              elsif ("$cmd" eq "othercommand") {
                    #&dostuff();
              }
        }
  }