1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 10:35:41 -04:00
perlbuut/plugins/.svn/text-base/rt.pm.svn-base
2009-12-05 00:02:04 -05:00

27 lines
593 B
Text

use WWW::RottenTomatoes;
# Construct it outside the sub so it can at least pretend to do some caching.
my $rt = WWW::RottenTomatoes->new;
sub {
my( $said, $pm ) = @_;
local $@;
my $movie_info = eval { $rt->movie_info( $said->{body} ) };
if( $@ ) {
print "Error fetching movie info: $@";
return;
}
if( $movie_info ) {
print "$movie_info->{title}: $movie_info->{rating} - ", @{ $movie_info->{bubbles} }[ rand @{ $movie_info->{bubbles} } ];
}
else {
print "Sorry failed to find a movie titled [$said->{body}]";
}
}
__DATA__
RottenTomatoes plugin. Syntax, rt Movie Title.