Cool Q robot run on Linux cloud services and realize their functions

Preface:

Gangster group in various robotic functions bells and whistles, I was very envious, so he also had a cool engage in Q robot to play.

But if you use normal windows version of the robot, then we have to ensure that the computer does not shut down 24 hours to run, so think of ways to get a robot mirroring a Dokcer container on a cloud server.

At the forum, there are a lot of big brother wrote a variety of plug-ins, but did not find a circle and some plug-maintenance, so there may be some problems.

Finally we found a level of God plug - cqhttp : This plug-Q report for the cool time via HTTP or WebSocket and accept the request to call the DLL interface Q cool, so you can use other language to write cool Q.

And then found a cool Q chiefs based asynchronous write python framework NoneBot , it would have to parse and process messages QQ robot received, and in the form of plug-ins, distributed messages corresponding to the command processor and natural language processing is to perform specific functions.

With these two, we will be able to write their own plug-ins to handle a variety received the news.

Reference URL are as follows:

1. https://cqhttp.cc/docs/4.14/#/       --cqhttp plug-in documentation

2. https://nonebot.cqp.moe/guide/    --NoneBot framework document

 

Installation process:

 

A. Preparations

 

1.Linux server

  First, we need a linux server, where I use the free white whore six months of Ali cloud server. Normally I put all port security groups are open, anyway, because the server is used to run this thing, regardless of the other, and some of our port will be used later, so a direct save trouble.

2. Connect Tools

  Here finalshell I use, I think it is very good use, transfer files and modify the windows host is very convenient.

 

Two .Docker installation

 

I am a Ubuntu system, the reference following the installation process:

https://yq.aliyun.com/articles/658984

Then there are other systems of the installation process:

https://www.runoob.com/docker/ubuntu-docker-install.html

Online tutorials are a lot of, I am here to leave a portal.

 

Three .Docker mirror coolq / wine-coolq configuration

 

We know, docker just a container, can be understood as common VMware virtual machines on our windows, we now have a container, need is a mirror.

Although the official also said cool Q Docker has been mirrored, but to save time, or can be directly used Gangster maintenance of the mirror is installed and enabled plug-ins.

Address: https://cqhttp.cc/docs/4.14/#/

About these basic introduction to the use of the above URLs are:

 

 

This is not complete, the following parameters are also some need their own party, for example, if I use the pro version, then you need to add extra COOLQ_URL download pro version.

My running configuration file paste (some documents they need to combine to modify)

sudo docker run -ti --rm --name cqhttp-test \
--network host \
-v $(pwd)/coolq:/home/user/coolq \
-e VNC_PASSWD=****** \
-p 9000:9000 \
-p 5700:5700 \
-e COOLQ_URL=https://dlsec.cqp.me/cqp-tuling \
-e COOLQ_ACCOUNT=QQ号 \
-e CQHTTP_POST_URL=http://127.0.0.1:9001 \
-e CQHTTP_SERVE_DATA_FILES=yes \
richardchien/cqhttp:latest

更多配置使用可以参考文档。

 

四.NoneBot的安装配置 

 

具体参考文档就行:https://nonebot.cqp.moe/guide/installation.html

安装下载还是很简单的,主要是在python环境里面运行。插件也可以自己跟着文档教程自己写。

 

五.日常使用事项

 

首先像我日常使用,主要就是放到一个screen里面去运行。

基本上用到的命令有:

-A  将所有的视窗都调整为目前终端机的大小。
-d <作业名称>  将指定的screen作业离线。
-h <行数>  指定视窗的缓冲区行数。
-m  即使目前已在作业中的screen作业,仍强制建立新的screen作业。
-r <作业名称>  恢复离线的screen作业。
-R  先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。
-s  指定建立新视窗时,所要执行的shell。
-S <作业名称>  指定screen作业的名称。
-v  显示版本信息。
-x  恢复之前离线的screen作业。
-ls或--list  显示目前所有的screen作业。
-wipe  检查目前所有的screen作业,并删除已经无法使用的screen作业。

一般是先创建一个新的screen,然后运行sudo docker run -ti --rm --name cqhttp-test \(上面容器的这段话)

最后才是运行python3 bot.py。

这样就能保证机器人24小时的运行啦。

Guess you like

Origin www.cnblogs.com/wushengyang/p/12575908.html