From 554e5b0e88d2cebdd54737beb2fd19cc148354cd Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Fri, 9 Jul 2010 13:16:19 +0200 Subject: Merge commands /go and /gonetest and extend with /so and /sotest, in localkannel-dispatch. --- localkannel-dispatch | 78 +++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/localkannel-dispatch b/localkannel-dispatch index e9e0c7e..7501886 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -191,59 +191,57 @@ Respond \"pong\" and echo back any addition input." $sbindir/localsendsms "$to" pong "$@" exit 0 ;; -# FIXME: generalize these ugly hacks somehow, and secure against random use - go) +# FIXME: generalize this ugly hacks somehow, and secure against random use + go|gotest|so|sotest) + case "$1" in + go*) + realcmd="go" + ;; + so*) + realcmd="so" + ;; + esac if [ "help" = "$1" ]; then $sbindir/localsendsms "$to" "Usage: -/go PHONE MSG... +/$realcmd PHONE MSG... +/${realcmd}test PHONE MSG... +/$realcmd help -Start thread \"go\" on behalf of PHONE. -Send \"[go] MSG\" to Alessandra and Vela." +Start thread \"$realcmd\" on behalf of PHONE. +Send \"[$cmd] MSG...\" to ${realcmd}test subscribers." exit 0 fi - [ -n "$1" ] || exit1 "phone number missing (try \"/go help\" for usage)" - [ -n "$2" ] || exit1 "message missing (try \"/go help\" for usage)" + [ -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 - info1phone="+393273009765" # Alessandra - info2phone="+393276733618" # Vela + case "$1" in + gotest|sotest) + info1phone="+393453915741" # Jonas + info2phone="+393453805531" # Jacob + info3phone="+393453801457" # Vera + ;; + go|so) + info1phone="+393273009765" # Alessandra + info2phone="+393276733618" # Vela + info3phone= + ;; + esac targetfrom=$(lastservicephone "$targetphone") [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." info1from=$(lastservicephone "$info1phone") [ -n "$info1from" ] || exit1 "refusing to redirect: unknown info phone number \"$info1phone\"." info2from=$(lastservicephone "$info2phone") [ -n "$info2from" ] || exit1 "refusing to redirect: unknown info phone number \"$info2phone\"." - SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "/go" - SMS_PHONE="$info1from" $sbindir/localsendsms "$info1phone" "[go] $@" - SMS_PHONE="$info2from" $sbindir/localsendsms "$info2phone" "[go] $@" - exit 0 - ;; - gotest) - if [ "help" = "$1" ]; then - $sbindir/localsendsms "$to" "Usage: -/gotest PHONE MSG... - -Start thread \"go\" on behalf of PHONE. -Report MSG to Jonas, Jacob and Vera." - exit 0 + if [ -n "$info3phone" ]; then + info3from=$(lastservicephone "$info3phone") + [ -n "$info3from" ] || exit1 "refusing to redirect: unknown info phone number \"$info3phone\"." + fi + SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "/$realcmd" + 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 - [ -n "$1" ] || exit1 "phone number missing (try \"/go help\" for usage)" - [ -n "$2" ] || exit1 "message missing (try \"/go help\" for usage)" - targetphone="$(echo "$1" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"; shift - info1phone="+393453915741" # Jonas - info2phone="+393453805531" # Jacob - info3phone="+393453801457" # Vera - targetfrom=$(lastservicephone "$targetphone") - [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." - info1from=$(lastservicephone "$info1phone") - [ -n "$info1from" ] || exit1 "refusing to redirect: unknown info phone number \"$info1phone\"." - info2from=$(lastservicephone "$info2phone") - [ -n "$info2from" ] || exit1 "refusing to redirect: unknown info phone number \"$info2phone\"." - info3from=$(lastservicephone "$info3phone") - [ -n "$info3from" ] || exit1 "refusing to redirect: unknown info phone number \"$info3phone\"." - SMS_PHONE="$targetfrom" $sbindir/localmarkdown2sms "$targetphone" "/go" - SMS_PHONE="$info1from" $sbindir/localsendsms "$info1phone" "[go] $@" - SMS_PHONE="$info2from" $sbindir/localsendsms "$info2phone" "[go] $@" - SMS_PHONE="$info3from" $sbindir/localsendsms "$info3phone" "[go] $@" exit 0 ;; esac -- cgit v1.2.3