From 9565482b65cdb65c3e23e899959d338c702396d6 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Sun, 24 Jan 2021 22:08:44 +0100 Subject: [PATCH] small changes --- boot.sh | 2 +- func.sh | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/boot.sh b/boot.sh index 082e60a..e0baec7 100755 --- a/boot.sh +++ b/boot.sh @@ -9,4 +9,4 @@ pwd . config.sh . func.sh -send "Server%20started." +send "boot" "Server%20started." diff --git a/func.sh b/func.sh index 6a82c51..0020447 100755 --- a/func.sh +++ b/func.sh @@ -26,17 +26,24 @@ send() { #echo "Sending $2 to ${userid}" #request - raw=$(curl --data "${params}" "https://api.telegram.org/bot${token}/${method}" 2> /dev/null) + #raw=$(curl --data "${params}" "https://api.telegram.org/bot${token}/${method}" 2> /dev/null) + request="${apiurl}${token}/${method}" + #echo "request: $request - $params" + raw=$(curl --data "${params}" "${request}" -s 2> /dev/null) #parse response - #echo "recieved: $raw" + echo "recieved: $raw" msgid=$(python3 -c "import sys, json; print(json.loads('$raw'.replace('\n',''))['result']['message_id'])") - #echo "msgid: ${msgid}, count: ${count}" + if [ "$?" -ne "0" ]; then + resetFile + else + echo "msgid: ${msgid}, count: ${count}" - #write to file - echo "$1" > $fname #ident - echo "${msgid}" >> $fname #msgid - echo "${count}" >> $fname #count + #write to file + echo "$1" > $fname #ident + echo "${msgid}" >> $fname #msgid + echo "${count}" >> $fname #count + fi } #used to rset the file, when nothing is sent