From c474d8759f93eeb29f5e82396650b9cba4e794b1 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 24 Sep 2010 16:41:03 +0200 Subject: Support multiple targetphones in go/so. --- localkannel-dispatch | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'localkannel-dispatch') diff --git a/localkannel-dispatch b/localkannel-dispatch index 33a3e0e..f342721 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -222,11 +222,11 @@ Respond \"pong\" and echo back any addition input." esac if [ "help" = "$1" ]; then $sbindir/localsendsms "$to" "Usage: -/$basecmd PHONE [MSG...] -/${basecmd}test PHONE [MSG...] +/$basecmd PHONE... [MSG...] +/${basecmd}test PHONE... [MSG...] /$basecmd help -Start thread \"$realcmd\" on behalf of PHONE, +Start thread \"$realcmd\" on behalf of each PHONE, and (if included) send MSG to subscribers." exit 0 fi @@ -239,22 +239,28 @@ and (if included) send MSG to subscribers." phones="$gophones" ;; esac - targetphone="$(echo "$1" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"; shift +# FIXME: Avoid hardcoding national prefix + while targetphone="$(echo "$1" | perl -pe 's/^(?=[^+])/+36/;' -e '/^\+\d+$/ or exit 1;')"; do + targetphones="${$targetphones:+$targetphones }$targetphone" + shift - # Sanity check + set sender number - targetfrom=$(lastservicephone "$targetphone") - [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." + # Sanity check + targetfrom=$(lastservicephone "$targetphone") + [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." + done # send responses (threaded one last, to work in debug mode) if [ -n "$*" ]; then for phone in $phones; do $sbindir/localsendsms "$phone" "[$cmd] $@" done - $sbindir/localsendsms "$to" "[info] \"$cmd\" thread started for \"$targetphone\", and trailing message forwarded to subscribers." + $sbindir/localsendsms "$to" "[info] \"$cmd\" thread started for $targetphones and trailing message forwarded to subscribers." else - $sbindir/localsendsms "$to" "[info] \"$cmd\" thread started for \"$targetphone\" (no trailing message, so nothing forwarded to subscribers)." + $sbindir/localsendsms "$to" "[info] \"$cmd\" thread started for $targetphones (no trailing message passed to subscribers)." fi - SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "$realcmd" + for phone in $targetphones; do + SMS_PHONE=$(lastservicephone "$phone") $sbindir/localmarkdown2sms "$phone" "$realcmd" + done exit 0 ;; esac -- cgit v1.2.3