fix(whatsapp): enforce require_mention in group chats

This commit is contained in:
kshitijk4poor 2026-04-03 07:34:18 +05:30 committed by Teknium
parent 23addf48d3
commit 714e4941b8
4 changed files with 263 additions and 16 deletions

View file

@ -563,6 +563,14 @@ def load_gateway_config() -> GatewayConfig:
if isinstance(frc, list):
frc = ",".join(str(v) for v in frc)
os.environ["TELEGRAM_FREE_RESPONSE_CHATS"] = str(frc)
whatsapp_cfg = yaml_cfg.get("whatsapp", {})
if isinstance(whatsapp_cfg, dict):
if "require_mention" in whatsapp_cfg and not os.getenv("WHATSAPP_REQUIRE_MENTION"):
os.environ["WHATSAPP_REQUIRE_MENTION"] = str(whatsapp_cfg["require_mention"]).lower()
if "mention_patterns" in whatsapp_cfg and not os.getenv("WHATSAPP_MENTION_PATTERNS"):
import json as _json
os.environ["WHATSAPP_MENTION_PATTERNS"] = _json.dumps(whatsapp_cfg["mention_patterns"])
except Exception as e:
logger.warning(
"Failed to process config.yaml — falling back to .env / gateway.json values. "