Skip to content

Your lightweight open-source personal agent.

resolve merge conflicts: keep all channels and add slack

Re-bin74e3c411a1e4
diff --cc nanobot/channels/manager.py
index d49d3b15e,26fa9f32a..b7bb0b2af
--- a/nanobot/channels/manager.py
+++ b/nanobot/channels/manager.py
@@@ -56,19 -63,59 +63,70 @@@ class ChannelManager
except ImportError as e:
logger.warning(f"WhatsApp channel not available: {e}")
+ # Discord channel
+ if self.config.channels.discord.enabled:
+ try:
+ from nanobot.channels.discord import DiscordChannel
+ self.channels["discord"] = DiscordChannel(
+ self.config.channels.discord, self.bus
+ )
+ logger.info("Discord channel enabled")
+ except ImportError as e:
+ logger.warning(f"Discord channel not available: {e}")
+
+ # Feishu channel
+ if self.config.channels.feishu.enabled:
+ try:
+ from nanobot.channels.feishu import FeishuChannel
+ self.channels["feishu"] = FeishuChannel(
+ self.config.channels.feishu, self.bus
+ )
+ logger.info("Feishu channel enabled")
+ except ImportError as e:
+ logger.warning(f"Feishu channel not available: {e}")
+
+ # DingTalk channel
+ if self.config.channels.dingtalk.enabled:
+ try:
+ from nanobot.channels.dingtalk import DingTalkChannel
+ self.channels["dingtalk"] = DingTalkChannel(
+ self.config.channels.dingtalk, self.bus
+ )
+ logger.info("DingTalk channel enabled")
+ except ImportError as e:
+ logger.warning(f"DingTalk channel not available: {e}")
+
+ # Email channel
+ if self.config.channels.email.enabled:
+ try:
+ from nanobot.channels.email import EmailChannel
+ self.channels["email"] = EmailChannel(
+ self.config.channels.email, self.bus
+ )
+ logger.info("Email channel enabled")
+ except ImportError as e:
+ logger.warning(f"Email channel not available: {e}")
++
+ # Slack channel
+ if self.config.channels.slack.enabled:
+ try:
+ from nanobot.channels.slack import SlackChannel
+ self.channels["slack"] = SlackChannel(
+ self.config.channels.slack, self.bus
+ )
+ logger.info("Slack channel enabled")
+ except ImportError as e:
+ logger.warning(f"Slack channel not available: {e}")
+ async def _start_channel(self, name: str, channel: BaseChannel) -> None:
+ """Start a channel and log any exceptions."""
+ try:
+ await channel.start()
+ except Exception as e:
+ logger.error(f"Failed to start channel {name}: {e}")
+
async def start_all(self) -> None:
- """Start WhatsApp channel and the outbound dispatcher."""
+ """Start all channels and the outbound dispatcher."""
if not self.channels:
logger.warning("No channels enabled")
return
diff --cc nanobot/config/schema.py
index 3575454ae,aa9729b03..8424cab67
--- a/nanobot/config/schema.py
+++ b/nanobot/config/schema.py
@@@ -17,33 -17,74 +17,95 @@@ class TelegramConfig(BaseModel)
enabled: bool = False
token: str = "" # Bot token from @BotFather
allow_from: list[str] = Field(default_factory=list) # Allowed user IDs or usernames
+ proxy: str | None = None # HTTP/SOCKS5 proxy URL, e.g. "http://127.0.0.1:7890" or "socks5://127.0.0.1:1080"
+
+
+ class FeishuConfig(BaseModel):
+ """Feishu/Lark channel configuration using WebSocket long connection."""
+ enabled: bool = False
+ app_id: str = "" # App ID from Feishu Open Platform
+ app_secret: str = "" # App Secret from Feishu Open Platform
+ encrypt_key: str = "" # Encrypt Key for event subscription (optional)
+ verification_token: str = "" # Verification Token for event subscription (optional)
+ allow_from: list[str] = Field(default_factory=list) # Allowed user open_ids
+
+
+ class DingTalkConfig(BaseModel):
+ """DingTalk channel configuration using Stream mode."""
+ enabled: bool = False
+ client_id: str = "" # AppKey
+ client_secret: str = "" # AppSecret
+ allow_from: list[str] = Field(default_factory=list) # Allowed staff_ids
+
+
+ class DiscordConfig(BaseModel):
+ """Discord channel configuration."""
+ enabled: bool = False
+ token: str = "" # Bot token from Discord Developer Portal
+ allow_from: list[str] = Field(default_factory=list) # Allowed user IDs
+ gateway_url: str = "wss://gateway.discord.gg/?v=10&encoding=json"
+ intents: int = 37377 # GUILDS + GUILD_MESSAGES + DIRECT_MESSAGES + MESSAGE_CONTENT
+
+ class EmailConfig(BaseModel):
+ """Email channel configuration (IMAP inbound + SMTP outbound)."""
+ enabled: bool = False
+ consent_granted: bool = False # Explicit owner permission to access mailbox data
+
+ # IMAP (receive)
+ imap_host: str = ""
+ imap_port: int = 993
+ imap_username: str = ""
+ imap_password: str = ""
+ imap_mailbox: str = "INBOX"
+ imap_use_ssl: bool = True
+
+ # SMTP (send)
+ smtp_host: str = ""
+ smtp_port: int = 587
+ smtp_username: str = ""
+ smtp_password: str = ""
+ smtp_use_tls: bool = True
+ smtp_use_ssl: bool = False
+ from_address: str = ""
+
+ # Behavior
+ auto_reply_enabled: bool = True # If false, inbound email is read but no automatic reply is sent
+ poll_interval_seconds: int = 30
+ mark_seen: bool = True
+ max_body_chars: int = 12000
+ subject_prefix: str = "Re: "
+ allow_from: list[str] = Field(default_factory=list) # Allowed sender email addresses
+class SlackDMConfig(BaseModel):
+ """Slack DM policy configuration."""
+ enabled: bool = True
+ policy: str = "open" # "open" or "allowlist"
+ allow_from: list[str] = Field(default_factory=list) # Allowed Slack user IDs
+
+
+class SlackConfig(BaseModel):
+ """Slack channel configuration."""
+ enabled: bool = False
+ mode: str = "socket" # "socket" supported
+ webhook_path: str = "/slack/events"
+ bot_token: str = "" # xoxb-...
+ app_token: str = "" # xapp-...
+ user_token_read_only: bool = True
+ group_policy: str = "open" # "open", "mention", "allowlist"
+ group_allow_from: list[str] = Field(default_factory=list) # Allowed channel IDs if allowlist
+ dm: SlackDMConfig = Field(default_factory=SlackDMConfig)
+
+
class ChannelsConfig(BaseModel):
"""Configuration for chat channels."""
whatsapp: WhatsAppConfig = Field(default_factory=WhatsAppConfig)
telegram: TelegramConfig = Field(default_factory=TelegramConfig)
+ discord: DiscordConfig = Field(default_factory=DiscordConfig)
+ feishu: FeishuConfig = Field(default_factory=FeishuConfig)
+ dingtalk: DingTalkConfig = Field(default_factory=DingTalkConfig)
+ email: EmailConfig = Field(default_factory=EmailConfig)
+ slack: SlackConfig = Field(default_factory=SlackConfig)
class AgentDefaults(BaseModel):
diff --cc pyproject.toml
index 5d4dec922,6fda084c8..aa65ea31f
--- a/pyproject.toml
+++ b/pyproject.toml
@@@ -28,8 -28,10 +28,11 @@@ dependencies =
"readability-lxml>=0.8.0",
"rich>=13.0.0",
"croniter>=2.0.0",
- "python-telegram-bot>=21.0",
+ "dingtalk-stream>=0.4.0",
+ "python-telegram-bot[socks]>=21.0",
+ "lark-oapi>=1.0.0",
+ "socksio>=1.0.0",
+ "slack-sdk>=3.26.0",
]
[project.optional-dependencies]