File size: 1,034 Bytes
69174a5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# config.py (erweitert)
import json
import os
import logging
from pathlib import Path
# 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()
]
)
# Dynamische Feed-Konfiguration
def load_feeds():
with open(FEEDS_FILE) as f:
return json.load(f)
# API-Keys
def load_api_keys():
with open(API_KEYS_FILE) as f:
return json.load(f)
# Einstellungen
SETTINGS = {
"check_interval": 5,
"max_retries": 3,
"request_timeout": 10,
"max_articles": 50
}
# Kategorien und Filter
CATEGORY_FILTERS = {
"technology": ["AI", "Machine Learning", "Cybersecurity"],
"politics": ["Election", "Government", "Policy"]
} |