From e9b50cc1579e9f9abf5f28914fb9f7121595153a Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 8 Jul 2010 11:23:36 +0200 Subject: Add /gone and /gonetest hacks to localkannel-dispatch. --- localkannel-dispatch | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'localkannel-dispatch') diff --git a/localkannel-dispatch b/localkannel-dispatch index 792b561..0e69cfb 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -191,6 +191,61 @@ 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 + gone) + if [ "help" = "$1" ]; then + $sbindir/localsendsms "$to" "Usage: +/gone PHONE MSG... + +Start thread \"gone\" on behalf of PHONE. +Send \"[gone] MSG\" to Alessandra and Vela." + exit 0 + fi + [ -n "$1" ] || exit1 "phone number missing (try \"/gone help\" for usage)" + [ -n "$2" ] || exit1 "message missing (try \"/gone help\" for usage)" + targetphone="$(echo "$1" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')"; shift + info1phone="+393273009765" # Alessandra + info2phone="+393276733618" # Vela + 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" "/gone" + SMS_PHONE="$info1from" $sbindir/localmarkdown2sms "$info1phone" "[gone] $@" + SMS_PHONE="$info2from" $sbindir/localmarkdown2sms "$info2phone" "[gone] $@" + exit 0 + ;; + gonetest) + if [ "help" = "$1" ]; then + $sbindir/localsendsms "$from" "Usage: +/gone PHONE MSG... + +Start thread \"gone\" on behalf of PHONE. +Report MSG to Jonas, Jacob and Vera." + exit 0 + fi + [ -n "$1" ] || exit1 "phone number missing (try \"/gone help\" for usage)" + [ -n "$2" ] || exit1 "message missing (try \"/gone 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" "/gone" + SMS_PHONE="$info1from" $sbindir/localmarkdown2sms "$info1phone" "[gone] $@" + SMS_PHONE="$info2from" $sbindir/localmarkdown2sms "$info2phone" "[gone] $@" + SMS_PHONE="$info3from" $sbindir/localmarkdown2sms "$info3phone" "[gone] $@" + exit 0 + ;; esac candidates=$(cd "$vardir/user" && grep -lF "$to" */phone | perl -pe "s,/phone$,,") || candidates= [ -z "$candidates" ] || $(grep -vqF "$candidates" "$vardir/group/admin/user") || admin=true -- cgit v1.2.3