summaryrefslogtreecommitdiff
path: root/localkannel-dispatch
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-24 16:41:03 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-24 16:41:03 +0200
commitc474d8759f93eeb29f5e82396650b9cba4e794b1 (patch)
treee94a42c0a111004808f2223325dff1d8c51e1976 /localkannel-dispatch
parent46cca23c06d0c209f64a69a058f5e86994598325 (diff)
Support multiple targetphones in go/so.
Diffstat (limited to 'localkannel-dispatch')
-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