0.0.9 minor verbose fix

This commit is contained in:
Franz Rolfsvaag 2025-08-10 03:58:27 +02:00
parent 83100e4e77
commit 9fcd55ec4b

35
bot.py
View File

@ -9,6 +9,8 @@ import pathlib
import os, asyncio, xml.etree.ElementTree as ET import os, asyncio, xml.etree.ElementTree as ET
import aiohttp import aiohttp
VERSION="0.0.9"
# ---------- Env & config loading ---------- # ---------- Env & config loading ----------
load_dotenv() load_dotenv()
@ -129,39 +131,8 @@ async def _fetch_latest_from_rss(url: str):
# ---------- boot notice ---------- # ---------- boot notice ----------
async def _post_boot_notice(): async def _post_boot_notice():
# 1) try build files
commit = None
subject = None
try:
with open("/app/.build_commit", "r") as f:
commit = f.read().strip()
except Exception:
pass
try:
with open("/app/.build_subject", "r") as f:
subject = f.read().strip()
except Exception:
pass
# 2) env fallback msg = f"Self-update and reboot successful! (v.{VERSION})"
if not commit:
commit = os.getenv("SHAI_BUILD_COMMIT", "").strip() or None
if not subject:
subject = os.getenv("SHAI_BUILD_SUBJECT", "").strip() or None
# 3) RSS fallback (optional, set SHAI_GIT_RSS to enable; default to your repo)
if (not commit or not subject):
rss_url = os.getenv("SHAI_GIT_RSS", "https://git.rolfsvaag.no/frarol96/shaiwatcher.rss").strip()
if rss_url:
sub2, sha2 = await _fetch_latest_from_rss(rss_url)
subject = subject or sub2
commit = commit or sha2
msg = "Self-update and reboot successful!"
if subject and len(subject) > 5:
msg += f"{subject}"
if commit:
msg += f" (`{commit}`)"
ch_id_raw = bot.config['DEFAULT'].get('modlog_channel_id', '') ch_id_raw = bot.config['DEFAULT'].get('modlog_channel_id', '')
try: try: