zeroclickinfo-goodies/lib/DDG/Goodie/HelpLine.pm

93 lines
3.0 KiB
Perl
Raw Normal View History

2013-06-21 13:34:59 -07:00
package DDG::Goodie::HelpLine;
2013-06-21 12:43:57 -07:00
use DDG::Goodie;
my @triggers = (
'suicide',
'suicide hotline',
'kill myself',
'suicidal thoughts',
'end my life',
'suicidal thoughts',
'suicidal',
'suicidal ideation',
'i want to kill myself',
'commit suicide',
2014-01-23 21:21:43 -08:00
'suicide pills',
'suicide pill',
'suicide prevention',
'kill myself',
'suicide phone number',
'suicide hot line',
'suicide lifeline',
'suicide life line',
'crisis intervention',
'i want to die',
'committing suicide',
'killing myself',
'hang myself',
'shoot myself',
'fastest way to kill myself',
'i\'m suicidal',
'how to make suicide pill',
'how to make suicide pills',
'make suicide pills',
'make suicide pill',
'best way to kill myself',
'easiest suicide method',
'i want to end my life',
2014-01-27 11:12:28 -08:00
'suicide help',
2014-01-27 11:21:39 -08:00
'suicide intervention',
'suicide method',
'suicide methods',
2014-01-27 13:51:13 -08:00
'how to kill myself',
'ways to kill myself',
);
triggers any => @triggers;
2013-06-21 12:43:57 -07:00
zci answer_type => 'helpline';
primary_example_queries 'suicide hotline';
2014-07-01 02:58:12 -07:00
description 'Checks if a query with the word "suicide" was made and returns a 24 hr suicide hotline.';
2013-06-21 12:43:57 -07:00
attribution github => ['https://github.com/conorfl', 'conorfl'],
twitter => '@areuhappylucia';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Helpline.pm';
topics 'everyday';
2013-06-21 13:34:59 -07:00
category 'special';
source 'https://en.wikipedia.org/wiki/List_of_suicide_crisis_lines';
2013-06-21 13:34:59 -07:00
my %helpline = (
# http://www.lifeline.org.au/Get-Help/I-Need-Help-Now and http://www.kidshelp.com.au/grownups/about-this-site.php
AU => ['13 11 14 or 1800 55 1800 (kids)', 'Australia'],
# http://www.suicidepreventionlifeline.org/ and http://org.kidshelpphone.ca/en
CA => ['1-800-273-8255 or 1-800-668-6868 (kids)', 'Canada'],
2014-07-01 02:58:12 -07:00
# http://samaritans.org.hk/24-hour-telephone-hotline (supports English, Cantonese and Mandarin)
HK => [ '2896 0000', 'Hong Kong'],
# http://www.samaritans.org/how-we-can-help-you/contact-us
IE => ['1850 60 90 90', 'Ireland'],
# http://www.lifeline.org.nz/corp_Home_378_2001.aspx
NZ => ['0800 543 354', 'New Zealand'],
# http://www.papyrus-uk.org/, http://www.samaritans.org/, and http://www.thecalmzone.net/help/helpline/helpline-nationwide/
GB => ['0800 068 41 41, 08457 90 90 90, or 0800 58 58 58', 'the UK'],
2014-07-01 02:58:12 -07:00
# http://www.samaritans.org.sg/contact/confide.htm#call_us
SG => ['1800-221 4444', 'Singapore'],
# http://www.suicidepreventionlifeline.org/
2014-01-29 12:15:35 -08:00
US => ['1-800-273-TALK (8255)', 'the U.S.'],
2013-06-21 13:34:59 -07:00
);
2013-06-21 12:43:57 -07:00
handle query_lc => sub {
my $query = shift;
# Check if the query matches exatly the trigger word.
my %suicide_phrases = map { $_ => 1 } @triggers;
return unless exists $suicide_phrases{$query};
# Display the result.
my $code = $loc->country_code;
return "24 Hour Suicide Hotline in " . $helpline{$code}[1] . ": " . $helpline{$code}[0]
if exists $helpline{$code}[0];
2013-06-21 12:43:57 -07:00
};
2013-06-21 13:34:59 -07:00
1;