Fix bot_auto_chatid: disable+stop daemon to prevent Restart=always from stealing updates

Made-with: Cursor
This commit is contained in:
anten-ka
2026-03-22 14:07:36 +03:00
parent 0b6c6875cf
commit 94006fe104

View File

@@ -1723,8 +1723,9 @@ bot_remove_admin() {
}
bot_auto_chatid() {
systemctl disable warp-bot 2>/dev/null
systemctl stop warp-bot 2>/dev/null
sleep 1
sleep 3
local flush_resp last_uid
flush_resp=$(curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getUpdates?offset=-1&limit=1")
last_uid=$(echo "$flush_resp" | jq -r '.result[-1].update_id // empty' 2>/dev/null)
@@ -1734,6 +1735,7 @@ bot_auto_chatid() {
echo -e "${YELLOW} Отправьте боту 3 любых сообщения в Telegram.${NC}"
echo -e "${YELLOW} Затем нажмите Enter.${NC}"
read -p " > " _
sleep 1
local resp; resp=$(curl -s --max-time 10 "https://api.telegram.org/bot${BOT_TOKEN}/getUpdates?limit=10")
local c; c=$(echo "$resp" | jq -r '[.result[].message.chat.id // empty] | map(select(. != "")) | unique | first // empty' 2>/dev/null)
if [ -n "$c" ] && [[ "$c" =~ ^[0-9-]+$ ]]; then