Created
August 21, 2010 00:18
-
-
Save usrbinsam/541502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use IO::Socket; | |
my $net = $ARGV[0]; | |
my $nickname = 'ircwiki'.$$; | |
my $irc = IO::Socket::INET->new( | |
PeerAddr => $net, | |
PeerPort => '6667', | |
Proto => 'tcp', | |
Timeout => '30') or die "Unable to establish connection to $net ($!)\n"; | |
my $file = "$net.txt\n"; | |
open(CRAWL, ">>$file"); | |
print $irc "NICK $nickname\r\n"; | |
print $irc "USER irc-wiki 8 * :IRC-Wiki Network Crawler (http://www.irc-wiki.org/)\r\n"; | |
while (my $buffer = <$irc>) | |
{ | |
print $buffer; | |
if ($buffer =~ m/^PING :(.*)/) | |
{ | |
print $irc "PONG $1\r\n"; | |
my $server = $1; | |
} | |
if ($buffer =~ /:(.*) 001 (.*) :Welcome to the (.*) IRC Network (.*)/) { print CRAWL "server=$1\n"; print CRAWL "network=$3\n"; } | |
if ($buffer =~ /266 (.*) :Current Global Users: (.*) Max: (.*)/) | |
{ | |
print CRAWL "globalcurrent=$2\n"; print CRAWL "globalmax=$3\n"; | |
print $irc "QUIT :Houston, we have contact! (http://www.irc-wiki.org/)\r\n"; | |
} | |
} | |
close($irc); close(CRAWL); | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment