All pastes #621787 Raw Edit

Xires

public text v1 · immutable
·published 2007-07-16 12:23 UTC
rendered paste body
#!/usr/bin/perl

use IO::Socket::INET;

my $server="irc.server.com";
my $port="6667";
my $nick="randomnick";
my $channel="#channel";

my $sk = IO::Socket::INET->new(
			PeerAddr=>"$server",
			PeerPort=>"$port",
			Proto=>"tcp"
		) or die "Can not connect on server!\n";

$sk->autoflush(1);

print $sk "NICK $nick\r\n";
print $sk "USER lol 8 *  : osohot : rand.googepage.com\r\n";
print $sk "JOIN $channel\r\n";

while($line = <$sk>) {
	$line =~ s/\r\n$//;

	if ($line=~ /^PING \:(.*)/) {
		print "PONG :$1";
		print $sk "PONG :$1";
	}

	if ($line=~ /PRIVMSG $channel :.test/) {
		stamp($sk, "PRIVMSG $channel :® Test if it works");
	}
}

sub stamp() {
	if ($#_ == '1') {
		my $sk = $_[0];
		print $sk "$_[1]\n";
	} else {
		print $sk "$_[0]\n";
	}
}