diff --git a/bashbot-lib b/bashbot-lib index d5adbde..703351e 160000 --- a/bashbot-lib +++ b/bashbot-lib @@ -1 +1 @@ -Subproject commit d5adbdec110a4e655e28176260255b6f2690a106 +Subproject commit 703351e14a5b98b64db055d792390fbf7e4da66e 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