User:Monie089
From Wikipedia, the free encyclopedia
Monie
A very awesome, cool, and helpful person on the Wii-Battle (http://wii-battle.com/) network. Please respect this person and great things shall happen to you. If you do not respect Monie, you shall die a painful death. - Frost
package torrentspy;
use LWP::Simple qw(get $ua); use strict; my $num_output = 5; $ua->timeout(7);
our %settings = ( trigger => '!tspy' );
sub main { my ( $plug, $chan, $nick, $host, $text ) = @_; if ($text eq 'null') { chucklebot->notice($nick, "$settings{'trigger'} requires a search term. Type !help $settings{'trigger'} for help."); } else { $text =~ s/\ /\+/g; my $content = get("http\:\/\/www\.torrentspy\.com\/rss.asp\?mode\=search\&query\=$text"); if (!$content) { chucklebot->notice($nick, "Unable to retrieve RSS. Timeout/Error."); return(); } my @results = parse_content($content); if (@results > 1) { chucklebot->notice($nick, "$_") foreach (@results); } else { chucklebot->privmsg($chan, "No Results!?"); } undef($content); } }
sub parse_content { my $num_output = $num_output; my $content = shift; $content =~ s/\n//g; $content =~ s/\r//g; my ($title,$description,$link,@items,@results) = undef; if ($content =~ /\<title\>(.+?)\<\/title\>/i) { $title = $1; } if ($content =~ /\<description\>(.+?)\<\/description\>/i) { $description = $1; } if ($content =~ /\<link\>(.+?)\<\/link\>/i) { $link = $1; } $title = convert($title); $description = convert($description); $link = convert($link); if ($title) { push(@results, "�$title� - $description [$link]"); } @items = split(/\<item/, $content); if (@items < $num_output) { $num_output = @items-1; } elsif (@items <= 1) { $num_output = 0; } for (my $x = 1; $x<$num_output+1; $x++) { if (@items[$x] =~ /\<title\>(.+?)\<\/title\>/i) { $title = $1; } if (@items[$x] =~ /\<link\>(.+?)\<\/link\>/i) { $link = $1; } $title = convert($title); $link = convert($link); push(@results, "�$title� - $link"); } undef(@items); undef($content); return(@results); }
sub convert { my $line = shift; $line =~ s/\<\;/</g; $line =~ s/\>\;/>/g; $line =~ s/\&\;/\&/g; $line =~ s/\"\;/\"/g; #$line =~ s/ / /g; return($line); } - From Your friend, Perl McScripter