/lib/DDG/Spice/RandWord.pm

https://github.com/pardocz/zeroclickinfo-spice · Perl · 31 lines · 25 code · 6 blank · 0 comment · 2 complexity · 50fbddde4567ee4c25fd6843bf901968 MD5 · raw file

  1. package DDG::Spice::RandWord;
  2. use DDG::Spice;
  3. name "Random Word";
  4. description "Generates a random word";
  5. source "WordNik";
  6. primary_example_queries "random word", "random word 5-10";
  7. category "random";
  8. topics "words_and_games", "everyday";
  9. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/RandWord.pm";
  10. icon_url "/i/wordnik.com.ico";
  11. attribution web => ['http://dylansserver.com','Dylan Lloyd'],
  12. email => ['dylan@dylansserver.com','Dylan Lloyd'];
  13. spice from => '(?:([0-9]+)\-([0-9]+)|)';
  14. spice to => 'http://api.wordnik.com/v4/words.json/randomWord?minLength=$1&maxLength=$2&api_key={{ENV{DDG_SPICE_RANDWORD_APIKEY}}}&callback={{callback}}';
  15. spice proxy_cache_valid => "418 1d";
  16. triggers any => "random word";
  17. handle remainder => sub {
  18. if ($_ =~ /^([0-9]+\-[0-9]+)$/) {
  19. return $1;
  20. } else {
  21. return '0-100';
  22. }
  23. return;
  24. };
  25. 1;