Create config.py
Browse files
config.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# config.py (erweitert)
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
import logging
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
# Pfade
|
8 |
+
BASE_DIR = Path(__file__).parent
|
9 |
+
CONFIG_DIR = BASE_DIR / "config"
|
10 |
+
FEEDS_FILE = CONFIG_DIR / "feeds.json"
|
11 |
+
API_KEYS_FILE = CONFIG_DIR / "api_keys.json"
|
12 |
+
|
13 |
+
# Logging-Konfiguration
|
14 |
+
def setup_logging():
|
15 |
+
logging.basicConfig(
|
16 |
+
level=logging.INFO,
|
17 |
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
18 |
+
handlers=[
|
19 |
+
logging.FileHandler("news_bot.log"),
|
20 |
+
logging.StreamHandler()
|
21 |
+
]
|
22 |
+
)
|
23 |
+
|
24 |
+
# Dynamische Feed-Konfiguration
|
25 |
+
def load_feeds():
|
26 |
+
with open(FEEDS_FILE) as f:
|
27 |
+
return json.load(f)
|
28 |
+
|
29 |
+
# API-Keys
|
30 |
+
def load_api_keys():
|
31 |
+
with open(API_KEYS_FILE) as f:
|
32 |
+
return json.load(f)
|
33 |
+
|
34 |
+
# Einstellungen
|
35 |
+
SETTINGS = {
|
36 |
+
"check_interval": 5,
|
37 |
+
"max_retries": 3,
|
38 |
+
"request_timeout": 10,
|
39 |
+
"max_articles": 50
|
40 |
+
}
|
41 |
+
|
42 |
+
# Kategorien und Filter
|
43 |
+
CATEGORY_FILTERS = {
|
44 |
+
"technology": ["AI", "Machine Learning", "Cybersecurity"],
|
45 |
+
"politics": ["Election", "Government", "Policy"]
|
46 |
+
}
|