2013-03-17 20:34:21 -07:00
|
|
|
package DDG::Goodie::Fortune;
|
2014-08-20 11:45:33 -07:00
|
|
|
# ABSTRACT: UNIX fortune quips.
|
2013-03-17 20:34:21 -07:00
|
|
|
|
2015-02-22 12:09:29 -08:00
|
|
|
use strict;
|
2013-03-17 20:34:21 -07:00
|
|
|
use DDG::Goodie;
|
|
|
|
use Fortune;
|
|
|
|
|
2014-10-14 11:52:56 -07:00
|
|
|
triggers startend => 'unix fortune', 'fortune cookie', 'random fortune';
|
2013-03-19 21:41:40 -07:00
|
|
|
|
2013-03-17 20:34:21 -07:00
|
|
|
zci answer_type => "fortune";
|
2014-10-14 11:52:56 -07:00
|
|
|
zci is_cached => 0;
|
2013-03-17 20:34:21 -07:00
|
|
|
|
2014-06-27 12:29:21 -07:00
|
|
|
my $ffile = share('fortunes');
|
|
|
|
my $fortune_file = Fortune->new($ffile);
|
2014-06-26 14:04:17 -07:00
|
|
|
$fortune_file->read_header();
|
|
|
|
|
2013-03-17 20:34:21 -07:00
|
|
|
handle remainder => sub {
|
2014-06-26 14:04:17 -07:00
|
|
|
my $output = $fortune_file->get_random_fortune();
|
2014-10-14 11:52:56 -07:00
|
|
|
$output =~ s/\n/ /g;
|
|
|
|
|
2016-05-15 12:01:11 -07:00
|
|
|
return $output, structured_answer => {
|
|
|
|
data => {
|
|
|
|
title => $output,
|
|
|
|
subtitle => "Random Fortune"
|
|
|
|
},
|
|
|
|
templates => {
|
|
|
|
group => 'text'
|
|
|
|
}
|
|
|
|
};
|
2013-03-17 20:34:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
1;
|