From a7454b888c92be2d3271d3088ae456bf0aec5d7e Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 10 Jul 2010 11:33:25 +0200 Subject: Add optionally send warnings too at unrecognized keyword in localmarkdown2sms. --- localmarkdown2sms | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'localmarkdown2sms') diff --git a/localmarkdown2sms b/localmarkdown2sms index d44e728..1bcb181 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -43,6 +43,9 @@ my $sms_user = $ENV{SMS_USER} || "tester"; my $sms_pw = $ENV{SMS_PW} || "foobar"; my $sms_api = $ENV{SMS_API}; my $sms_phone = $ENV{SMS_PHONE}; +my $sms_errfrom = $ENV{SMS_ERRFROM} || $sms_phone; +my $sms_errto1 = $ENV{SMS_ERRTO1}; +my $sms_errto2 = $ENV{SMS_ERRTO2}; my $sms_smsc = $ENV{SMS_SMSC}; my $sms_msgtag = $ENV{SMS_MSGTAG} || "text"; my $sms_cp = $ENV{SMS_CP} || "utf8"; @@ -68,8 +71,13 @@ my ($key) = lc (shift @ARGV); # strip international prefix # (prefix is optional some places and illegal at other places - forgot where) -$phone =~ s/^\+//g if ($stripprefix); -$sms_phone =~ s/^\+//g if ($stripprefix); +if ($stripprefix) { + $phone =~ s/^\+//g; + $sms_phone =~ s/^\+//g; + $sms_errfrom =~ s/^\+//g; + $sms_errto1 =~ s/^\+//g; + $sms_errto2 =~ s/^\+//g; +} # strip non-word chars from keyword (and use only first chunk of word chars) $key =~ s/.*?(\w+).*?/$1/; @@ -243,6 +251,8 @@ if (0 == $num_children) { my $err_en = "Sorry, not recognized as a keyword: Please check spelling and try again."; my $err_it = "Spiacente, non riconosco come parola chiave: Controlla l'ortografia e riprova."; &sendmsg($sms_phone, $phone, "fallback message", "$key?\n$err_it\n$err_en"); + ($sms_errto1) and &sendmsg($sms_errfrom, $sms_errto1, "warning", "[warning] $phone wrote: $key"); + ($sms_errto2) and &sendmsg($sms_errfrom, $sms_errto2, "warning", "[warning] $phone wrote: $key"); exit; } -- cgit v1.2.3