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 d7e10bc9eb
commit b094fe043e
2 changed files with 30 additions and 11 deletions

@ -1 +1 @@
Subproject commit dc0cf65d2c3e5efd8e5d117118e41e9768116d41
Subproject commit 601128b8561c1b5d112eba8cf28878f25440b0e1

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