
环境Win11WSL2Ubuntu24.04一、相关文档Weixin (微信)Weixin (WeChat)二、前置安装pip install aiohttp cryptography # Optional: for terminal QR code display pip install hermes-agent[messaging]pip install aiohttp cryptography 安装uadminUD26:~$ pip install aiohttp cryptography Command pip not found, but can be installed with: sudo apt install python3-pip uadminUD26:~$ sudo apt update uadminUD26:~$ sudo apt install python3-pip uadminUD26:~$ pip3 install aiohttp cryptography error: externally-managed-environment × This environment is externally managed ╰─ To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.12/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. 安装报错安装这个简单版本可能旧一点 uadminUD26:~$ sudo apt install python3-aiohttp python3-cryptography使用hermes的虚拟环境安装uadminUD26:~$ source ~/.hermes/hermes-agent/venv/bin/activate(venv) uadminUD26:~$ pip show aiohttp cryptography先查一下可能已经安装了(venv) uadminUD26:~$ pip install aiohttp cryptography(venv) uadminUD26:~$ pip show aiohttp cryptography其他venv相关用法# 安装venv所需的程序包 sudo apt update sudo apt install python3-full python3-venv -y # 查看安装情况 dpkg -l | grep python3-venv apt list --installed | grep python3-venv # 新建虚拟环境 python3 -m venv ~/venvs/hermes # 激活虚拟环境 source ~/venvs/hermes/bin/activate pip安装在虚拟环境下 # 取消激活虚拟环境 deactivate # 删除虚拟环境 rm -rf ~/venvs/hermespip install hermes-agent[messaging]安装报错可以忽略可以不安装。也可以在venv中安装。三、安装配置微信gateway配置hermes gateway setupSelect a platform to configure:↑↓ navigate ENTER/SPACE select ESC cancel(○) Mattermost (not configured)(○) Signal (not configured)(○) Weixin / WeChat (not configured)(○) BlueBubbles (iMessage) (not configured)(○) QQ Bot (not configured)(○) Yuanbao (not configured)(○) DingTalk (not configured)(○) Discord (not configured)(○) Email (not configured)(○) Feishu / Lark (not configured)(○) Google Chat (not configured)(○) Home Assistant (not configured)(○) IRC (not configured)(○) LINE (not configured)(○) Matrix (not configured)(○) ntfy (not configured)(○) iMessage via Photon (not configured)(○) Raft (not configured)(○) SimpleX Chat (not configured)(○) Slack (not configured)(○) SMS (Twilio) (not configured)(○) Microsoft Teams (not configured)(○) ✈️ Telegram (not configured)(○) WeCom (Enterprise WeChat) (not configured)(○) WeCom Callback (self-built apps) (not configured)(○) WhatsApp (not configured)→ (●) Done选择→ (○) Weixin / WeChat (not configured)使用微信扫码私信消息授权How should direct messages be authorized?↑↓ navigate ENTER/SPACE select ESC cancel→ (●) Use DM pairing approval (recommended)(○) Allow all direct messages(○) Only allow listed user IDs(○) Disable direct messages默认处理群聊How should group chats be handled?↑↓ navigate ENTER/SPACE select ESC cancel→ (●)Disable group chats (recommended)(○) Allow all group chats(○) Only allow listed group chat IDs选择→ (○) Only allow listed group chat IDs微信群聊ID不好获取建议选默认的选项日志输出.微信连接成功account_id6e1234567890im.botSkipped (keeping current)✓ DM pairing enabled.Unknown DM users can request access and you approve them with hermes pairing approve.Note: QR login connects an iLink bot identity (e.g. ...im.bot), not ascriptable personal WeChat account. Ordinary WeChat groups typically cannotinvite an im.bot identity, and iLink does not deliver ordinary-group eventsto most bot accounts. The settings below only apply when iLink actuallydelivers group events for your account type — otherwise DM remains the onlyworking channel regardless of this choice.Allowed group chat IDs (comma-separated, not member user IDs):回车先不填✓ Group allowlist saved (only takes effect if iLink delivers group events).设置主聊天后续可以在聊天窗口输入/sethome设置。Use your Weixin user ID (o9cq807bOHexabcde_abcdefghijim.wechat) as the home channel? [Y/n]: Y✓ Home channel set to o9cq807bOHexabcde_abcdefghijim.wechat✓ Weixin configured!Account ID: 6e1234567890im.botUser ID: o9cq807bOHexabcde_abcdefghijim.wechat选择DoneSelect a platform to configure:→ (●) Done◆ Messaging PlatformsSkipped (keeping current)重启gateway────────────────────────────────────────────────────────── Restart the gateway to pick up changes? [Y/n]: Y⏳ User service restarting gracefully (PID 2153)...⚠ Graceful restart did not complete within 5s; forcing a service restart...⏳ User service process started (PID 7594); waiting for gateway runtime...✓ User service restarted (PID 7594)四、配置文件.env~/.hermes/.envWEIXIN_ACCOUNT_ID6e1234567890im.bot WEIXIN_TOKEN6e1234567890im.bot:060000bb1502d9f74dea7d8d4cbb1234567890 WEIXIN_BASE_URLhttps://ilinkai.weixin.qq.com WEIXIN_CDN_BASE_URLhttps://novac2c.cdn.weixin.qq.com/c2c WEIXIN_DM_POLICYpairing WEIXIN_ALLOW_ALL_USERSfalse WEIXIN_ALLOWED_USERS WEIXIN_GROUP_POLICYallowlist WEIXIN_GROUP_ALLOWED_USERS WEIXIN_HOME_CHANNELo9cq807bOHexabcde_abcdefghijim.wechat如果How should group chats be handled?想选择Disable group chats (recommended)可以修改WEIXIN_GROUP_POLICYdisabled# 下面这一行直接删掉或者留空都可以# WEIXIN_GROUP_ALLOWED_USERS重启网关hermes gateway restartconfig.yaml~/.hermes/config.yamlplatforms: weixin: enabled: false feishu: enabled: true这里的weixin:enabled: false没什么影响后续可以手动改成true。五、使用测试修改备注修改微信机器人的名称从微信ClawBot改为hermes助手聊天配对在hermes命令行输入批准配对命令uadminUD26:~$ hermes pairing approve weixin A1B2C3D4 Approved! User o9cq807bOHexabcde_abcdefghijim.wechat (o9cq807bOHexabcde_abcdefghijim.wechat) on weixin can now use the bot~ Theyll be recognized automatically on their next message.聊天成功回复设置主聊天更多命令