Files
abot/README2.md
2025-06-03 16:48:47 +08:00

5.5 KiB
Raw Blame History

WeChatRobot

一个基于Python的微信机器人项目支持多种AI模型集成提供消息自动回复、群管理等功能。

功能特点

  • 支持多种AI模型集成Claude、DeepSeek、豆包等
  • 自动消息回复和处理
  • 群管理功能
  • 数据库消息存档
  • 邮件通知系统
  • 系统监控集成

系统要求

  • Python 3.8+
  • MySQL 数据库
  • Redis 服务器
  • 支持的操作系统Windows/Linux/MacOS

环境配置

  1. 克隆项目到本地:
git clone [项目地址]
cd WeChatRobot
  1. 创建并激活虚拟环境:
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/MacOS
source .venv/bin/activate
  1. 安装依赖:
pip install -r requirements.txt
  1. 配置数据库:
  • 确保MySQL服务已启动
  • 创建数据库message_archive
  • 配置数据库连接信息config.yaml
  1. 配置Redis
  • 确保Redis服务已启动
  • 配置Redis连接信息config.yaml

配置文件说明

config.yaml 中配置以下内容:

1. AI模型配置

Claude AI

claude:
  key: "your-api-key"
  api: "http://127.0.0.1:8080/v1/chat/completions"
  model: "windsurf/gpt4o"
  prompt: "your-prompt-template"

DeepSeek AI

deepseek:
  key: "your-api-key"
  api: "https://api.deepseek.com/chat/completions"
  model: "deepseek-chat"
  prompt: "your-prompt-template"

豆包AI

doubao:
  key: "your-api-key"
  api: "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
  model: "doubao-1-5-lite-32k-250115"
  prompt: "your-prompt-template"

2. 数据库配置

db_config:
  pool_name: "wechat_boot_pool"
  pool_size: 10
  host: "your-db-host"
  user: "your-db-user"
  password: "your-db-password"
  database: "message_archive"
  charset: "utf8mb4"
  use_unicode: true
  get_warnings: true
  pool_reset_session: true

3. Redis配置

redis_config:
  host: "your-redis-host"
  port: 6379
  db: 0
  decode_responses: true

4. 邮件配置

email_config:
  smtp_server: "smtp.163.com"
  smtp_port: 465
  sender_email: "your-email@163.com"
  sender_password: "your-email-password"
  alert_recipient: "alert-recipient@example.com"

5. 系统监控配置

glances:
  host: "your-glances-host"
  port: 61208

插件配置说明

1. AI聊天插件 (dify)

Dify:
  enable: true
  commands: ["ai", "dify", "聊天", "AI"]
  command-tip: "聊天 请求内容"
  api-key: "your-dify-api-key"
  base-url: "your-dify-base-url"
  price: 0
  admin_ignore: false
  whitelist_ignore: false
  http-proxy: ""

2. 音乐插件 (music)

Music:
  enable: true
  command: ["点歌", "音乐"]
  command-format: "点歌 歌曲名"

3. 视频插件 (video_man)

VideoMan:
  enable: true
  command: ["猛男", "肌肉", "帅哥"]
  command-format: "猛男"

4. 群智闯关插件 (game_task)

GameTask:
  enable: true
  command: ["/s", "/t", "/a", "/r", "/l", "/h"]
  command-format: "游戏命令格式说明"

5. 积分交易插件 (point_trade)

PointTrade:
  enable: true
  command: ["积分转账", "我的积分", "积分排行", "打劫", "保释"]
  command-format: "积分相关命令格式"

6. 全球新闻插件 (global_news)

GlobalNews:
  enable: true
  command: ["全球新闻", "国际新闻", "环球新闻", "政经新闻"]
  command-format: "全球新闻 - 获取最新的全球政治经济新闻"

7. 自动加群插件 (group_auto_invite)

GroupAutoInvite:
  enable: true
  command: ["#加群配置|", "#加群"]
  command-format: "加群命令格式说明"

8. 系统更新插件 (system_updater)

SystemUpdater:
  enable: true
  commands: ["更新系统", "系统更新"]
  wait_time: 5
  admin_wxids: ["admin-wxid1", "admin-wxid2"]

9. 插件管理器 (plugin_manager)

PluginManager:
  enable: true
  command: ["插件", "plugin", "插件管理"]
  command-format: "插件管理命令格式说明"

启动服务

  1. 启动主程序:
python main.py
  1. 使用重启脚本Linux/MacOS
./restart.sh

目录结构

WeChatRobot/
├── admin/           # 管理后台相关代码
├── base/           # 基础功能模块
├── db/             # 数据库相关代码
├── plugins/        # 插件目录
├── resource/       # 资源文件
├── static/         # 静态文件
├── utils/          # 工具函数
├── wechat_ipad/    # 微信相关核心代码
├── config.yaml     # 配置文件
├── main.py         # 主程序入口
├── requirements.txt # 依赖列表
└── restart.sh      # 重启脚本

注意事项

  1. 确保所有API密钥配置正确
  2. 数据库和Redis服务必须正常运行
  3. 建议使用虚拟环境运行项目
  4. 定期检查日志文件wx_debug.log, wx_info.log, wx_error.log
  5. 部分功能需要消耗积分
  6. 部分功能需要管理员权限

常见问题

  1. 如果遇到依赖安装问题请确保pip版本最新
python -m pip install --upgrade pip
  1. 如果遇到数据库连接问题,检查:

    • 数据库服务是否运行
    • 配置信息是否正确
    • 数据库用户权限是否足够
  2. 如果遇到Redis连接问题检查

    • Redis服务是否运行
    • 配置信息是否正确
    • Redis服务器防火墙设置
  3. 如果遇到API调用问题检查

    • API密钥是否正确
    • API服务是否可用
    • 网络连接是否正常

许可证

本项目采用 MIT 许可证,详见 LICENSE 文件。