I installed the bot on the Tencent Cloud.
# Too expensive! Not recommended!
System: Ubuntu Server 18.04.1 LTS 64bit
location: shanghai
CPU: 2 core
mem: 2GB
bandwidth: 4Mbps
Price: 50 yuan per month
Such as my new bot: 3059509092
Add one new port for ssh because my college's firewall bans the 22 port.
vim /etc/ssh/sshd_config
# Add new port
Port 40230
If use Ubuntu, we need to adjust the config of ssh becuase the default user is not root. First change the password.
sudo passwd root
Then revise the config of sshd.
sudo vi /etc/ssh/sshd_config
To
PermitRootLogin yes
PasswordAuthentication yes
At last
sudo service ssh restart
wget -c https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod 777 Miniconda3-latest-Linux-x86_64.sh #给执行权限
bash Miniconda3-latest-Linux-x86_64.sh #运行
cd /home/miniconda3/bin/
chmod 777 activate
. ./activate
# mirrors of tsinghua
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
# create new virtual env
conda create -n name python==<version>
wget https://github.com/Mrs4s/go-cqhttp/releases/download/v1.0.0-rc1/go-cqhttp_linux_amd64.tar.gz
tar -zxvf go-cqhttp_linux_amd64.tar.gz
cd go-cqhttp_linux_amd64.tar.gz
# run go-cqhttp first time.
./go-cqhttp
# choose the third item which is reverse websocket
Then modify the comfig.yml as shown blow.
uin:your bot qq
# port 8080 needs to be opened in the firewall.
universal: ws://127.0.0.1:8080/onebot/v11/ws/
# restart go-cqhttp
./go-cqhttp
need another package for audio item
sudo apt install -y ffmpeg
# first update the apt tool
sudo apt update
# install postgresql and postgresql-contrib
sudo apt install postgresql postgresql-contrib
Create new database
# switch usr
sudo su - postgres
psql
# 用户名↓ # 密码↓
CREATE USER uname WITH PASSWORD 'zhenxun'; # 创建用户
# 数据库名称↓ 所有者↓
CREATE DATABASE testdb OWNER uname; # 创建数据库
git clone -b main https://github.com/Ironieser/zhenxun_bot.git
cd zhenxun_bot
pip3 install poetry
poetry install
# if use conda virtual env , dont need to do.
poetry shell
## playwright install chromiuw which is the headless browser.
playwright install chromium
playwright install-deps chromium
configure the super root
vim .env.dev
# add qq of super user
SUPERUSERS=["your qq"]
vim configs/config.py
bind: str = ""
sql_name: str = "postgresql"
user: str = "uname"
password: str = "zhenxun"
address: str = "127.0.0.1"
port: str = "5432"
database: str = "testdb"
python3 bot.py