PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/RandWord.pm

https://github.com/aembleton/zeroclickinfo-spice
Perl | 34 lines | 27 code | 7 blank | 0 comment | 2 complexity | 9bc982a930207074840142313dae23c2 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. status "enabled";
  14. spice is_cached => 0;
  15. spice from => '(?:([0-9]+)\-([0-9]+)|)';
  16. spice to => 'http://api.wordnik.com/v4/words.json/randomWord?minLength=$1&maxLength=$2&api_key={{ENV{DDG_SPICE_RANDWORD_APIKEY}}}&callback={{callback}}';
  17. spice proxy_cache_valid => "418 1d";
  18. triggers any => "random word";
  19. handle remainder => sub {
  20. if ($_ =~ /^([0-9]+\-[0-9]+)$/) {
  21. return $1;
  22. } else {
  23. return '0-100';
  24. }
  25. return;
  26. };
  27. 1;