added server status checking, different processing for callback and fixed error.log getting overwritten

This commit is contained in:
celso 2023-03-27 00:46:10 -03:00
parent 166ee8ce80
commit 70eb9fedb1
2 changed files with 30 additions and 11 deletions

@ -1 +1 @@
Subproject commit d5adbdec110a4e655e28176260255b6f2690a106
Subproject commit 703351e14a5b98b64db055d792390fbf7e4da66e

39
bot.sh
View File

@ -15,7 +15,7 @@ bot_tmpdir="/tmp/tpdnsbot/"
}
}
exec 2>"${bot_tmpdir}/error.log"
exec 2>>"${bot_tmpdir}/error.log"
. ./bashbot-lib/bashbot-lib.sh
. ./bashbot-lib/viewer.sh
@ -35,15 +35,34 @@ while [ "${1}" == "start" ]; do
view_content curmsg
for i in $(awk '{print $1}' ./allowed_ids.txt); do
[ "${curmsg[user_id]}" == "${i}" ] && {
[ "${curmsg[callback]}" == "recheck" ] || [ "${curmsg[text]}" == "/start" ]
} && {
__ip=$(./getip.sh "${bot_tmpdir}")
sendmsg "${curmsg[chat_id]}" "${__ip}%0Asyncplay: port 60000%0Acstrike: port 64000" "${inline_kbd}"
unset curmsg
declare -A curmsg
getmsg_content curmsg sentmsgs.txt
tput setaf 3; view_content curmsg; tput sgr0
[ "${curmsg[callback]}" == "recheck" ] && {
editmsg "${curmsg[chat_id]}" "${curmsg[msg_id]}" "checking again."
__ip="$(./getip.sh "${bot_tmpdir}")"
editmsg "${curmsg[chat_id]}" "${curmsg[msg_id]}" "checking again.."
ps -w -w -U syncplay -o args= | grep "syncplay-server" >/dev/null \
&& __syncplay_status="online" || __syncplay_status="offline"
editmsg "${curmsg[chat_id]}" "${curmsg[msg_id]}" "checking again..."
ps -w -w -U steam -o args= | grep "hlds_run" >/dev/null \
&& __cstrike_status="online" || __cstrike_status="offline"
editmsg "${curmsg[chat_id]}" "${curmsg[msg_id]}" "${__ip}%0Asyncplay(${__syncplay_status}): port 60000%0Acstrike(${__cstrike_status}): port 64000" "${inline_kbd}"
unset curmsg
declare -A curmsg
getmsg_content curmsg sentmsgs.txt
tput setaf 3; view_content curmsg; tput sgr0
}
[ "${curmsg[text]}" == "/start" ] && {
__ip="$(./getip.sh "${bot_tmpdir}")"
ps -w -w -U syncplay -o args= | grep "syncplay-server" >/dev/null\
&& __syncplay_status="online" || __syncplay_status="offline"
ps -w -w -U steam -o args= | grep "hlds_run" >/dev/null\
&& __cstrike_status="online" || __cstrike_status="offline"
sendmsg "${curmsg[chat_id]}" "${__ip}%0Asyncplay(${__syncplay_status}): port 60000%0Acstrike(${__cstrike_status}): port 64000" "${inline_kbd}"
unset curmsg
declare -A curmsg
getmsg_content curmsg sentmsgs.txt
tput setaf 3; view_content curmsg; tput sgr0
}
}
done
unset curmsg __ip
unset curmsg __ip __syncplay_status __cstrike_status
done