/lib/DDG/Spice/Twitter.pm
https://github.com/pardocz/zeroclickinfo-spice · Perl · 35 lines · 28 code · 6 blank · 1 comment · 1 complexity · 6dd2b5e17f53b2e1a4300634f236f83e MD5 · raw file
- package DDG::Spice::Twitter;
- use DDG::Spice;
- primary_example_queries '@duckduckgo';
- secondary_example_queries "twitter yegg";
- description "Shows a user's latest tweet.";
- name "Twitter";
- code_url "https://github.com/duckduckgo/zeroclickinfo-spice/blob/master/lib/DDG/Spice/Twitter.pm";
- topics "everyday", "social";
- category "time_sensitive";
- attribution github => ["https://github.com/duckduckgo/", "DuckDuckGo"],
- twitter => ["https://twitter.com/duckduckgo", "duckduckgo"],
- github => ["https://github.com/ecounysis/", "Eric Christensen"],
- twitter => ["https://twitter.com/ecounysis", "Eric Christensen"];
- spice to => 'https://duckduckgo.com/tw.js?user=$1&callback={{callback}}¤t=1';
- triggers query => qr/^(?:twitter\s)?@([a-z0-9_]+)$|^twitter\s([a-z0-9_]+)$/i;
- # Possibly add skip words to a file for slurping?
- my $skip = join "|", ("apis?",
- "developers?",
- "users?",
- "search(es)?");
- handle matches => sub {
- if ($1) {
- return $1;
- } elsif ($2) {
- return $2 unless ($2 =~ m/^($skip)$/i)
- }
- return;
- };
- 1;