summaryrefslogtreecommitdiff
path: root/localkannel-dispatch
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-07-09 13:42:01 +0200
committerJonas Smedegaard <dr@jones.dk>2010-07-09 13:42:01 +0200
commit1646b325d9ad177a496415abb57662e80be731ac (patch)
treed835748974cd987721dee1688b818ec900f5a67b /localkannel-dispatch
parent31deb77082a45e8ca2c39d2a089509137194538d (diff)
Reorder responses in /go command to work in debug mode, and add comments, in localkannel-dispatch.
Diffstat (limited to 'localkannel-dispatch')
-rwxr-xr-xlocalkannel-dispatch16
1 files changed, 10 insertions, 6 deletions
diff --git a/localkannel-dispatch b/localkannel-dispatch
index 4bbae96..a09987c 100755
--- a/localkannel-dispatch
+++ b/localkannel-dispatch
@@ -207,13 +207,12 @@ Respond \"pong\" and echo back any addition input."
/${realcmd}test PHONE MSG...
/$realcmd help
-Start thread \"$realcmd\" on behalf of PHONE.
-Send \"[$cmd] MSG...\" to ${realcmd}test subscribers."
+Send \"[$cmd] MSG...\" to ${realcmd}test subscribers,
+and start thread \"$realcmd\" on behalf of PHONE."
exit 0
fi
[ -n "$1" ] || exit1 "phone number missing (try \"/$cmd help\" for usage)"
[ -n "$2" ] || exit1 "message missing (try \"/$cmd help\" for usage)"
- targetphone="$(echo "$1" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"; shift
case "$cmd" in
gotest|sotest)
info1phone="+393453915741" # Jonas
@@ -226,8 +225,9 @@ Send \"[$cmd] MSG...\" to ${realcmd}test subscribers."
info3phone=
;;
esac
- targetfrom=$(lastservicephone "$targetphone")
- [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"."
+ targetphone="$(echo "$1" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"; shift
+
+ # Sanity check + set sender number
info1from=$(lastservicephone "$info1phone")
[ -n "$info1from" ] || exit1 "refusing to redirect: unknown info phone number \"$info1phone\"."
info2from=$(lastservicephone "$info2phone")
@@ -236,12 +236,16 @@ Send \"[$cmd] MSG...\" to ${realcmd}test subscribers."
info3from=$(lastservicephone "$info3phone")
[ -n "$info3from" ] || exit1 "refusing to redirect: unknown info phone number \"$info3phone\"."
fi
- SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "/$realcmd"
+ targetfrom=$(lastservicephone "$targetphone")
+ [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"."
+
+ # send responses (threaded one last, to work in debug mode)
SMS_PHONE="$info1from" $sbindir/localsendsms "$info1phone" "[$cmd] $@"
SMS_PHONE="$info2from" $sbindir/localsendsms "$info2phone" "[$cmd] $@"
if [ -n "$info3phone" ]; then
SMS_PHONE="$info3from" $sbindir/localsendsms "$info2phone" "[$cmd] $@"
fi
+ SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "/$realcmd"
exit 0
;;
esac