if( $time < 5 ) {
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
my $req = HTTP::Request->new( GET => 'http://bash.org/?'.$what );
my $res = $ua->request( $req );
my @quotes;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
my $req = HTTP::Request->new( GET => 'http://qdb.us/?'.$what );
my $res = $ua->request( $req );
my @quotes;
my $ua = LWP::UserAgent->new(
agent => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051224 Debian/1.5.dfsg-3 Firefox/1.5"
);
+ $ua->timeout(5);
my $response = $ua->get( 'http://www.webtender.com/cgi-bin/search?name="'.$what.'"' );
if( $response->{ '_rc' } != 200 ) {
$kernel->post( $src, $replypath, "Failed to retrieve search results.", $dest );
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
my $req = HTTP::Request->new( GET => 'http://grouphug.us/random' );
my $res = $ua->request( $req );
my @hugs;
}
}
}
+
+TITLE: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ if( $what !~ /^https?:\/\/.+$/ ) {
+ $kernel->post( $src, $replypath, "Usage: TITLE <URL>", $dest );
+ return;
+ }
+
+ use WWW::Shorten::TinyURL;
+
+ use LWP::UserAgent;
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
+ my $req = HTTP::Request->new( GET => $what );
+ my $res = $ua->request( $req );
+ if( $res->is_success ) {
+ my $content = $res->content;
+ if( $content =~ /<title>(.*?)<\/title>/si ) {
+ use HTML::Entities;
+ my $title = decode_entities( $1 );
+ $kernel->post( $src, $replypath, "Title: $title (".makeashorterlink( $what ).")", $dest );
+ } else {
+ $kernel->post( $src, $replypath, "Title: None (".makeashorterlink( $what ).")", $dest );
+ }
+ }
+ }