From c3b0ac72b2b69718ef61b3561daa14ca8b5bf687 Mon Sep 17 00:00:00 2001 From: weiensong Date: Tue, 21 Nov 2023 09:56:38 +0800 Subject: [PATCH 1/3] feat: check environment, python version must be greater than or equal to 3.9 --- check_env/__init__.py | 13 +++++++++++++ main.py | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 check_env/__init__.py diff --git a/check_env/__init__.py b/check_env/__init__.py new file mode 100644 index 0000000..b0d947e --- /dev/null +++ b/check_env/__init__.py @@ -0,0 +1,13 @@ +import sys + + +class UnsupportedPythonVersionError(Exception): + def __init__(self, error_msg: str): + super().__init__(error_msg) + + +python_version_info = sys.version_info +if not sys.version_info >= (3, 9): + msg = "当前Python版本: " + ".".join(map(str, python_version_info[:3])) + (', 需要python版本 >= 3.9, 前往下载: ' + 'https://www.python.org/downloads/') + raise UnsupportedPythonVersionError(msg) diff --git a/main.py b/main.py index adccdea..450ed2d 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- import signal +import check_env + from argparse import ArgumentParser from wcferry import Wcf From 217bc470c545e8e3414bf8ca2bd4f445c95d3051 Mon Sep 17 00:00:00 2001 From: weiensong Date: Tue, 21 Nov 2023 09:57:09 +0800 Subject: [PATCH 2/3] docs: update README.MD --- README.MD | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index 91348bf..cd22a03 100644 --- a/README.MD +++ b/README.MD @@ -10,7 +10,7 @@ ## Quick Start 0. 遇到问题先看看上面的文档、教程、FAQ 和【微信机器人】沙雕行为合集。 -1. 安装 Python,例如 [3.10.11](https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe) +1. 安装 Python>=3.9,例如 [3.10.11](https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe) 2. 安装微信 `3.9.2.23`,下载地址在 [这里](https://github.com/lich0821/WeChatFerry/releases/download/v39.0.0/WeChatSetup-3.9.2.23.exe);也可以从 [WeChatSetup](https://gitee.com/lch0821/WeChatSetup) 找到。 3. 克隆项目 ```sh @@ -54,7 +54,14 @@ python main.py # 需要停止按 Ctrl+C ``` -如果你配置了多个模型,下面的内容才对你有帮助否则略过,通过参数可以选择要跑的模型。 +如果你配置了多个模型(不需要将其他配置注释或者移除),下面的内容才对你有帮助否则略过,通过python main.py -h 通过参数可以选择要跑的模型。 +```sh +# 查看帮助 +python main.py -h +#optional arguments: +# -h, --help show this help message and exit +# -c C, --chat_model C 选择要使用的AI模型,默认不选择,可选参数:1. tigerbot 模型 2. chatgpt 模型 3. 讯飞星火模型 4. chatglm 模型 +``` ```sh # 例: 我想运行选择chatgpt的机器人 python main.py -c 2 @@ -86,7 +93,7 @@ python main.py -c 2 第一次运行的时候,可以在手机上往需要响应的群里发消息,打印的消息中方括号里的就是;多个群用 `,` 分隔。 ```yaml groups: - enable: [] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom + enable: [] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom, 多个群用 `,` 分隔 ``` #### 配置 AI 模型 From 2f37ab97809b22dd65a00a2f8a4a3b16926f28a1 Mon Sep 17 00:00:00 2001 From: weiensong Date: Tue, 21 Nov 2023 11:08:15 +0800 Subject: [PATCH 3/3] fix: the position of judgment --- chatglm/__init__.py | 13 +++++++++++++ check_env/__init__.py | 13 ------------- main.py | 1 - 3 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 check_env/__init__.py diff --git a/chatglm/__init__.py b/chatglm/__init__.py index e69de29..fede0f3 100644 --- a/chatglm/__init__.py +++ b/chatglm/__init__.py @@ -0,0 +1,13 @@ +import sys + + +class UnsupportedPythonVersionError(Exception): + def __init__(self, error_msg: str): + super().__init__(error_msg) + + +python_version_info = sys.version_info +if not sys.version_info >= (3, 9): + msg = "当前Python版本: " + ".".join(map(str, python_version_info[:3])) + (', 需要python版本 >= 3.9, 前往下载: ' + 'https://www.python.org/downloads/') + raise UnsupportedPythonVersionError(msg) \ No newline at end of file diff --git a/check_env/__init__.py b/check_env/__init__.py deleted file mode 100644 index b0d947e..0000000 --- a/check_env/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - - -class UnsupportedPythonVersionError(Exception): - def __init__(self, error_msg: str): - super().__init__(error_msg) - - -python_version_info = sys.version_info -if not sys.version_info >= (3, 9): - msg = "当前Python版本: " + ".".join(map(str, python_version_info[:3])) + (', 需要python版本 >= 3.9, 前往下载: ' - 'https://www.python.org/downloads/') - raise UnsupportedPythonVersionError(msg) diff --git a/main.py b/main.py index 450ed2d..fbf54e1 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import signal -import check_env from argparse import ArgumentParser