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:
@@ -0,0 +1,12 @@
|
||||
# 🐛 Fehlermeldung #3
|
||||
|
||||
**Artikel:** [#15526](https://www.brettspiel-news.de/index.php/de/component/content/article/15526)
|
||||
**Gemeldet von:** Test System
|
||||
**Datum:** 09.07.2026 16:39
|
||||
|
||||
## Fehlerbeschreibung
|
||||
|
||||
Roxley wurde 2014 gegruendet, nicht 2013. Bitte pruefen und korrigieren.
|
||||
|
||||
---
|
||||
*Status: offen | Bearbeiter: Basti*
|
||||
Binary file not shown.
+27
-24
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user