Install QQ robot on Ubuntu 16.04

Install QQ Robot on Ubuntu#

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.

Install 酷Q HTTP

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

supervisord start-up self-start##

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

Configuration information##

Account configuration file###

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

Filter and report HTTP configuration files###

{". or":[{"message_type":"private"},{"message_type":"group","anonymous":{".eq":null},"raw_message":{".regex":"CQ:at,qq=2450184313|^come out$"}},{"post_type":"request"}]}

Firewall##

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

Install QQ robot on Ubuntu 16.04
Install non-portable QQ on ubuntu
install vscode on ubuntu18
Install Redis on Ubuntu
Install R4 on ubuntu20
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
Install docker on Ubuntu
Install Docker on ubuntu18.04
Install nodejs10 on Ubuntu16
Install mysql on Ubuntu 14.04
Install Django on ubuntu
Install Pytorch+CUDA on Ubuntu 16.04
Install Python3 on Ubuntu 14.04
Install rJava on Ubuntu18
Install JDK10+ on Ubuntu
Install Python3 on Ubuntu 16.04
Install KDE on Ubuntu16.04.2
Install Docker on Ubuntu18
Install Python3.7 on Ubuntu
Install flashplayer on Ubuntu
Docker practice (1): install Docker on Ubuntu 16.04
Install ubuntu on virtual machine
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Install Python 3.7 on Ubuntu 18.04 LTS
Install Android Studio on Ubuntu
Install scrapy framework on ubuntu
Install Mysql offline on Ubuntu
Install Oracle Java8 on Ubuntu
Install Odoo 11 stack on Ubuntu 16.04
Install Go locale on Ubuntu16
Install common software on Ubuntu 16.04
Install Docker on Ubuntu 18.04 offline
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
Install Tenda u12 driver on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
Install and configure MySQL on Ubuntu
Install Chef server workstation on Ubuntu 18.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
Install botan2 encryption library on ubuntu
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
Docker ubuntu: install python-PIL-image environment on 14.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04