#!perl -T use strict; use Irssi; use LWP::Simple; use LWP::UserAgent; use CGI qw/unescapeHTML/; use vars qw($VERSION %IRSSI); $VERSION = '0.0.1'; %IRSSI = ( 'authors' => 'Craig Andrews', 'contact' => 'craig@simplyspiffing.com', 'name' => 'lookupbot', 'description' => 'Some kind of magical internet searcher', 'license' => 'Craig\'s Magical Freebie License'); # Get the count and cleaned up data sub get_data { my $data = shift; my @params = split / +/, $data; my $trigger = shift @params; my $count = 1; if (defined $params[0] && int($params[0]) > 0) { $count = shift @params; $count = 10 if $count > 10; } $data = join ' ', @params; $data =~ s/[^[:print:]]/ /g; $data =~ s/ */ /g; return ($trigger, $count, $data); } # Retrieve the content froma url sub get_content { my ($url, $data) = @_; $data = CGI::escape($data); $url = sprintf($url, $data) if defined $data; my $ua = LWP::UserAgent->new(agent => "google suck"); my $result = $ua->get($url); my $content; $content = $result->content if $result->is_success; return $content; } sub image_search { my $content = shift; my @definitions = $content =~ /imgurl=(.+?)\&/g; return @definitions; } sub define_search { my $content = shift; $content =~ s/[\n\r]+/ /g; my @definitions = $content =~ /(?<=
(.+?)<\/p>/ig; @definitions[0] = @tmp[1]; } else { @definitions = $content =~ /(?<=