PageRenderTime 36ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/DDG/Spice/Drinks.pm

https://github.com/robertbrook/zeroclickinfo-spice
Perl | 31 lines | 24 code | 7 blank | 0 comment | 4 complexity | cb77f77211543302764dd9f84e489feb MD5 | raw file
  1. package DDG::Spice::Drinks;
  2. use DDG::Spice;
  3. primary_example_queries "how to mix a tom collins";
  4. secondary_example_queries "mixing 007", "how to make a 1.21 gigawatts";
  5. description "Bartending info";
  6. name "Drinks";
  7. source "Drink Project";
  8. code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Drinks.pm";
  9. topics "food_and_drink";
  10. category "entertainment";
  11. attribution github => ['https://github.com/mutilator','mutilator'];
  12. triggers any => "drink", "make", "mix", "recipe", "ingredients";
  13. triggers start => "mixing", "making";
  14. spice to => 'http://drinkproject.com/api/?type=json&name=$1&callback={{callback}}';
  15. handle query_lc => sub {
  16. if (/^((((making|mixing)+|(how\sto\s(make|mix)+)+)+(\s(a|an|the)*)*)|(mixed\s+)*drink(\s+(recipe|mix))*)+\s+(.+)$/) {
  17. return $12 if $12;
  18. }
  19. if (/^(.+)\s+(drink|mixed)\s(drink|mix|recipe|ingredients)$/) {
  20. return $1 if $1;
  21. }
  22. return;
  23. };
  24. 1;