Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
feat(wecom): add WeCom channel with SDK pinned to GitHub tag v0.1.2
Re-bind0b4f0d70d02
diff --git a/README.md b/README.mdindex 5be0ce5ae..6e8211e65 100644--- a/README.md+++ b/README.md@@ -208,7 +208,7 @@ Connect nanobot to your favorite chat platform.| **Slack** | Bot token + App-Level token || **Email** | IMAP/SMTP credentials || **QQ** | App ID + App Secret |-| **Wecom** | Bot ID + App Secret |+| **Wecom** | Bot ID + Bot Secret |<details><summary><b>Telegram</b> (Recommended)</summary>@@ -683,12 +683,17 @@ nanobot gatewayUses **WebSocket** long connection — no public IP required.-**1. Create a wecom bot**+**1. Install the optional dependency**-In the client's workspace, click on "Intelligent Robot" to create a robot and choose API mode for creation.-Select to create in "long connection" mode, and obtain Bot ID and Secret.+```bash+pip install nanobot-ai[wecom]+```-**2. Configure**+**2. Create a WeCom AI Bot**++Go to the WeCom admin console → Intelligent Robot → Create Robot → select **API mode** with **long connection**. Copy the Bot ID and Secret.++**3. Configure**```json{@@ -696,23 +701,21 @@ Select to create in "long connection" mode, and obtain Bot ID and Secret."wecom": {"enabled": true,"botId": "your_bot_id",- "secret": "your_secret",- "allowFrom": [- "your_id"- ]+ "secret": "your_bot_secret",+ "allowFrom": ["your_id"]}}}```-**3. Run**+**4. Run**```bashnanobot gateway```> [!TIP]-> wecom uses WebSocket to receive messages — no webhook or public IP needed!+> WeCom uses WebSocket to receive messages — no webhook or public IP needed!</details>diff --git a/nanobot/channels/manager.py b/nanobot/channels/manager.pyindex 369795a90..2c5cd3fbc 100644--- a/nanobot/channels/manager.py+++ b/nanobot/channels/manager.py@@ -156,7 +156,6 @@ class ChannelManager:self.channels["wecom"] = WecomChannel(self.config.channels.wecom,self.bus,- groq_api_key=self.config.providers.groq.api_key,)logger.info("WeCom channel enabled")except ImportError as e:diff --git a/nanobot/channels/wecom.py b/nanobot/channels/wecom.pyindex dc9731147..1c4445130 100644--- a/nanobot/channels/wecom.py+++ b/nanobot/channels/wecom.py@@ -2,6 +2,7 @@import asyncioimport importlib.util+import osfrom collections import OrderedDictfrom typing import Any@@ -36,10 +37,9 @@ class WecomChannel(BaseChannel):name = "wecom"- def __init__(self, config: WecomConfig, bus: MessageBus, groq_api_key: str = ""):+ def __init__(self, config: WecomConfig, bus: MessageBus):super().__init__(config, bus)self.config: WecomConfig = config- self.groq_api_key = groq_api_keyself._client: Any = Noneself._processed_message_ids: OrderedDict[str, None] = OrderedDict()self._loop: asyncio.AbstractEventLoop | None = None@@ -50,7 +50,7 @@ class WecomChannel(BaseChannel):async def start(self) -> None:"""Start the WeCom bot with WebSocket long connection."""if not WECOM_AVAILABLE:- logger.error("WeCom SDK not installed. Run: pip install wecom-aibot-sdk-python")+ logger.error("WeCom SDK not installed. Run: pip install nanobot-ai[wecom]")returnif not self.config.bot_id or not self.config.secret:@@ -213,7 +213,6 @@ class WecomChannel(BaseChannel):if file_url and aes_key:file_path = await self._download_and_save_media(file_url, aes_key, "image")if file_path:- import osfilename = os.path.basename(file_path)content_parts.append(f"[image: {filename}]\n[Image: source: {file_path}]")else:@@ -308,6 +307,7 @@ class WecomChannel(BaseChannel):media_dir = get_media_dir("wecom")if not filename:filename = fname or f"{media_type}_{hash(file_url) % 100000}"+ filename = os.path.basename(filename)file_path = media_dir / filenamefile_path.write_bytes(data)diff --git a/nanobot/config/schema.py b/nanobot/config/schema.pyindex b772d18d2..bb0d286a3 100644--- a/nanobot/config/schema.py+++ b/nanobot/config/schema.py@@ -208,7 +208,7 @@ class WecomConfig(Base):secret: str = "" # Bot Secret from WeCom AI Bot platformallow_from: list[str] = Field(default_factory=list) # Allowed user IDswelcome_message: str = "" # Welcome message for enter_chat event- react_emoji: str = "eyes" # Emoji for message reactions+class ChannelsConfig(Base):"""Configuration for chat channels."""diff --git a/pyproject.toml b/pyproject.tomlindex 0582be664..9868513e6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -44,11 +44,13 @@ dependencies = ["json-repair>=0.57.0,<1.0.0","chardet>=3.0.2,<6.0.0","openai>=2.8.0",- "wecom-aibot-sdk-python>=0.1.2","tiktoken>=0.12.0,<1.0.0",][project.optional-dependencies]+wecom = [+ "wecom-aibot-sdk-python @ git+https://github.com/chengyongru/[email protected]",+]matrix = ["matrix-nio[e2e]>=0.25.2","mistune>=3.0.0,<4.0.0",