From 7fd4dd5d86074afc6acb0375e2d20e28584c2327 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 9 Jul 2010 16:48:16 +0200 Subject: Improve sendsmg() in localmarkdown2sms and localsendsms to use $from and $to (not us $sms_phone and reuse $phone). --- localmarkdown2sms | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'localmarkdown2sms') diff --git a/localmarkdown2sms b/localmarkdown2sms index 5afdd89..0ba1622 100755 --- a/localmarkdown2sms +++ b/localmarkdown2sms @@ -204,7 +204,7 @@ sub transliterate { } sub sendmsg { - my ($phone, $desc, $msg) = @_; + my ($from, $to, $desc, $msg) = @_; unless ($dummy) { my $ua = LWP::UserAgent->new(agent => "localmarkdown2sms"); @@ -212,9 +212,9 @@ sub sendmsg { my $url = $sms_url . '?' . $sms_usertag . '=' . uri_escape($sms_user) . '&password=' . uri_escape($sms_pw) - . '&to=' . uri_escape($phone); + . '&to=' . uri_escape($to); $url .= '&api_id=' . uri_escape($sms_api) if ($sms_api); - $url .= '&from=' . uri_escape($sms_phone) if ($sms_phone); + $url .= '&from=' . uri_escape($from) if ($from); $url .= '&smsc=' . uri_escape($sms_smsc) if ($sms_smsc); $url .= '&concatenation=true' if ($sms_concatenation); $url .= '&concat=' . uri_escape($sms_concat) if ($sms_concat); @@ -232,7 +232,7 @@ sub sendmsg { } DEBUG "Done $desc"; } else { - print STDERR "\n --> $phone: $desc\n"; + print STDERR "\n [$from --> $to: $desc]\n\n"; print STDERR $msg . "\n"; } } @@ -242,7 +242,7 @@ my $num_children = $#{ $reply{$key} } + 1; # How many children we'll create if (0 == $num_children) { my $err_en = "Sorry, I don't recognize \"$key\" as a keyword: Please check spelling and try again."; my $err_it = "Spiacente, non riconosco \"$key\" come parola chiave.\nControlla che sia corretta e riprova."; - &sendmsg($phone, "fallback message", $err_it . "\n" . $err_en); + &sendmsg($sms_phone, $phone, "fallback message", $err_it . "\n" . $err_en); exit; } @@ -255,7 +255,7 @@ if ($debug) { } for my $num ( 0 .. $num_children - 1 ) { sleep($delay{$key}[$num]) unless ($nosleep); - &sendmsg($phone, "reply #$num [" . $delay{$key}[$num] . "s]", $reply{$key}[$num]); + &sendmsg($sms_phone, $phone, "reply #$num [" . $delay{$key}[$num] . "s]", $reply{$key}[$num]); } 1; -- cgit v1.2.3