|
|
|
@ -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 |
|
|
|
|