sub {
use WWW::Shorten 'SnipURL';
use XML::RSS;
- use LWP::Simple;
use Time::CTime;
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
}
my $xml;
- if( !( $xml = get( $url ) ) ) {
+ use LWP::UserAgent;
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
+ my $req = HTTP::Request->new( GET => $url );
+ my $res = $ua->request( $req );
+ if( $res->is_success ) {
+ $xml = $res->content;
+ } else {
$kernel->post( $src, $replypath, "Failed to fetch RSS feed from $url", $dest );
return;
}
FANDANGO: |-
sub {
- use LWP::Simple;
use POSIX;
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
}
if( $#args == 0 ) {
if( $args[0] =~ /^[0-9]{5}$/ ) {
- my $site = get( 'http://www.fandango.com/TheaterListings.aspx?location='.$args[0] );
+ my $site
+ use LWP::UserAgent;
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
+ my $req = HTTP::Request->new( GET => 'http://www.fandango.com/TheaterListings.aspx?location='.$args[0] );
+ my $res = $ua->request( $req );
+ if( $res->is_success ) {
+ $site = $res->content;
+ } else {
+ $kernel->post( $src, $replypath, "Accessing Fandango page failed.", $dest );
+ }
$site =~ s/ / /gi;
my @lines = split( /\n/, $site );
my @pages;
GROUPHUG: |-
sub {
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ my @hugs;
+
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;
if( $res->is_success ) {
my $content = $res->content;
$content =~ s/[\n\r]//g;
TITLE: |-
sub {
+ use POE::Component::IRC::Common qw( :ALL );
my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
if( $what !~ /^https?:\/\/.+$/ ) {
$kernel->post( $src, $replypath, "Usage: TITLE <URL>", $dest );
if( $content =~ /<title>(.*?)<\/title>/si ) {
use HTML::Entities;
my $title = decode_entities( $1 );
- $kernel->post( $src, $replypath, "Title: $title (".makeashorterlink( $what ).")", $dest );
+ $title =~ s/[[:space:]]+/ /gs;
+ $title =~ s/(^[[:space:]]*)|([[:space:]]*$)//gs;
+ $kernel->post( $src, $replypath, BOLD . makeashorterlink( $what ) . NORMAL . " ($title)", $dest );
} else {
- $kernel->post( $src, $replypath, "Title: None (".makeashorterlink( $what ).")", $dest );
+ $kernel->post( $src, $replypath, BOLD . makeashorterlink( $what ) . NORMAL, $dest );
}
}
}