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()
|
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):
|
def notify_basti(report_id, article_id, name, text):
|
||||||
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
|
"""Schreibt Fehlermeldung als .md-Datei für Basti."""
|
||||||
return
|
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 "")
|
url = f"https://www.brettspiel-news.de/index.php/de/component/content/article/{article_id}"
|
||||||
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}"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
content = f"""# 🐛 Fehlermeldung #{report_id}
|
||||||
payload = json.dumps({
|
|
||||||
"chat_id": TELEGRAM_CHAT_ID,
|
**Artikel:** [#{article_id}]({url})
|
||||||
"text": msg,
|
**Gemeldet von:** {name}
|
||||||
"parse_mode": "Markdown"
|
**Datum:** {datetime.now().strftime('%d.%m.%Y %H:%M')}
|
||||||
}).encode()
|
|
||||||
req = urllib.request.Request(
|
## Fehlerbeschreibung
|
||||||
f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage",
|
|
||||||
data=payload,
|
{text}
|
||||||
headers={"Content-Type": "application/json"}
|
|
||||||
)
|
---
|
||||||
urllib.request.urlopen(req, timeout=5)
|
*Status: offen | Bearbeiter: Basti*
|
||||||
except Exception as e:
|
"""
|
||||||
print(f"[WARN] Telegram failed: {e}")
|
with open(fpath, "w") as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
print(f"[OK] Basti benachrichtigt → {fname}")
|
||||||
|
return fpath
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════
|
||||||
# HTML-Formular (inline, self-contained)
|
# HTML-Formular (inline, self-contained)
|
||||||
|
|||||||
Reference in New Issue
Block a user