Auto-update existing Telegram bot during upgrade

This commit is contained in:
Виталий Литвинов
2026-04-26 10:51:30 +03:00
parent ffea9f5d77
commit 7bb88f2c24
2 changed files with 44 additions and 0 deletions

View File

@@ -963,6 +963,31 @@ bot_service_status() {
fi
}
auto_update_bot_if_possible() {
[ -d "$SCRIPT_DIR/gotelegram-bot" ] || return 0
[ "$(bot_service_status)" = "not_installed" ] && return 0
[ -f "$BOT_DIR/.env" ] || return 0
local needs_update=0
[ -f "$SCRIPT_DIR/gotelegram-bot/bot.py" ] && \
! cmp -s "$SCRIPT_DIR/gotelegram-bot/bot.py" "$BOT_DIR/bot.py" && needs_update=1
[ -f "$SCRIPT_DIR/gotelegram-bot/i18n.py" ] && \
! cmp -s "$SCRIPT_DIR/gotelegram-bot/i18n.py" "$BOT_DIR/i18n.py" && needs_update=1
[ -f "$SCRIPT_DIR/gotelegram-bot/requirements.txt" ] && \
! cmp -s "$SCRIPT_DIR/gotelegram-bot/requirements.txt" "$BOT_DIR/requirements.txt" && needs_update=1
local lang_file lang_name
for lang_file in "$SCRIPT_DIR"/gotelegram-bot/lang/*.json; do
[ -e "$lang_file" ] || continue
lang_name=$(basename "$lang_file")
! cmp -s "$lang_file" "$BOT_DIR/lang/$lang_name" && needs_update=1
done
[ "$needs_update" = "1" ] || return 0
bot_install >/dev/null 2>&1 || \
log_warning "Telegram bot auto-update failed; run menu 12 → Telegram-bot → Install/update"
}
menu_bot() {
local st
st=$(bot_service_status)
@@ -1788,6 +1813,7 @@ main() {
fi
auto_migrate_legacy_state || true
auto_update_bot_if_possible || true
auto_install_admin_web_if_possible || true
# First-run language picker (before banner so banner appears in chosen lang)