Looking at it now, it seems that QQ robots only have cool Q robots and Docker can run on Linux.
Then start to install the cool Q robot, the resource consumption is not very large, it takes up about 180M of memory.
First install docker
CoolQ official website provides docker
COOLQ Docker 2.0
But I plan to develop some functions through HTTP
, so I chose CQHTTP Docker with HTTP
plugin made by the big guy
First of all, the pull
mirror, I think the download is relatively slow, hang a screen
slowly
docker pull richardchien/cqhttp:latest
After the download is complete, start the container for testing
docker run -ti --rm --name coolq \
- v /home/coolq:/home/user/coolq \ #Mount the host directory to the container for persisting cool Q program files
- p 9000:9000 \ #noVNC port, used to control CoolQ from the browser
- p 5700:5700 \ #Port opened by HTTP API plug-in
- e COOLQ_ACCOUNT=123456 \ #QQ account to log in, optional but recommended
- e CQHTTP_POST_URL=http://example.com:8080 \ #Incident report address
- e VNC_PASSWD=111111111 \ #noVnc password
- e CQHTTP_SERVE_DATA_FILES=yes \ #Allow access to CoolQ data files via HTTP interface
richardchien/cqhttp:latest
At this point, you can log in to noVNC
to view and log in
If there is no problem with the test, just change the --rm
in the startup parameters to -d
to save and run
docker start coolq
docker stop coolq
Since I have a timed task how often the machine is turned on and off, but coolq
will not start automatically after booting, select supervisord
to start automatically
Pay attention to autorestart=false
, because after starting coolq
, it will be exit(0)
, so supervisord
will keep trying to restart, we only need him to start it once.
[ program:coolq]
command=docker start coolq
stderr_logfile=/var/log/supervisor/error_coolq.log
stdout_logfile=/var/log/supervisor/coolq.log
directory=/home
autostart=true
user=docker
autorestart=false
Note that the report address cannot be 127.0.0.1
, because the container has its own 127.0.0.1
, in general, the machine ip
can be used as the report address
[123456789]
use_ws =false
use_ws_reverse =false
serve_data_files = yes
access_token =11111111111111111
log_level = error
post_url = http://example.com:8080
secret =11111111111111111
show_log_console =false
event_filter = filter.json
{". or":[{"message_type":"private"},{"message_type":"group","anonymous":{".eq":null},"raw_message":{".regex":"CQ:at,qq=2450184313|^come out$"}},{"post_type":"request"}]}
Because Docker
directly changes iptables
and has a higher priority than ufw
, you cannot control the opening and closing of its listening ports through ufw
, you need to manually configure Docker
information
# vim /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
# vim /etc/ufw/before.rules
# * Add the following content before the filter
# 172.17.0.0 /16 is the docker bridge address, which may be different
* nat
: POSTROUTING ACCEPT [0:0]-A POSTROUTING !-o docker0 -s 172.17.0.0/16-j MASQUERADE
COMMIT
# vim /etc/default/docker
# Add this configuration information
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 --iptables=false"
# vim /etc/docker/daemon.json
# Create without this file
{" iptables":false}
Restart daemon
, docker
, ufw
systemctl daemon-reload && systemctl restart docker && ufw reload
Recommended Posts