36 lines
1.0 KiB
Perl
36 lines
1.0 KiB
Perl
package DDG::Goodie::WhereAmI;
|
|
# ABSTRACT: Display the user's perceived location from GeoIP
|
|
|
|
use strict;
|
|
use DDG::Goodie;
|
|
|
|
zci is_cached => 0;
|
|
|
|
triggers start => 'where am i', 'my location', 'current location', 'my current location';
|
|
|
|
primary_example_queries 'Where am I?';
|
|
secondary_example_queries 'my location';
|
|
description 'display your perceived location';
|
|
name 'WhereAmI';
|
|
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/WhereAmI.pm';
|
|
category 'computing_tools';
|
|
topics 'travel';
|
|
attribution twitter => ['crazedpsyc', 'Michael Smith'],
|
|
cpan => ['CRZEDPSYC', 'Michael Smith'];
|
|
|
|
handle remainder => sub {
|
|
return if length($_) or !$loc or !$loc->city;
|
|
|
|
my $answer = 'Lat: ' . $loc->latitude . ', Lon: ' . $loc->longitude
|
|
. ' (near ' . join(', ', $loc->city, $loc->region || $loc->country_name) . ')';
|
|
|
|
return $answer,
|
|
structured_answer => {
|
|
input => [],
|
|
operation => 'Apparent current location',
|
|
result => $answer
|
|
};
|
|
};
|
|
|
|
1;
|