diff --git a/.gitignore b/.gitignore index 4c890d4..7f19591 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ count token *.save +*.log +JSON.sh/* +tmp-bot-bash/ diff --git a/README.md b/README.md index 1c32671..9751fbf 100644 --- a/README.md +++ b/README.md @@ -445,4 +445,4 @@ No - its not more or less insecure as any other Bot written in any other languag If you feel that there's something missing or if you found a bug, feel free to submit a pull request! -#### $$VERSION$$ v0.49-1-g851be83 +#### $$VERSION$$ v0.49-4-g8e08c1f diff --git a/bashbot.cron b/bashbot.cron index 54de6ed..4a5af80 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.49-2-g0a90edb +#### $$VERSION$$ v0.49-4-g8e08c1f SHELL=/bin/sh diff --git a/bashbot.rc b/bashbot.rc index 27791ae..9f71898 100755 --- a/bashbot.rc +++ b/bashbot.rc @@ -1,7 +1,7 @@ #!/bin/sh # description: Start or stop telegram-bash-bot # -#### $$VERSION$$ v0.49-2-g0a90edb +#### $$VERSION$$ v0.49-4-g8e08c1f # ### BEGIN INIT INFO # Provides: bashbot diff --git a/bashbot.sh b/bashbot.sh index 6cab0b3..2da6cad 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.49-4-g8e08c1f +#### $$VERSION$$ v0.49-9-gb27017f # get location of bashbot.sh an change to bashbot dir SCRIPT="./$(basename $0)" @@ -458,17 +458,17 @@ process_client() { fi # Audio - URLS[AUDIO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")" + URLS[AUDIO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","audio","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Document - URLS[DOCUMENT]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","document","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")" + URLS[DOCUMENT]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","document","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Photo - URLS[PHOTO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","photo",.*,"file_id"\]' | cut -f 2 | cut -d '"' -f 2 | sed -n '$p')")" + URLS[PHOTO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","photo",.*,"file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Sticker - URLS[STICKER]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","sticker","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")" + URLS[STICKER]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","sticker","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Video - URLS[VIDEO]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","video","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")" + URLS[VIDEO]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","video","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Voice - URLS[VOICE]="$(get_file "$(echo "$UPDATE" | egrep '\["result",'$PROCESS_NUMBER',"message","voice","file_id"\]' | cut -f 2 | cut -d '"' -f 2)")" + URLS[VOICE]="$(get_file "$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","voice","file_id"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")")" # Contact CONTACT[NUMBER]="$(sed -n -e '/\["result",'$PROCESS_NUMBER',"message","contact","phone_number"\]/ s/.*\][ \t]"\(.*\)"$/\1/p' <"$TMP")" diff --git a/commands.sh b/commands.sh index 64eec74..264e7c9 100755 --- a/commands.sh +++ b/commands.sh @@ -4,25 +4,28 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.49-1-g851be83 +#### $$VERSION$$ v0.49-4-g8e08c1f # adjust your language setting here, e.g.when run from other user or cron. # 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 +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 if [ "$1" = "source" ];then # Place the token in the token file - TOKEN=$(cat token) + TOKEN="$(cat token)" # Set INLINE to 1 in order to receive inline queries. # To enable this option in your bot, send the /setinline command to @BotFather. - INLINE=0 + INLINE="0" # Set to .* to allow sending files from all locations FILE_REGEX='/home/user/allowed/.*' else - if ! tmux ls | grep -v send | grep -q $copname; then - [ ! -z ${URLS[*]} ] && { + if ! tmux ls | grep -v send | grep -q "$copname"; then + [ ! -z "${URLS[*]}" ] && { curl -s ${URLS[*]} -o $NAME send_file "${CHAT[ID]}" "$NAME" "$CAPTION" rm -f "$NAME" @@ -32,25 +35,25 @@ else # Inline if [ $INLINE == 1 ]; then # inline query data - iUSER[FIRST_NAME]=$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1) - iUSER[LAST_NAME]=$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3) - iUSER[USERNAME]=$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1) - iQUERY_ID=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1) - iQUERY_MSG=$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1) + iUSER[FIRST_NAME]="$(echo "$res" | sed 's/^.*\(first_name.*\)/\1/g' | cut -d '"' -f3 | tail -1)" + iUSER[LAST_NAME]="$(echo "$res" | sed 's/^.*\(last_name.*\)/\1/g' | cut -d '"' -f3)" + iUSER[USERNAME]="$(echo "$res" | sed 's/^.*\(username.*\)/\1/g' | cut -d '"' -f3 | tail -1)" + iQUERY_ID="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -1)" + iQUERY_MSG="$(echo "$res" | sed 's/^.*\(inline_query.*\)/\1/g' | cut -d '"' -f5 | tail -6 | head -1)" # Inline examples - if [[ $iQUERY_MSG == photo ]]; then + if [[ "$iQUERY_MSG" == "photo" ]]; then answer_inline_query "$iQUERY_ID" "photo" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" "http://blog.techhysahil.com/wp-content/uploads/2016/01/Bash_Scripting.jpeg" fi - if [[ $iQUERY_MSG == sticker ]]; then + if [[ "$iQUERY_MSG" == "sticker" ]]; then answer_inline_query "$iQUERY_ID" "cached_sticker" "BQADBAAD_QEAAiSFLwABWSYyiuj-g4AC" fi - if [[ $iQUERY_MSG == gif ]]; then + if [[ "$iQUERY_MSG" == "gif" ]]; then answer_inline_query "$iQUERY_ID" "cached_gif" "BQADBAADIwYAAmwsDAABlIia56QGP0YC" fi - if [[ $iQUERY_MSG == web ]]; then + if [[ "$iQUERY_MSG" == "web" ]]; then answer_inline_query "$iQUERY_ID" "article" "GitHub" "http://github.com/topkecleon/telegram-bot-bash" fi fi & diff --git a/notify b/notify index 5c25f19..347b395 100755 --- a/notify +++ b/notify @@ -2,7 +2,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.49-3-g6f1c328 +#### $$VERSION$$ v0.49-4-g8e08c1f # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/question b/question index b1945df..62edfbf 100755 --- a/question +++ b/question @@ -3,7 +3,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.49-2-g0a90edb +#### $$VERSION$$ v0.49-4-g8e08c1f # adjust your language setting here # https://github.com/topkecleon/telegram-bot-bash#setting-up-your-environment diff --git a/version b/version index af54773..0f23783 100755 --- a/version +++ b/version @@ -1,6 +1,6 @@ #!/bin/sh # -#### $$VERSION$$ v0.49-2-g0a90edb +#### $$VERSION$$ v0.49-4-g8e08c1f # # Easy Versioning in git: #