feat: 初始化

This commit is contained in:
hackrobot
2024-03-04 18:39:54 +08:00
parent fffeba0b3d
commit e6a5cd45a2
28 changed files with 33048 additions and 62 deletions

180
README.md
View File

@@ -1,92 +1,148 @@
# win-hook-bot
# WeChatRobot
一个基于 [WeChatFerry](https://github.com/lich0821/WeChatFerry) 的微信机器人示例。
|[📖 文档](https://wechatferry.readthedocs.io/)|[📺 视频教程](https://mp.weixin.qq.com/s/APdjGyZ2hllXxyG_sNCfXQ)|[🙋 FAQ](https://mp.weixin.qq.com/s/bdPNrbJYoXhezCzHMqLoEw)|[🚨【微信机器人】沙雕行为合集](https://mp.weixin.qq.com/s/mc8O5iuhy46X4Bgqs80E8g)|
|:-:|:-:|:-:|:-:|
|![碲矿](https://s2.loli.net/2023/09/25/fub5VAPSa8srwyM.jpg)|![赞赏](https://s2.loli.net/2023/09/25/gkh9uWZVOxzNPAX.jpg)|
|:-:|:-:|
|后台回复 `WeChatFerry` 加群交流|如果你觉得有用|
## Getting started
## Quick Start
0. 遇到问题先看看上面的文档、教程和 FAQ。
- 按照步骤来,版本保持一致,少走弯路。
- 按照步骤来,版本保持一致,少走弯路。
- 按照步骤来,版本保持一致,少走弯路。
1. 安装 Python>=3.9Python 12 需要自己编译依赖,慎选),例如 [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/latest);也可以从 [WeChatSetup](https://gitee.com/lch0821/WeChatSetup) 找到。
3. 克隆项目
```sh
git clone https://github.com/lich0821/WeChatRobot.git
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://gitlab.yidooplanet.com/gitlab-instance-0a899031/win-hook-bot.git
git branch -M main
git push -uf origin main
# 如果网络原因打不开可以科学上网或者使用gitee
git clone https://gitee.com/lch0821/WeChatRobot.git
```
## Integrate with your tools
如果觉得克隆复杂,也可以直接下载 [最新版](https://github.com/lich0821/WeChatRobot/releases/latest) 到本地解压。
- [ ] [Set up project integrations](http://gitlab.yidooplanet.com/gitlab-instance-0a899031/win-hook-bot/-/settings/integrations)
4. 安装依赖
```sh
# 升级 pip
python -m pip install -U pip
# 安装必要依赖
pip install -r requirements.txt
# ChatGLM 还需要安装一个 kernel
ipython kernel install --name chatglm3 --user
```
## Collaborate with your team
5. 运行
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
我们需要运行两次 `main.py` 第一次是生成配置文件 `config.yaml`, 第二次是真正跑你的机器人。
直接运行程序会自动拉起微信,如果微信未打开,会自动打开微信;如果版本不对,也会有提示;其他报错,请进群交流。
## Test and Deploy
下面代码为第一次运行:第一次运行 `main.py` 会在 WeChatRobot 目录下生成一个 `config.yaml` 文件,参照修改配置进行修改。
Use the built-in continuous integration in GitLab.
其中 chatgpt、tigerbot、chatglm 和 xinghuo_web 是四种模型的配置信息,你需要配置它们的参数,不知道的可以加群交流。
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
```sh
python main.py
***
# 需要停止按 Ctrl+C
```
# Editing this README
启动之后,可以正常接收消息但不会响应群消息。参考下方 [修改配置](#config) 进行配置,以便响应特定群聊。
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
下面代码为第二次运行:你可以通过命令行参数选择模型,默认是不选择,这样你配置了什么参数就跑什么模型。正因如此你需要配置前面所说四种模型中的至少一种(当然也可以都配置,想跑那个模型就选什么参数), 然后就可以开始使用你的机器人了。
```sh
python main.py
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
# 需要停止按 Ctrl+C
```
## Name
Choose a self-explaining name for your project.
如果你配置了多个模型(不需要将其他配置注释或者移除),下面的内容才对你有帮助否则略过,通过 `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 模型
```
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
```sh
# 例: 我想运行选择chatgpt的机器人
python main.py -c 2
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
# 需要停止按 Ctrl+C
```
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
> python main.py -c C 其中参数 C 可选择如下所示
>> 1. tigerbot 模型
>> 2. chatgpt 模型
>> 3. 讯飞星火模型
>> 4. chatglm 模型
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
6. 停止
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
不要那么粗暴,温柔点儿;
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
不要直接关闭窗口,温柔点儿。
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
输入:`Ctrl+C`。否则,会出现各种奇怪问题。
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
### <a name="config"></a>修改配置
*修改配置后,需要重新启动,以便让配置生效。*
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
配置文件 `config.yaml` 是运行程序后自动从模板复制过来的,功能默认关闭。
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
#### 响应被 @ 消息
为了响应群聊消息,需要添加相应的 `roomId`
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
第一次运行的时候,可以在手机上往需要响应的群里发消息,打印的消息中方括号里的就是;多个群用 `,` 分隔。
```yaml
groups:
enable: [] # 允许响应的群 roomId大概长这样2xxxxxxxxx3@chatroom, 多个群用 `,` 分隔
```
## License
For open source projects, say how it is licensed.
#### 配置 AI 模型
为了使用 AI 模型,需要对相应模型并进行配置。
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
使用 ChatGLM 见注意事项 [README.MD](base/chatglm/README.MD)
```yaml
chatgpt: # -----chatgpt配置这行不填-----
key: # 填写你 ChatGPT 的 key
api: https://api.openai.com/v1 # 如果你不知道这是干嘛的,就不要改
proxy: # 如果你在国内你可能需要魔法大概长这样http://域名或者IP地址:端口号
prompt: 你是智能聊天机器人,你叫 wcferry # 根据需要对角色进行设定
chatglm: # -----chatglm配置这行不填-----
key: sk-012345678901234567890123456789012345678901234567 # 这个应该不用动
api: http://localhost:8000/v1 # 根据自己的chatglm地址修改
proxy: # 如果你在国内你可能需要魔法大概长这样http://域名或者IP地址:端口号
prompt: 你是智能聊天机器人,你叫小薇 # 根据需要对角色进行设定
file_path: C:/Pictures/temp #设定生成图片和代码使用的文件夹路径
tigerbot: # -----tigerbot配置这行不填-----
key: # key
model: # tigerbot-7b-sft
# 抓取方式详见文档https://www.bilibili.com/read/cv27066577
xinghuo_web: # -----讯飞星火web模式api配置这行不填-----
cookie: # cookie
fd: # fd
GtToken: # GtToken
prompt: 你是智能聊天机器人,你叫 wcferry。请用这个角色回答我的问题 # 根据需要对角色进行设定
bard: # -----bard配置这行不填-----
api_key: # api-key 创建地址https://ai.google.dev/pricing创建后复制过来即可
model_name: gemini-pro # 新模型上线后可以选择模型
proxy: http://127.0.0.1:7890 # 如果你在国内你可能需要魔法大概长这样http://域名或者IP地址:端口号
# 提示词尽可能用英文bard对中文提示词的效果不是很理想下方提示词为英语老师的示例请按实际需要修改,默认设置的提示词为谷歌创造的AI大语言模型
# I want you to act as a spoken English teacher and improver. I will speak to you in English and you will reply to me in English to practice my spoken English. I want you to keep your reply neat, limiting the reply to 100 words. I want you to strictly correct my grammar mistakes, typos, and factual errors. I want you to ask me a question in your reply. Now let's start practicing, you could ask me a question first. Remember, I want you to strictly correct my grammar mistakes, typos, and factual errors.
prompt: You am a large language model, trained by Google.
```
## HTTP
如需要使用 HTTP 接口,请参考 [wcfhttp](https://wechatferry.readthedocs.io/zh/latest/?badge=latest)。
[![PyPi](https://img.shields.io/pypi/v/wcfhttp.svg)](https://pypi.python.org/pypi/wcfhttp) [![Downloads](https://static.pepy.tech/badge/wcfhttp)](https://pypi.python.org/pypi/wcfhttp) [![Documentation Status](https://readthedocs.org/projects/wechatferry/badge/?version=latest)](https://wechatferry.readthedocs.io/zh/latest/?badge=latest)