From 1646b325d9ad177a496415abb57662e80be731ac Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 9 Jul 2010 13:42:01 +0200 Subject: Reorder responses in /go command to work in debug mode, and add comments, in localkannel-dispatch. --- localkannel-dispatch | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'localkannel-dispatch') 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 -- cgit v1.2.3