backend-lehrer (11 files): - llm_gateway/routes/schools.py (867 → 5), recording_api.py (848 → 6) - messenger_api.py (840 → 5), print_generator.py (824 → 5) - unit_analytics_api.py (751 → 5), classroom/routes/context.py (726 → 4) - llm_gateway/routes/edu_search_seeds.py (710 → 4) klausur-service (12 files): - ocr_labeling_api.py (845 → 4), metrics_db.py (833 → 4) - legal_corpus_api.py (790 → 4), page_crop.py (758 → 3) - mail/ai_service.py (747 → 4), github_crawler.py (767 → 3) - trocr_service.py (730 → 4), full_compliance_pipeline.py (723 → 4) - dsfa_rag_api.py (715 → 4), ocr_pipeline_auto.py (705 → 4) website (6 pages): - audit-checklist (867 → 8), content (806 → 6) - screen-flow (790 → 4), scraper (789 → 5) - zeugnisse (776 → 5), modules (745 → 4) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
106 lines
3.0 KiB
Python
106 lines
3.0 KiB
Python
"""
|
|
Messenger API - Data Helpers.
|
|
|
|
JSON-based file storage for contacts, conversations, messages, and groups.
|
|
"""
|
|
|
|
import json
|
|
from typing import List, Dict
|
|
from pathlib import Path
|
|
|
|
# Datenspeicherung (JSON-basiert fuer einfache Persistenz)
|
|
DATA_DIR = Path(__file__).parent / "data" / "messenger"
|
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
CONTACTS_FILE = DATA_DIR / "contacts.json"
|
|
CONVERSATIONS_FILE = DATA_DIR / "conversations.json"
|
|
MESSAGES_FILE = DATA_DIR / "messages.json"
|
|
GROUPS_FILE = DATA_DIR / "groups.json"
|
|
|
|
|
|
def load_json(filepath: Path) -> List[Dict]:
|
|
"""Laedt JSON-Daten aus Datei."""
|
|
if not filepath.exists():
|
|
return []
|
|
try:
|
|
with open(filepath, "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
except Exception:
|
|
return []
|
|
|
|
|
|
def save_json(filepath: Path, data: List[Dict]):
|
|
"""Speichert Daten in JSON-Datei."""
|
|
with open(filepath, "w", encoding="utf-8") as f:
|
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
|
|
|
|
|
def get_contacts() -> List[Dict]:
|
|
return load_json(CONTACTS_FILE)
|
|
|
|
|
|
def save_contacts(contacts: List[Dict]):
|
|
save_json(CONTACTS_FILE, contacts)
|
|
|
|
|
|
def get_conversations() -> List[Dict]:
|
|
return load_json(CONVERSATIONS_FILE)
|
|
|
|
|
|
def save_conversations(conversations: List[Dict]):
|
|
save_json(CONVERSATIONS_FILE, conversations)
|
|
|
|
|
|
def get_messages() -> List[Dict]:
|
|
return load_json(MESSAGES_FILE)
|
|
|
|
|
|
def save_messages(messages: List[Dict]):
|
|
save_json(MESSAGES_FILE, messages)
|
|
|
|
|
|
def get_groups() -> List[Dict]:
|
|
return load_json(GROUPS_FILE)
|
|
|
|
|
|
def save_groups(groups: List[Dict]):
|
|
save_json(GROUPS_FILE, groups)
|
|
|
|
|
|
# ==========================================
|
|
# DEFAULT TEMPLATES
|
|
# ==========================================
|
|
|
|
DEFAULT_TEMPLATES = [
|
|
{
|
|
"id": "1",
|
|
"name": "Terminbestaetigung",
|
|
"content": "Vielen Dank fuer Ihre Terminanfrage. Ich bestaetige den Termin am [DATUM] um [UHRZEIT]. Bitte geben Sie mir Bescheid, falls sich etwas aendern sollte.",
|
|
"category": "termin"
|
|
},
|
|
{
|
|
"id": "2",
|
|
"name": "Hausaufgaben-Info",
|
|
"content": "Zur Information: Die Hausaufgaben fuer diese Woche umfassen [THEMA]. Abgabetermin ist [DATUM]. Bei Fragen stehe ich gerne zur Verfuegung.",
|
|
"category": "hausaufgaben"
|
|
},
|
|
{
|
|
"id": "3",
|
|
"name": "Entschuldigung bestaetigen",
|
|
"content": "Ich bestaetige den Erhalt der Entschuldigung fuer [NAME] am [DATUM]. Die Fehlzeiten wurden entsprechend vermerkt.",
|
|
"category": "entschuldigung"
|
|
},
|
|
{
|
|
"id": "4",
|
|
"name": "Gespraechsanfrage",
|
|
"content": "Ich wuerde gerne einen Termin fuer ein Gespraech mit Ihnen vereinbaren, um [THEMA] zu besprechen. Waeren Sie am [DATUM] um [UHRZEIT] verfuegbar?",
|
|
"category": "gespraech"
|
|
},
|
|
{
|
|
"id": "5",
|
|
"name": "Krankmeldung bestaetigen",
|
|
"content": "Vielen Dank fuer Ihre Krankmeldung fuer [NAME]. Ich wuensche gute Besserung. Bitte reichen Sie eine schriftliche Entschuldigung nach, sobald Ihr Kind wieder gesund ist.",
|
|
"category": "krankmeldung"
|
|
}
|
|
]
|