diff --git a/bashbot-lib b/bashbot-lib index dc0cf65..601128b 160000 --- a/bashbot-lib +++ b/bashbot-lib @@ -1 +1 @@ -Subproject commit dc0cf65d2c3e5efd8e5d117118e41e9768116d41 +Subproject commit 601128b8561c1b5d112eba8cf28878f25440b0e1 diff --git a/bot.sh b/bot.sh index 94384e9..455cee5 100755 --- a/bot.sh +++ b/bot.sh @@ -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