summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalkannel-dispatch26
1 files changed, 16 insertions, 10 deletions
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