Yunzai-Bot icon indicating copy to clipboard operation
Yunzai-Bot copied to clipboard

Linux环境搭建

Open Le-niao opened this issue 3 years ago • 25 comments

linux服务器环境搭建教程

准备一个服务器,要求不高,1核1g都可以, qq小号,米游社cookie,下面开始教程

这里以腾讯轻量应用服务器CentOS 8.2为例。 选择Node.js镜像 (Node版本至少v14以上)

Node.js镜像

傻瓜式安装过程

创建好后登录服务器,切换root权限
sudo -i 

执行脚本,自动搭建

CentOS 8.2
curl -sL http://mtw.so/5U67tU | bash

Ubuntu 18.04.1 LTS
curl -sL http://mtw.so/5EpvSF | sudo -E bash -

进入项目目录
cd Yunzai-Bot
首次运行,按提示输入完成配置登录
node app

后台运行 or 停止
npm start / npm stop

其他

如何获取米游社cookie

手动搭建环境(CentOS)

切换root权限

sudo -i

安装nodejs

yum install -y dnf dnf module install nodejs:16 -y

安装git

yum -y install git

安装并运行redis

yum -y install redis && redis-server --daemonize yes

克隆项目

git clone https://github.com/Le-niao/Yunzai-Bot.git

克隆失败的可以用码云

git clone https://gitee.com/Le-niao/Yunzai-Bot.git

安装模块

cd Yunzai-Bot

安装cnpm npm install cnpm -g --registry=https://registry.npm.taobao.org

用cnpm安装,主要安装Puppeteer,下载chrome浏览器 cnpm install Puppeteer安装

安装chrome依赖库

yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y && yum install libdrm libgbm libxshmfence -y && yum install nss -y && yum update nss -y;

安装中文字体

yum groupinstall fonts -y

运行

node app

后台运行 or 停止 npm start / npm stop

运行成功

运行成功

Le-niao avatar Nov 20 '21 04:11 Le-niao

这个搭建怎么找到文件修改配置

xueshuaib avatar May 01 '22 09:05 xueshuaib

Error: Could not find expected browser (chrome) locally. Run npm install to download the correct` Chromium revision (982053).

Aphlos1530 avatar May 06 '22 06:05 Aphlos1530

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received 206_122_285_581

xwt000203 avatar May 06 '22 14:05 xwt000203

linux 输出的角色卡片是乱码 的怎么解决呀

Abortbeen avatar May 15 '22 07:05 Abortbeen

无法显示中文

Abortbeen avatar May 15 '22 07:05 Abortbeen

无法显示中文

安装中文字体 yum groupinstall fonts -y

Le-niao avatar May 15 '22 09:05 Le-niao

建议更新脚本,将安装chrome放到 安装npm依赖前面 现在的版本npm会自动访问谷歌安装chrome 导致国内服务器卡住

RealHeart avatar May 19 '22 17:05 RealHeart

有无更新命令?

llightos avatar Jun 02 '22 09:06 llightos

有无更新命令?

使用机器人命令: #更新 #重启

或命令行: git pull && npm i && npm restart

RealHeart avatar Jun 02 '22 09:06 RealHeart

[2022-06-07T21:49:47.557] [ERROR] [iMac:484436257] - 报错:global.js Error: ENOENT: no such file or directory, scandir './resources/global_img' at Object.readdirSync (node:fs:1405:3) at readdirectory (file:///opt/Yunzai-Bot/lib/app/global.js:71:18) at init (file:///opt/Yunzai-Bot/lib/app/global.js:64:3) at file:///opt/Yunzai-Bot/lib/app/global.js:25:1 at ModuleJob.run (node:internal/modules/esm/module_job:198:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:385:24) at async loadApp (file:///opt/Yunzai-Bot/lib/init.js:171:19) at async init (file:///opt/Yunzai-Bot/lib/init.js:47:3) at async Client. (file:///opt/Yunzai-Bot/app.js:51:3) { errno: -2, syscall: 'scandir', code: 'ENOENT', path: './resources/global_img' }

Bai3396 avatar Jun 07 '22 13:06 Bai3396

关闭登录保护还要验证码,需要怎么发送

ghost avatar Jun 08 '22 10:06 ghost

IMG_20220609_081103.jpg这怎么回事

QYYJN avatar Jun 09 '22 00:06 QYYJN

cnpm install时报错 微信图片_20220612013211

编辑:已解决,不要使用腾讯自带的node.js,直接用CentOS8.2执行一键安装即可

Yamakoer avatar Jun 12 '22 05:06 Yamakoer

能不能做一个微信版本的机器人,改一下接口代码

Kevinli1987 avatar Jun 14 '22 07:06 Kevinli1987

sill idealTree buildDeps cnpm安装失败 换过淘宝和npmmirror镜像还是不行 腾讯云上挂不了梯子... 佬佬,救救

Russell987 avatar Jun 18 '22 10:06 Russell987

您好,我已经收到您的邮件!

Kevinli1987 avatar Jun 18 '22 10:06 Kevinli1987

您好,我已经收到您的邮件!

Kevinli1987 avatar Jul 29 '22 07:07 Kevinli1987

能否提供一个低版本2.1.8的克隆链接,现在已经找不到之前的版本了

Happygoing-ding avatar Aug 04 '22 03:08 Happygoing-ding

image 一键安装这样了,是因为什么

507840158 avatar Aug 05 '22 07:08 507840158

自动搭建脚本的链接失效了wwwwwwwwwwwwwwwwwww

JiJiang233 avatar Aug 06 '22 17:08 JiJiang233

自动脚本能修复一下吗?

zangxycoding avatar Aug 09 '22 12:08 zangxycoding

image 这些个报错是啥意思啊,还有输入指令为什么都是角色查询呢

526882956 avatar Sep 02 '22 07:09 526882956

您好,我已经收到您的邮件!

Kevinli1987 avatar Sep 02 '22 07:09 Kevinli1987

[root@VM-20-14-centos Yunzai-Bot]# npm start

[email protected] start pm2 start ./config/pm2/pm2.json

[PM2] Applying action restartProcessId on app [Yunzai-Bot](ids: [ 1 ]) [PM2][ERROR] Process 1 not found Process 1 not found /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/API.js:1717 acted.push(proc.pm2_env ? proc.pm2_env.pm_id : proc.pm_id) ^

TypeError: Cannot read properties of undefined (reading 'pm2_env') at /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/API.js:1717:25 at Array.forEach () at API.speedList (/root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/API.js:1716:18) at /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/binaries/CLI.js:301:15 at wrapper (/root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/async/internal/once.js:12:16) at replenish (/root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/async/internal/eachOfLimit.js:76:25) at iterateeCallback (/root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/async/internal/eachOfLimit.js:65:17) at /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/async/internal/onlyOnce.js:12:16 at /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/binaries/CLI.js:292:11 at /root/Yunzai-Bot/node_modules/.pnpm/[email protected]/node_modules/pm2/lib/API.js:330:21

jiexi22 avatar Sep 03 '22 06:09 jiexi22

可以弄成微信群聊的接口吗

YemingQing avatar Sep 07 '22 01:09 YemingQing

node:internal/modules/cjs/loader:956
  const err = new Error(message);
              ^

Error: Cannot find module '@redis/client/dist/lib/commands/generic-transformers'
Require stack:
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js:9:30)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js'
  ]
}

最后启动机器人(node app)的时候报了这个错误,大家有遇到么?

SunnerSun avatar Oct 02 '22 13:10 SunnerSun

您好,我已经收到您的邮件!

Kevinli1987 avatar Oct 02 '22 13:10 Kevinli1987

node:internal/modules/cjs/loader:956
  const err = new Error(message);
              ^

Error: Cannot find module '@redis/client/dist/lib/commands/generic-transformers'
Require stack:
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js:9:30)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js'
  ]
}

最后启动机器人(node app)的时候报了这个错误,大家有遇到么?

我也遇到了这个问题 第一次启动

jyh111 avatar Oct 02 '22 14:10 jyh111

node:internal/modules/cjs/loader:956
  const err = new Error(message);
              ^

Error: Cannot find module '@redis/client/dist/lib/commands/generic-transformers'
Require stack:
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js
- /root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js:9:30)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/ADD.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/bloom/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/commands/index.js',
    '/root/Yunzai-Bot/node_modules/_@[email protected]@@redis/bloom/dist/index.js'
  ]
}

最后启动机器人(node app)的时候报了这个错误,大家有遇到么?

我也遇到了这个问题 第一次启动

我弄好了,应该是安装指定package.json版本的redis cnpm install [email protected] 或者可以考虑关掉再重启redis服务

jyh111 avatar Oct 02 '22 16:10 jyh111

十分感谢,我去试一试

SunnerSun avatar Oct 03 '22 08:10 SunnerSun