Test2 / config.py
Dunevhhhh's picture
Update config.py
e6b49ad verified
# config.py
import json
import os
import logging
from pathlib import Path
from typing import Dict, List, Union
# Pfade
BASE_DIR = Path(__file__).parent
CONFIG_DIR = BASE_DIR / "config"
FEEDS_FILE = CONFIG_DIR / "feeds.json"
API_KEYS_FILE = CONFIG_DIR / "api_keys.json"
# Logging-Konfiguration
def setup_logging():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler("news_bot.log"),
logging.StreamHandler()
]
)
logging.getLogger("apscheduler").setLevel(logging.WARNING)
# Dynamische Feed-Konfiguration
def load_feeds() -> List[Dict]:
with open(FEEDS_FILE) as f:
return json.load(f)
def load_api_keys() -> Dict[str, str]:
try:
with open(API_KEYS_FILE) as f:
return json.load(f)
except FileNotFoundError:
logging.warning("API-Keys-Datei nicht gefunden!")
return {}
# Einstellungen
SETTINGS = {
"check_interval": 5,
"max_retries": 3,
"request_timeout": 10,
"max_articles": 50,
"telegram_chat_id": "",
"telegram_bot_token": "",
"newsapi_page_size": 100
}
# Kategorien und Filter
CATEGORY_FILTERS = {
"technology": ["AI", "Machine Learning", "Cybersecurity"],
"politics": ["Election", "Government", "Policy"]
}