#!/bin/bash [ "${1}" == "stop" ] && { kill -SIGTERM "$(cat /tmp/tpdnsbot.pid)" 2>/dev/null exit 0 } printf "%s" "${$}" > /tmp/tpdnsbot.pid api_url="https://api.telegram.org/bot${TELEGRAM_DNS_TOKEN}/" botid="6040192441" bot_tmpdir="/tmp/tpdnsbot/" [ -d "${bot_tmpdir}" ] || { mkdir "${bot_tmpdir}" || { printf "error: can't write to /tmp\n" exit 2 } } exec 2>"${bot_tmpdir}/error.log" . ./bashbot-lib/bashbot-lib.sh . ./bashbot-lib/viewer.sh declare -a kbd_rows=( 1 ) declare -a kbd_text=( "check again" ) declare -a kbd_data=( "recheck" ) inline_kbd=$(mkinline_kbd kbd_rows kbd_text kbd_data) unset kbd_rows unset kbd_text unset kbd_data while [ "${1}" == "start" ]; do getupd >/dev/null || continue declare -A curmsg getmsg_content curmsg updates.txt 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 } done unset curmsg __ip done