-
安装NekoBox:
- 首先确保已安装Node.js和npm。
- 运行以下命令安装NekoBox:
npm install neko-box@latest
-
初始化数据库:
- 初始化数据库并创建必要的表:
neko init
- 按照提示输入数据库密码,并保存配置文件。
- 初始化数据库并创建必要的表:
-
配置启动命令:
- 修改
nekobox.js文件中的botToken,替换为你的Discord bot token。 - 启动NekoBox:
node nekobox.js
- 修改
-
Discord应用授权:
- 申请Discord开发者访问权限,创建新的应用。
- 生成Bot User OAuth2 令牌,将其替换到
nekobox.js中的botToken字段。
-
配置Webhook:
- 创建一个Discord Webhook URL,
https://yourdomain.com:300/api/webhook。 - 在
nekoconfig.json中添加:{ "webhook": { "url": "https://yourdomain.com:300/api/webhook", "path": "/api/webhook", "secret": "your-secret-key" } }
- 创建一个Discord Webhook URL,
-
用户管理配置:
- 在数据库中创建用户表,字段包括
userId、username、email等。 - 使用SQL语句创建初始用户,如管理员账号:
INSERT INTO users (username, email, password, role) VALUES ('admin', 'admin@example.com', 'password', 'admin');
- 在数据库中创建用户表,字段包括
-
直播功能配置:
- 配置视频源和流媒体软件(如ffmpeg和rtmp服务器)。
- 在
nekoconfig.json中添加直播配置:{ "live": { "sources": [ { "type": "rtmp", "url": "rtmp://live-akamai.example.com/live", "stream_name": "nekoLive", "title": "Neko Live", "category": "游戏" } ] } }
-
添加互动命令:
-
在
nekobox.js中添加命令监听器:bot.on('messageCreate', (message) => { // 处理消息 if (message.content.startsWith('@')) { const username = message.content.split('@')[1].replace(/ (#|@)/, '').trim(); bot.sendMessage(new Message(`${username} @你`, message.channel.id)); } }); bot.on('commandCreate', (command) => { // 处理命令 if (command.name === '!ping') { bot.sendMessage(new Message('pong!', command.channel.id)); } });
-
-
部署NekoBox:
- 本地运行:
pm2 start nekobox.js
使用pm2管理进程,确保服务持续运行。
- 远程部署:
- 使用Docker构建镜像:
docker build -t neko-box .
- 启动容器:
docker run -p 300:300 -d neko-box
- 配置Nginx作为反向代理:
server { listen 80; server_name yourdomain.com; location / { proxy_pass http://localhost:300; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /ws { proxy_pass http://localhost:300; proxy_set_header Upgrade WebSocket; proxy_set_header Connection "Upgrade"; } }
- 使用Docker构建镜像:
- 本地运行:
-
测试和调试:
- 访问Discord服务器,确保NekoBox成功连接。
- 测试直播功能和互动命令,确保一切正常工作。
- 检查数据库连接和数据是否正确。
通过以上步骤,你可以成功配置并运行NekoBox,创建一个功能丰富的Discord直播平台。
