wechat-bot-starter

微信机器人快速搭建 - 基于 wechaty/itchat 的微信机器人模板。适合:想做微信自动化的开发者。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "wechat-bot-starter" with this command: npx skills add yang1002378395-cmyk/wechat-bot-starter

微信机器人快速搭建 Skill

快速搭建微信机器人,支持自动回复、消息监控、群管理。

技术选型

方案优点缺点推荐场景
Wechaty跨平台、生态好需要付费 Pad 协议生产环境
itchat免费、简单易封号个人测试
企业微信官方支持、稳定功能受限企业应用
ComWechat免费、Web 协议需登录小规模

快速开始

方案 1:Wechaty(推荐)

# 安装
npm install wechaty wechaty-puppet-wechat

# 创建机器人
cat > bot.js << 'EOF'
const { Wechaty } = require('wechaty')
const bot = new Wechaty()

bot
  .on('scan', (qrcode) => console.log('扫码登录:\n' + qrcode))
  .on('login', (user) => console.log('登录成功:', user))
  .on('message', async (msg) => {
    if (msg.text() === 'ping') {
      await msg.say('pong')
    }
  })

bot.start()
EOF

node bot.js

方案 2:itchat(简单)

# 安装
pip install itchat

# 创建机器人
cat > bot.py << 'EOF'
import itchat

@itchat.msg_register(itchat.content.TEXT)
def reply(msg):
    if msg['Text'] == 'ping':
        return 'pong'
    return None

itchat.auto_login(hotReload=True)
itchat.run()
EOF

python bot.py

功能模板

1. 自动回复

import itchat

# 关键词回复
REPLIES = {
    '你好': '你好!有什么可以帮你的?',
    '价格': '我们的产品价格如下...',
    '联系方式': '电话:xxx,微信:xxx'
}

@itchat.msg_register(itchat.content.TEXT)
def auto_reply(msg):
    text = msg['Text']
    for keyword, reply in REPLIES.items():
        if keyword in text:
            return reply
    return None

2. 群管理

import itchat

@itchat.msg_register(itchat.content.TEXT, isGroupChat=True)
def group_admin(msg):
    # 进群欢迎
    if msg['Type'] == 'note' and '加入群聊' in msg['Text']:
        return '欢迎新成员!请阅读群公告。'
    
    # 禁言词检测
    banned_words = ['广告', '推广', '加微信']
    for word in banned_words:
        if word in msg['Text']:
            # 可以调用踢人 API
            return None

3. 消息转发

import itchat

TARGET_GROUP = '目标群名称'

@itchat.msg_register(itchat.content.TEXT)
def forward(msg):
    # 转发到指定群
    if msg['Text'].startswith('#转发'):
        groups = itchat.search_chatrooms(name=TARGET_GROUP)
        if groups:
            groups[0].send(msg['Text'][3:])

4. 定时发送

import itchat
import schedule
import time

def morning_greeting():
    groups = itchat.search_chatrooms(name='工作群')
    if groups:
        groups[0].send('早上好!今天也要加油💪')

schedule.every().day.at('09:00').do(morning_greeting)

while True:
    schedule.run_pending()
    time.sleep(60)

接入 OpenClaw

import itchat
import requests

OPENCLAW_URL = 'http://localhost:3000/api/chat'

@itchat.msg_register(itchat.content.TEXT)
def ai_reply(msg):
    # 发送给 OpenClaw
    response = requests.post(OPENCLAW_URL, json={
        'message': msg['Text'],
        'user_id': msg['FromUserName']
    })
    
    return response.json().get('reply')

配置文件

~/.openclaw/workspace/WECHAT-BOT.md

# 机器人配置
bot:
  name: "小助手"
  welcome: "你好!我是小助手,有什么可以帮你?"

# 自动回复规则
auto_reply:
  - keyword: "价格"
    reply: "请查看产品目录:https://example.com"
  - keyword: "客服"
    reply: "正在为您转接人工客服..."

# 群管理
group_admin:
  banned_words: ["广告", "推广"]
  welcome_msg: "欢迎加入!请阅读群公告。"

# 定时任务
schedule:
  - time: "09:00"
    msg: "早上好!"
    target: "工作群"

注意事项

防封号技巧

  1. 不要频繁登录 - 使用 hotReload=True
  2. 控制发送频率 - 每秒不超过 1 条
  3. 避免营销内容 - 容易被举报
  4. 使用企业微信 - 官方支持更安全

Web 微信限制

  • 部分账号无法登录 Web 微信
  • 新注册账号通常不支持
  • 建议使用企业微信替代

推荐架构

微信消息
    ↓
消息队列(Redis)
    ↓
OpenClaw Agent 处理
    ↓
回复消息

创建:2026-03-12 版本:1.0

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

人人商城龙虾助手

人人商城龙虾助手 - 人人商城数据查询与订单管理工具。 当用户提到以下意图时使用此技能: 「查待办事项」「查运营数据」「查商品信息」「查会员信息」 「查订单」「管理订单」「查优惠券」「设置满额包邮」 「配置商城API」「验证API连通性」 支持:待办事项查询、运营数据统计、商品/会员/订单全维度查询、优惠券管理、...

Registry SourceRecently Updated
3281imdake
General

微信公众号自动发布

自动登录微信公众号,自动填写标题正文,生成并设置AI封面图,支持草稿保存、摘要留言赞赏配置,提升发布效率。

Registry SourceRecently Updated
3112xiebbs
General

电子书下载

下载中文电子书到用户电脑。通过搜索读书派(dushupai.com)等资源站获取城通网盘下载链接,自动完成密码输入、API调用获取直链、curl下载、zip解压等全流程。当用户提到"下载电子书"、"下载这本书"、"找一下某本书的电子版"、"帮我下个epub/mobi/azw3"、"下载 XX 到电脑"等与获取电子...

Registry SourceRecently Updated
General

Wechat Xhs Publisher

微信公众号与小红书一键发布工具。当需要将热点新闻改写成公众号文章并发布到微信公众号和小红书时使用,包括:1)根据热点新闻改写公众号文章 2)使用AI生成文章配图 3)发布前IP检测 4)发布到微信公众号 5)发布到小红书。触发场景:热点新闻发布、公众号文章发布、小红书种草、社交媒体同步发布。

Registry SourceRecently Updated