QQ robot....

 Robot introduction

Used here: go-cqhttp is responsible for communicating with QQ. Nonebot serves as the reverse proxy server of go-cqhttp to process and respond to QQ group messages. Use Django to send the messages received by Nonebot to ChatGPT, and then return the messages.

The functions I have implemented here: support prefix keywords to trigger ChatGPT, support another QQ private chat to execute group sending (send to all groups) instructions, support keywords to trigger advertisements, and support @ triggering ChatGPT.

For group messages with more than 15 words, keyword pop-up ads will not be triggered.

 

 Robot environment construction

If you need the source code, please ask me~

WeChat: iostreamX64

QQ:846581636

Environmental requirements

Windows system, windows10/11, windows server2013 or above are all acceptable.

Python3 environment.

go-cqhttp working

Copy the config.yml I gave to go-cqhttp folder separately (for later use), delete all the files except go-cqhttp_windows_386.exe, delete them and run go-cqhttp_windows_386.exe to confirm everything. Then click go-cqhttp.bat to select the reverse proxy. After execution, a config.yml file will appear in the folder. Delete this file, copy the previously copied file back, and change the account password inside to your.

I have configured config.yml except for the account and password, and cannot change anything else.

Run go-cqhttp.bat again. You have logged in to your account, but you will be prompted that the reverse proxy server cannot be connected. Don't worry, let's take our time.

Installation library

Install under xin/chat: pip install django

Install under xin/chat: pip install djangorestframework 

Install under xin/chat: pip install requests 

Test under xin/chat: python.exe .\manage.py runserver 8081, it can start normally.

Install under xin/chat: pip install openai

Put your openai key in xin\chat\myapp\openai_key.py, and openai will check the address of the key.

Install under xin/chat: pip install urllib3==1.25.11 #Must be this version, higher versions will not work.

Run under xin/chat: python.exe .\manage.py runserver 8081

Enter in your browser: http://127.0.0.1:8081/chat-api/?msg=“Hello”

The test results are as follows:

Open a new console window and run in the project root directory: pip install nb-cli  

Run under xin\nonebotXin\: pip install 'nonebot2[fastapi]' 

Run under xin\nonebotXin\: pip install nonebot2 

Run under xin\nonebotXin\: pip install nonebot-adapter-cqhttp 

Run under xin\nonebotXin\: pip install nonebot-plugin-apscheduler 

Finished~

Guess you like

Origin blog.csdn.net/LYXlyxll/article/details/131880276
qq