Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

部署Node Countdown Bot

Antares edited this page Sep 1, 2020 · 3 revisions

安装依赖项

此时默认用户已经装好了Node.js和yarn

Docker安装参考TUNA的教程

apt update
apt install -y git sqlite3

下载Node-Countdwon-Bot

cd /opt/bot
git clone https://github.com/AntaresQAQ/Node-Countdown-Bot.git

进行相关配置

cd Node-Countdown-Bot
yarn
cp config-default.json config.json

编辑config.json

{
  "koishi": {
    "type": "ws",
    "port": 6700,
    "server": "http://127.0.0.1:6700",
    "token": "<和 go-cqhttp 的 access_token 保持一致>",
    "secret": ""
  },
  "cqhttp_path": "/opt/bot/cqhttp",
  "commandPrefix": [
    "<指令前缀列表,自行修改>",
    "--",
    "!!"
  ],
  "debug": false
}

配置必要模块

这些模块必须配置正确,否则程序无法正常启动。

CodeRunner

cd /opt/bot/Node-Countdown-Bot/modules/CodeRunner/docker
docker build .
cd ..
vim config.json

参考index.jsconfigDefault对象编辑config.json,通过 docker images 命令找到 bot_code_runner 的 Image ID 填入配置文件的 docker_image 字段上。

PortraitAnimation

cd /opt/bot/Node-Countdown-Bot/modules/PortraitAnimation
vim config.json

参考index.jsconfigDefault对象编辑config.json

百度AI开放平台创建应用,获取 API Key 和 Secret Key

{
  "baidu_client_id": "<这里填写 API Key>",
  "baidu_client_secret": "<这里填写 Secret Key>"
}

Read

cd /opt/bot/Node-Countdown-Bot/modules/Read
vim config.json

阿里云 RAM 访问控制,创建子用户并开启只能语音交互的权限,得到 AccessKey ID 和 AccessKey Secret

阿里云智能语音交互平台创建应用,得到 AppKey

{
  "appKey": "<这里填写 AppKey>",
  "accessKeyId": "<这里填写 AccessKey ID>",
  "accessKeySecret": "<这里填写 AccessKey Secret>"
}

Weather

cd /opt/bot/Node-Countdown-Bot/modules/Weather
vim config.json

和风天气注册账号创建应用,得到 API KEY

{
  "api_key": "<这里填写 API KEY>"
}

使用 systemd

[Unit]
Description=CountdownBot service
After=network.target rc-local.service
Requires=rc-local.service

[Service]
Type=simple
WorkingDirectory=/opt/bot/Node-Countdown-Bot
User=root
Group=root
ExecStart=/usr/bin/node /opt/bot/Node-Countdown-Bot/run.js
RemainAfterExit=yes

Clone this wiki locally