Add Telegram notifications, make Discord optional

This commit is contained in:
2026-10-28 17:47:36 +01:00
parent b61feb4fef
commit 775dd4178d
9 changed files with 313 additions and 19 deletions
+24 -3
View File
@@ -11,6 +11,8 @@ ENV_KEYS = [
"DISCORD_WEBHOOK_URL",
"DISCORD_SERVER_NAME",
"DISCORD_ROLES",
"TELEGRAM_BOT_TOKEN",
"TELEGRAM_CHAT_ID",
"COUNTRY",
"REFRESH_TIME",
"TEST_MODE",
@@ -27,9 +29,28 @@ def _reload_env_config(monkeypatch, env):
return importlib.import_module(MODULE_NAME)
def test_missing_webhook_exits(monkeypatch):
with pytest.raises(SystemExit):
_reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"})
def test_no_notification_channel_does_not_exit(monkeypatch, caplog):
cfg = _reload_env_config(monkeypatch, {"PRODUCT_NAMES": "RTX 5090"})
assert not cfg.DISCORD_ENABLED
assert not cfg.TELEGRAM_ENABLED
assert "DISCORD IS NOT CONFIGURED" in caplog.text
assert "TELEGRAM IS NOT CONFIGURED" in caplog.text
def test_telegram_only_is_enabled(monkeypatch):
cfg = _reload_env_config(
monkeypatch,
{"PRODUCT_NAMES": "RTX 5090", "TELEGRAM_BOT_TOKEN": "123:abc", "TELEGRAM_CHAT_ID": "-100"},
)
assert cfg.TELEGRAM_ENABLED
assert not cfg.DISCORD_ENABLED
def test_telegram_partial_config_is_disabled(monkeypatch):
cfg = _reload_env_config(
monkeypatch, {"PRODUCT_NAMES": "RTX 5090", "TELEGRAM_BOT_TOKEN": "123:abc"}
)
assert not cfg.TELEGRAM_ENABLED
def test_missing_product_names_exits(monkeypatch):