fix: Basti-Benachrichtigung via Dateisystem statt Telegram

- notify_basti() schreibt .md-Dateien nach fehler-server/eingang/
- Format: YYYYMMDD-HHMMSS_ID.md mit Artikel-Link und Fehlerbeschreibung
- Keine externe API nötig, funktioniert offline
This commit is contained in:
Hermes Agent
2026-07-09 16:39:40 +02:00
parent 6571254e52
commit 589705d6c5
3 changed files with 39 additions and 24 deletions
+27 -24
View File
@@ -89,35 +89,38 @@ def update_status(rid, status, loesung):
conn.close()
# ═══════════════════════════════════════════════════
# Telegram
# Basti-Benachrichtigung (Datei-basiert)
# ═══════════════════════════════════════════════════
FEHLER_EINGANG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "eingang")
def notify_basti(report_id, article_id, name, text):
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
return
"""Schreibt Fehlermeldung als .md-Datei für Basti."""
os.makedirs(FEHLER_EINGANG, exist_ok=True)
ts = datetime.now().strftime("%Y%m%d-%H%M%S")
fname = f"{ts}_{report_id}.md"
fpath = os.path.join(FEHLER_EINGANG, fname)
preview = text[:300] + ("" if len(text) > 300 else "")
msg = (
f"\U0001f41b *Neue Fehlermeldung* \\#{report_id}\n\n"
f"\U0001f4f0 *Artikel:* \\#{article_id}\n"
f"\U0001f464 *Von:* {name}\n\n"
f"\U0001f4dd *Fehler:*\n{preview}"
)
url = f"https://www.brettspiel-news.de/index.php/de/component/content/article/{article_id}"
try:
payload = json.dumps({
"chat_id": TELEGRAM_CHAT_ID,
"text": msg,
"parse_mode": "Markdown"
}).encode()
req = urllib.request.Request(
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
data=payload,
headers={"Content-Type": "application/json"}
)
urllib.request.urlopen(req, timeout=5)
except Exception as e:
print(f"[WARN] Telegram failed: {e}")
content = f"""# 🐛 Fehlermeldung #{report_id}
**Artikel:** [#{article_id}]({url})
**Gemeldet von:** {name}
**Datum:** {datetime.now().strftime('%d.%m.%Y %H:%M')}
## Fehlerbeschreibung
{text}
---
*Status: offen | Bearbeiter: Basti*
"""
with open(fpath, "w") as f:
f.write(content)
print(f"[OK] Basti benachrichtigt → {fname}")
return fpath
# ═══════════════════════════════════════════════════
# HTML-Formular (inline, self-contained)