Skip to content

Commit 2eae5c5

Browse files
committed
更新readme,优化文件结构
1 parent 68928c6 commit 2eae5c5

22 files changed

+205
-83
lines changed

@AutomationLog.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 170 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,131 @@
1-
# wxauto_http_api
1+
# 🚀 wxauto_http_api
22

3-
基于wxauto的微信HTTP API接口,支持通过HTTP API调用微信功能,同时支持可选的wxautox扩展功能。
3+
<div align="center">
44

5-
## 功能特点
5+
![Version](https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000)
6+
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
7+
![Platform](https://img.shields.io/badge/platform-Windows-lightgrey.svg)
8+
![Python](https://img.shields.io/badge/python-3.7%2B-blue.svg)
69

7-
- 内置wxauto微信自动化库
8-
- 可选支持wxautox扩展功能(需单独安装)
9-
- 提供完整的HTTP API接口
10-
- 支持消息发送、接收、文件传输等功能
11-
- 支持群聊、好友管理等功能
10+
</div>
1211

13-
## 安装说明
12+
基于wxauto的微信HTTP API接口,提供简单易用的HTTP API调用微信功能,同时支持可选的wxautox扩展功能。通过本项目,您可以轻松地将微信集成到您的应用程序中。
13+
14+
## ✨ 功能特点
15+
16+
- 📱 **内置wxauto微信自动化库**:开箱即用,无需额外安装
17+
- 🚀 **可选支持wxautox扩展功能**:提供更强大的功能和更高的稳定性(需单独安装)
18+
- 🌐 **完整的HTTP API接口**:简单易用的RESTful API
19+
- 💬 **丰富的消息功能**:支持文本、图片、文件、视频等多种消息类型
20+
- 👥 **群聊和好友管理**:支持群聊创建、成员管理、好友添加等功能
21+
- 🔄 **实时消息监听**:支持实时获取新消息
22+
- 🖥️ **图形化管理界面**:提供直观的服务管理和配置界面
23+
24+
## 🔧 安装说明
1425

1526
### 前置条件
1627

17-
- Python 3.7+
18-
- Windows操作系统
19-
- 微信PC客户端已登录
28+
- **Python 3.7+**:确保已安装Python 3.7或更高版本
29+
- **Windows操作系统**:目前仅支持Windows平台
30+
- **微信PC客户端**:确保已安装并登录微信PC客户端,建议使用微信3.9版本
2031

2132
### 安装步骤
2233

23-
1. 克隆本仓库
34+
1. **克隆本仓库**
2435

2536
```bash
2637
git clone https://github.com/yourusername/wxauto_http_api.git
2738
cd wxauto_http_api
2839
```
2940

30-
2. 安装依赖
41+
2. **安装依赖**
3142

3243
```bash
3344
# 安装基础依赖
3445
pip install -r requirements.txt
35-
36-
# 安装wxauto和其他依赖
37-
python install_deps.py
38-
39-
# 如需使用wxautox(可选)
40-
# pip install wxautox-x.x.x.x-cpxxx-cpxxx-xxx.whl
4146
```
4247

43-
或者直接运行应用,程序会自动检测并安装所需依赖:
48+
3. **启动应用**
4449

4550
```bash
46-
python run.py
51+
# 启动图形界面
52+
python main.py --service ui
53+
# 或者直接双击 start_ui.bat
4754
```
4855

49-
> **注意**: 本项目会自动安装所需的 wxauto 库,按照以下顺序尝试安装:
50-
> 1. 首先尝试从 PyPI 安装
51-
> 2. 如果 PyPI 安装失败,尝试从 GitHub 克隆并安装
52-
> 3. 如果 GitHub 安装也失败,将使用本地 wxauto 文件夹进行安装
53-
>
54-
> 这种机制确保了即使在网络受限的环境中,只要有本地 wxauto 文件夹,程序也能正常运行。
56+
## 🚀 使用说明
57+
58+
### 启动方式
59+
60+
本项目提供两种启动方式:
5561

56-
## 使用说明
62+
1. **图形界面模式**(推荐)
5763

58-
### 启动服务
64+
```bash
65+
# 方式1:使用Python命令
66+
python main.py --service ui
67+
68+
# 方式2:直接双击批处理文件
69+
start_ui.bat
70+
```
71+
72+
2. **仅API服务模式**
5973

6074
```bash
61-
python run.py
75+
# 方式1:使用Python命令
76+
python main.py --service api
77+
78+
# 方式2:直接双击批处理文件
79+
start_api.bat
6280
```
6381

64-
默认情况下,服务将在 `http://0.0.0.0:5000` 上启动。
82+
默认情况下,API服务将在 `http://0.0.0.0:5000` 上启动。
83+
84+
### 图形界面功能
85+
86+
图形界面提供以下功能:
87+
88+
- **服务管理**:启动/停止API服务
89+
- **库选择**:选择使用wxauto或wxautox库
90+
- **插件管理**:安装/更新wxautox库
91+
- **配置管理**:修改端口、API密钥等配置
92+
- **日志查看**:实时查看API服务日志
93+
- **状态监控**:监控服务状态、资源使用情况
6594

6695
### API密钥配置
6796

68-
`.env` 文件中配置API密钥:
97+
有两种方式配置API密钥:
98+
99+
1. **通过图形界面配置**
100+
- 点击"插件配置"按钮
101+
- 在弹出的对话框中设置API密钥
102+
103+
2. **通过配置文件配置**
104+
-`.env` 文件中添加以下内容:
105+
```
106+
API_KEYS=your_api_key1,your_api_key2
107+
```
108+
109+
### 📚 API接口说明
110+
111+
所有API请求都需要在请求头中包含API密钥:
69112

70113
```
71-
API_KEYS=your_api_key1,your_api_key2
72-
SECRET_KEY=your_secret_key
114+
X-API-Key: your_api_key
73115
```
74116

75-
### API接口说明
76-
77117
#### 初始化微信
78118

79-
```
119+
```http
80120
POST /api/wechat/initialize
81121
```
82122

83123
#### 发送消息
84124

85-
```
125+
```http
86126
POST /api/message/send
87-
```
127+
Content-Type: application/json
88128
89-
请求体:
90-
91-
```json
92129
{
93130
"receiver": "接收者名称",
94131
"message": "消息内容",
@@ -99,57 +136,86 @@ POST /api/message/send
99136

100137
#### 获取新消息
101138

102-
```
139+
```http
103140
GET /api/message/get-next-new?savepic=true&savevideo=true&savefile=true&savevoice=true&parseurl=true
104141
```
105142

106-
更多API接口请参考代码或API文档。
143+
#### 添加监听对象
144+
145+
```http
146+
POST /api/message/listen/add
147+
Content-Type: application/json
148+
149+
{
150+
"who": "群名称或好友名称",
151+
"savepic": true
152+
}
153+
```
154+
155+
#### 获取监听消息
156+
157+
```http
158+
GET /api/message/listen/get?who=群名称或好友名称
159+
```
160+
161+
更多API接口请在图形界面中点击"API说明"按钮查看详细文档。
107162

108-
## 库的选择
163+
## 🔄 库的选择
109164

110165
本项目支持两种微信自动化库:
111166

112-
- **wxauto**: 开源的微信自动化库,功能相对基础,默认内置
113-
- **wxautox**: 增强版的微信自动化库,提供更多功能,需单独安装
167+
- **wxauto** 📱:开源的微信自动化库,功能相对基础,**默认内置**
168+
- **wxautox** 🚀:增强版的微信自动化库,提供更多功能和更高的稳定性,**需单独安装**
169+
170+
### 选择使用哪个库
114171

115172
您可以通过以下方式选择使用哪个库:
116173

117-
1. **安装时选择**:运行 `python install_deps.py` 时,会提示您选择使用哪个库
118-
2. **手动配置**:在 `.env` 文件中设置 `WECHAT_LIB` 参数
174+
1. **通过图形界面选择**(推荐):
175+
- 在图形界面中选择"wxauto"或"wxautox"单选按钮
176+
- 点击"重载配置"按钮使配置生效
119177

120-
```bash
121-
# 在.env文件中添加以下配置
122-
# 使用wxauto库
123-
WECHAT_LIB=wxauto
178+
2. **通过配置文件选择**
179+
-`.env` 文件中设置 `WECHAT_LIB` 参数
180+
```bash
181+
# 使用wxauto库
182+
WECHAT_LIB=wxauto
124183

125-
# 或者使用wxautox库
126-
WECHAT_LIB=wxautox
127-
```
184+
# 或者使用wxautox库
185+
WECHAT_LIB=wxautox
186+
```
187+
188+
### 安装wxautox库
128189

129190
如果您选择使用wxautox库,有以下几种安装方式:
130191

131-
1. **通过UI界面安装**
132-
- 启动程序后,在UI界面点击"安装wxautox"按钮
133-
- 选择您已下载的wxautox wheel文件
192+
1. **通过图形界面安装**(推荐)
193+
- 启动程序后,在图形界面点击"安装wxautox"按钮
194+
- 选择您已下载的wxautox wheel文件(位于 `lib` 目录或您自己下载的位置)
134195
- 系统将自动安装并配置wxautox库
135196

136197
2. **通过命令行安装**
137198
```bash
138199
# 如果您有wxautox的wheel文件
139-
pip install wxautox-x.x.x.x-cpxxx-cpxxx-xxx.whl
200+
pip install lib/wxautox-x.x.x.x-cpxxx-cpxxx-xxx.whl
140201
```
141202

142-
3. **通过安装脚本安装**
143-
- 将wxautox wheel文件放在项目根目录
144-
- 运行 `python install_deps.py` 并选择wxautox选项
203+
> **注意**:程序会严格按照您的选择使用指定的库。如果您选择了wxautox但未安装,程序会自动降级使用wxauto库。
145204
146-
**注意**:程序会严格按照您的选择使用指定的库,不会自动切换。如果您选择了wxautox但未安装,程序将无法启动。
205+
## ⚙️ 自定义配置
147206

148-
## 自定义配置
207+
### 通过图形界面配置
149208

150-
`.env` 文件中可以进行更多配置
209+
推荐使用图形界面进行配置,点击"插件配置"按钮可以修改以下配置
151210

152-
```
211+
- **端口号**:API服务监听的端口号
212+
- **API密钥**:访问API所需的密钥
213+
214+
### 通过配置文件配置
215+
216+
您也可以在 `.env` 文件中进行更多高级配置:
217+
218+
```ini
153219
# API配置
154220
API_KEYS=your_api_key1,your_api_key2
155221
SECRET_KEY=your_secret_key
@@ -164,12 +230,42 @@ WECHAT_RECONNECT_DELAY=30
164230
WECHAT_MAX_RETRY=3
165231
```
166232

167-
## 注意事项
233+
## 📁 项目结构
234+
235+
```
236+
wxauto_http_api/
237+
├── app/ # 应用程序核心代码
238+
│ ├── api/ # API接口实现
239+
│ ├── config.py # 配置模块
240+
│ ├── logs.py # 日志模块
241+
│ ├── plugin_manager.py # 插件管理模块
242+
│ └── wechat/ # 微信功能实现
243+
├── build_tools/ # 打包工具
244+
├── data/ # 数据文件
245+
│ ├── api/ # API数据
246+
│ └── logs/ # 日志文件
247+
├── docs/ # 文档
248+
├── lib/ # 第三方库
249+
├── wxauto/ # wxauto库
250+
├── .env # 环境变量配置
251+
├── main.py # 主入口点
252+
├── requirements.txt # 依赖项列表
253+
├── start_api.bat # 启动API服务的批处理文件
254+
└── start_ui.bat # 启动UI服务的批处理文件
255+
```
256+
257+
## ⚠️ 注意事项
258+
259+
- **微信客户端**:请确保微信PC客户端已登录
260+
- **窗口状态**:使用过程中请勿关闭微信窗口
261+
- **安全性**:API密钥请妥善保管,避免泄露
262+
- **兼容性**:本项目仅支持Windows操作系统
263+
- **依赖项**:确保已安装所有必要的依赖项
264+
265+
## 📝 许可证
168266

169-
- 请确保微信PC客户端已登录
170-
- 使用过程中请勿关闭微信窗口
171-
- API密钥请妥善保管,避免泄露
267+
[MIT License](LICENSE)
172268

173-
## 许可证
269+
## 🤝 贡献
174270

175-
MIT License
271+
欢迎提交问题和功能请求!如果您想贡献代码,请提交拉取请求。
File renamed without changes.
File renamed without changes.

app_ui.py renamed to app/app_ui.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,11 @@ def start_api_service(self):
15201520
cmd = [executable, "--service", "api", "--debug"]
15211521
else:
15221522
# 如果是开发环境,使用Python解释器启动main.py
1523-
cmd = [sys.executable, "main.py", "--service", "api"]
1523+
# 注意:main.py 现在位于项目根目录,而不是app目录
1524+
# 获取项目根目录
1525+
app_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1526+
main_py_path = os.path.join(app_dir, "main.py")
1527+
cmd = [sys.executable, main_py_path, "--service", "api"]
15241528

15251529
# 添加调试参数,以获取更详细的日志
15261530
if os.environ.get("WXAUTO_DEBUG") == "1":
File renamed without changes.
File renamed without changes.

app/initialize_wechat.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@echo off
2+
echo 正在初始化微信...
3+
curl -X POST -H "X-API-Key: test-key-2" http://localhost:5000/api/wechat/initialize
4+
echo.
5+
echo 初始化完成!
6+
pause
File renamed without changes.

0 commit comments

Comments
 (0)