mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 18:35:49 -04:00
27 lines
593 B
Text
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.
|