Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,24 @@
|
|
| 1 |
-
app.py
|
| 2 |
-
|
| 3 |
-
import
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
|
|
|
| 7 |
setup_logging()
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
def load_json(file_path): try: with open(file_path, "r", encoding="utf-8") as f: return json.load(f) except FileNotFoundError: logging.error(f"Datei nicht gefunden: {file_path}") return {}
|
| 26 |
-
|
| 27 |
-
def load_text_list(file_path): try: with open(file_path, "r", encoding="utf-8") as f: return [line.strip().lower() for line in f if line.strip()] except FileNotFoundError: logging.warning(f"Datei nicht gefunden: {file_path}") return []
|
| 28 |
-
|
| 29 |
-
Laden der Konfiguration
|
| 30 |
-
|
| 31 |
-
FEEDS = load_json(FEEDS_FILE) API_KEYS = load_json(API_KEYS_FILE) BLACKLIST = load_text_list(BLACKLIST_FILE) WHITELIST = load_text_list(WHITELIST_FILE)
|
| 32 |
-
|
| 33 |
-
SETTINGS = { "check_interval": 5, "max_retries": 3, "request_timeout": 10, "max_articles": 50, "telegram_chat_id": API_KEYS.get("telegram_chat_id", ""), "telegram_bot_token": API_KEYS.get("telegram_bot_token", "") }
|
| 34 |
-
|
| 35 |
-
CATEGORY_FILTERS = { "technology": ["AI", "Machine Learning", "Cybersecurity"], "politics": ["Election", "Government", "Policy"] }
|
| 36 |
-
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import asyncio
|
| 3 |
+
import logging
|
| 4 |
+
from scheduler import NewsScheduler
|
| 5 |
+
from config import setup_logging, load_api_keys
|
| 6 |
|
| 7 |
+
# Logging-Konfiguration
|
| 8 |
setup_logging()
|
| 9 |
|
| 10 |
+
async def main():
|
| 11 |
+
try:
|
| 12 |
+
scheduler = NewsScheduler()
|
| 13 |
+
await scheduler.start()
|
| 14 |
+
while True:
|
| 15 |
+
await asyncio.sleep(3600) # Hauptloop für kontinuierlichen Betrieb
|
| 16 |
+
except KeyboardInterrupt:
|
| 17 |
+
logging.info("Bot wurde ordnungsgemäß beendet")
|
| 18 |
+
except Exception as e:
|
| 19 |
+
logging.error(f"Kritischer Fehler: {str(e)}")
|
| 20 |
+
finally:
|
| 21 |
+
await scheduler.shutdown()
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
asyncio.run(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|