Skip to content

Your lightweight open-source personal agent.

fix: handle dict config in is_allowed() and _validate_allow_from()

samy73cf9a220b1b
diff --git a/nanobot/channels/base.py b/nanobot/channels/base.py
index dd29c0851..b6b50681c 100644
--- a/nanobot/channels/base.py
+++ b/nanobot/channels/base.py
@@ -116,7 +116,10 @@ class BaseChannel(ABC):
def is_allowed(self, sender_id: str) -> bool:
"""Check if *sender_id* is permitted. Empty list → deny all; ``"*"`` → allow all."""
- allow_list = getattr(self.config, "allow_from", [])
+ if isinstance(self.config, dict):
+ allow_list = self.config.get("allow_from") or self.config.get("allowFrom") or []
+ else:
+ allow_list = getattr(self.config, "allow_from", [])
if not allow_list:
logger.warning("{}: allow_from is empty — all access denied", self.name)
return False
diff --git a/nanobot/channels/manager.py b/nanobot/channels/manager.py
index aaec5e335..58531c412 100644
--- a/nanobot/channels/manager.py
+++ b/nanobot/channels/manager.py
@@ -75,7 +75,12 @@ class ChannelManager:
def _validate_allow_from(self) -> None:
for name, ch in self.channels.items():
- if getattr(ch.config, "allow_from", None) == []:
+ cfg = ch.config
+ if isinstance(cfg, dict):
+ allow = cfg.get("allow_from") or cfg.get("allowFrom")
+ else:
+ allow = getattr(cfg, "allow_from", None)
+ if allow == []:
raise SystemExit(
f'Error: "{name}" has empty allowFrom (denies all). '
f'Set ["*"] to allow everyone, or add specific user IDs.'