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
|
|
|
|
|
|
|
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
|
|
|
|
2014-10-14 11:52:56 -07:00
|
|
|
primary_example_queries 'fortune cookie', 'random fortune';
|
2013-03-19 21:41:40 -07:00
|
|
|
name 'Fortune';
|
|
|
|
description 'get a random phrase from the original fortunes file';
|
|
|
|
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Fortune.pm';
|
|
|
|
category 'random';
|
|
|
|
topics 'words_and_games';
|
2014-11-07 12:43:25 -08:00
|
|
|
attribution github => ['https://github.com/frncscgmz', 'frncscgmz'],
|
|
|
|
github => ['https://github.com/dmschulman', 'dmschulman'];
|
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;
|
|
|
|
|
|
|
|
return $output,
|
|
|
|
structured_answer => {
|
|
|
|
input => [],
|
2015-01-09 00:01:04 -08:00
|
|
|
operation => 'Random fortune',
|
2014-10-14 11:52:56 -07:00
|
|
|
result => $output
|
|
|
|
};
|
2013-03-17 20:34:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
1;
|