From 7e75b92261ada6d67baa5bf3ac08f106ae8499db Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 14 Apr 2019 20:30:59 +0200 Subject: [PATCH] new interactive command calc --- bashbot.cron | 2 +- bashbot.rc | 2 +- bashbot.sh | 4 ++-- calc | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 calc diff --git a/bashbot.cron b/bashbot.cron index a608261..770c393 100644 --- a/bashbot.cron +++ b/bashbot.cron @@ -7,7 +7,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-dev3-0-g2550aec +#### $$VERSION$$ v0.60-dev3-8-gdec3150 SHELL=/bin/sh diff --git a/bashbot.rc b/bashbot.rc index ebf016e..8625dba 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.60-dev3-0-g2550aec +#### $$VERSION$$ v0.60-dev3-8-gdec3150 # shellcheck disable=SC2009 # shellcheck disable=SC2181 diff --git a/bashbot.sh b/bashbot.sh index 4b2e142..a3e6dfe 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -10,7 +10,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.60-dev3-6-g5787908 +#### $$VERSION$$ v0.60-dev3-8-gdec3150 # # Exit Codes: # - 0 sucess (hopefully) @@ -457,7 +457,7 @@ background() { startproc() { killproc "$2" - local fifo="$2${copname}" # add $1 to copname, so we can have more than one running script per chat + local fifo="$2${copname}" mkfifo "${TMPDIR:-.}/${fifo}" tmux new-session -d -s "${fifo}" "$1 &>${TMPDIR:-.}/${fifo}; echo imprettydarnsuredatdisisdaendofdacmd>${TMPDIR:-.}/${fifo}" tmux new-session -d -s "sendprocess_${fifo}" "bash $SCRIPT outproc ${CHAT[ID]} ${fifo}" diff --git a/calc b/calc new file mode 100755 index 0000000..f5f9260 --- /dev/null +++ b/calc @@ -0,0 +1,33 @@ +#!/bin/bash + +# This file is public domain in the USA and all free countries. +# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) + +#### $$VERSION$$ v0.60-dev3-8-gdec3150 + +# adjust your language setting here +# https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment +export 'LC_ALL=C.UTF-8' +export 'LANG=C.UTF-8' +export 'LANGUAGE=C.UTF-8' + +unset IFS +# set -f # if you are paranoid use set -f to disable globbing + +echo 'Starting Calculator ...' +echo 'Enter first number.' +read -r A +echo 'Enter second number.' +read -r B +echo 'Select Operation: mykeyboardstartshere "Addition" "Subtraction" "Multiplication" "Division" "Cancel"' +read -r opt +echo -n 'Result: ' +case $opt in + 'add'* | 'Add'* ) expr $A + $B ;; + 'sub'* | 'Sub'* ) expr $A - $B ;; + 'mul'* | 'Mul'* ) expr $A \* $B ;; + 'div'* | 'Div'* ) expr $A / $B ;; + 'can'* | 'Can'* ) echo "abort!" ;; + * ) echo "unknown operator!";; +esac +echo "Bye .."