2023-03-21 18:36:20 -03:00
|
|
|
#!/bin/bash
|
2023-03-21 18:44:50 -03:00
|
|
|
[ "${1}" == "stop" ] && {
|
|
|
|
kill -SIGTERM "$(cat /tmp/tpdnsbot.pid)" 2>/dev/null
|
|
|
|
exit 0
|
|
|
|
}
|
2023-03-21 18:36:20 -03:00
|
|
|
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
|
|
|
|
|
|
|
|
while [ "${1}" == "start" ]; do
|
2023-03-22 19:09:33 -03:00
|
|
|
getupd >/dev/null || continue
|
2023-03-21 18:36:20 -03:00
|
|
|
declare -A curmsg
|
2023-03-22 08:19:55 -03:00
|
|
|
getmsg_content curmsg updates.txt
|
2023-03-21 18:36:20 -03:00
|
|
|
view_content curmsg
|
2023-03-22 11:42:20 -03:00
|
|
|
for i in $(awk '{print $1}' ./allowed_ids.txt); do
|
2023-03-22 19:09:33 -03:00
|
|
|
[ "${curmsg[user_id]}" == "${i}" ] && {
|
|
|
|
[ "${curmsg[callback]}" == "recheck" ] || [ "${curmsg[text]}" == "/start" ]
|
|
|
|
} && {
|
2023-03-22 11:42:20 -03:00
|
|
|
sendmsg "${curmsg[chat_id]}" $(./getip.sh "${bot_tmpdir}")
|
|
|
|
unset curmsg
|
|
|
|
declare -A curmsg
|
|
|
|
getmsg_content curmsg sentmsgs.txt
|
|
|
|
tput setaf 3; view_content curmsg; tput sgr0
|
|
|
|
}
|
|
|
|
done
|
2023-03-21 18:36:20 -03:00
|
|
|
unset curmsg
|
|
|
|
done
|