admin管理员组文章数量:1516870
Yunzai
看了很多网上讲解的云崽,都感觉没有完全讲清楚Linux用户使用docker方法(windows我没咋用过,这里windows怎么套娃我就不说了)
而且官方文档内的docker脚本中gitee内部三个js文件均没有同步成功,显示[session-a24140b4] Repository or file not found,难怪会报错三个js内容。
以下内容如果你觉得麻烦,我的云盘里面有配置好的(插件有些,gitee版本少几个插件,data已经删掉需要重新执行后面指令)
-----------视频教程-----------
哔哩哔哩
-----------文字教程-----------
服务器(或家里小主机、电脑)要求:2核2G(推荐配置) 硬盘60-100GB
推荐系统:alios
目前还没服务器(不想折腾家里)?点击这里获取nat低价服务器(有增值营业执照)
环境要求:有docker运行
docker安装两种
1.脚本
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
2.手动配置
Centos/Openanolis/OpenCloudOS适用以下代码
yum install docker-ce -y
(#代表下面适用于检测不到软件包使用)
#yum install -y yum-utils device-mapper-persistent-data lvm2
#yum-config-manager --add-repo .repo
#sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
#yum makecache
#yum install docker-ce -y
Debian 和 Ubuntu适用
apt update
apt upgrade -y
apt install curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates
curl -sS
| gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list
apt update
apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
上述安装完毕后,执行下方代码
status status docker//检测是否存在docker
status start docker//存在则启动docker服务
status enable docker//开机自启
------------我的配置好的安装方式------------
yunzai-bot资源下载链接:
提取码:qHeX
下载完我配置好的压缩包,然后上传(建议宝塔云控)
cd /(建议装主目录宝塔管理轻松)
wget (获取云盘下载链接粘贴在这里)
解压
unzip yunzai-bot.zip
再执行下载容器并配置容器
cd /yunzai-bot && docker-compose up -d && docker exec -it yunzai-bot node app login
配置完成,如果出现登录异常可看官方文档进行修改
------------手动安装方式------------
1.执行辅助脚本
cd / && bash <(curl -sSL )
2.脚本执行完后,不要先启动容器
3.配置yunzai-bot插件后(cd /yunzai-bot/yunzai/plugins)
cd /yunzai-bot/yunzai (大型插件可在这里clone)
cd ./plugins/example (js插件)
三个js报错可复制以下内容到js中
一言.js
import plugin from '../../lib/plugins/plugin.js'
import fetch from 'node-fetch'export class example extends plugin {constructor () {super({/** 功能名称 */name: '一言',/** 功能描述 */dsc: '简单开发示例',/** */event: 'message',/** 优先级,数字越小等级越高 */priority: 5000,rule: [{/** 命令正则匹配 */reg: '^#一言$',/** 执行方法 */fnc: 'hitokoto'}]})}/*** #一言* @param e oicq传递的事件参数e*/async hitokoto (e) {/** e.msg 用户的命令消息 */logger.info('[用户命令]', e.msg)/** 一言接口地址 */let url = '/'/** 调用接口获取数据 */let res = await fetch(url).catch((err) => logger.error(err))/** 判断接口是否请求成功 */if (!res) {logger.error('[一言] 接口请求失败')return await this.reply('一言接口请求失败')}/** 接口结果,json字符串转对象 */res = await res.json()/** 输入日志 */logger.info(`[接口结果] 一言:${res.hitokoto}`)/** 最后回复消息 */await this.reply(`一言:${res.hitokoto}`)}
}
主动复读.js
import plugin from '../../lib/plugins/plugin.js'export class example2 extends plugin {constructor () {super({name: '复读',dsc: '复读用户发送的内容,然后撤回',/** */event: 'message',priority: 5000,rule: [{/** 命令正则匹配 */reg: '^#复读$',/** 执行方法 */fnc: 'repeat'}]})}/** 复读 */async repeat () {/** 设置上下文,后续接收到内容会执行doRep方法 */this.setContext('doRep')/** 回复 */await this.reply('请发送要复读的内容', false, { at: true })}/** 接受内容 */doRep () {/** 复读内容 */this.reply(this.e.message, false, { recallMsg: 5 })/** 结束上下文 */this.finish('doRep')}
}
进群退群通知.js
import plugin from '../../lib/plugins/plugin.js'
import { segment } from 'oicq'
export class newcomer extends plugin {constructor () {super({name: '欢迎新人',dsc: '新人入群欢迎',/** */event: 'notice.group.increase',priority: 5000})}/** 接受到消息都会执行一次 */async accept () {/** 定义入群欢迎内容 */let msg = '欢迎新人!'/** 冷却cd 30s */let cd = 30if (this.e.user_id == Bot.uin) return/** cd */let key = `Yz:newcomers:${this.e.group_id}`if (await redis.get(key)) returnredis.set(key, '1', { EX: cd })/** 回复 */await this.reply([segment.at(this.e.user_id),// segment.image(),msg])}
}export class outNotice extends plugin {constructor () {super({name: '退群通知',dsc: 'xx退群了',event: 'notice.group.decrease'})/** 退群提示词 */this.tips = '退群了'}async accept () {if (this.e.user_id == Bot.uin) returnlet name, msgif (this.e.member) {name = this.e.member.card || this.e.member.nickname}if (name) {msg = `${name}(${this.e.user_id}) ${this.tips}`} else {msg = `${this.e.user_id} ${this.tips}`}logger.mark(`[退出通知]${this.e.logText} ${msg}`)await this.reply(msg)}
}
clone完大型插件或者配置好损坏的三个js后执行以下代码
cd /yunzai-bot && vim docker-compose.yaml
docker-compose.yaml文件配置(看你有啥插件就咋配置)
version: "3.9"
services:yunzai-bot:container_name: yunzai-botimage: swr.cn-south-1.myhuaweicloud.com/sirly/yunzai-bot:v3plusrestart: alwaysvolumes:- ./yunzai/config:/app/Yunzai-Bot/config/config/ # 配置文件- ./yunzai/genshin_config:/app/Yunzai-Bot/plugins/genshin/config # 配置文件- ./yunzai/logs:/app/Yunzai-Bot/logs # 日志文件- ./yunzai/data:/app/Yunzai-Bot/data # 数据文件- ./yunzai/plugins/example:/app/Yunzai-Bot/plugins/example # js 插件# 以下目录是插件目录,安装完插件后需要手动添加映射- ./yunzai/plugins/miao-plugin:/app/Yunzai-Bot/plugins/miao-plugin # 喵喵插件- ./yunzai/plugins/py-plugin:/app/Yunzai-Bot/plugins/py-plugin # 新py插件- ./yunzai/plugins/xiaoyao-cvs-plugin:/app/Yunzai-Bot/plugins/xiaoyao-cvs-plugin # 图鉴插件- ./yunzai/plugins/guoba-plugin:/app/Yunzai-Bot/plugins/guoba-plugin # 锅巴插件- ./yunzai/plugins/TRSS-Plugin:/app/Yunzai-Bot/plugins/TRSS-Plugin- ./yunzai/plugins/xianxin-plugin:/app/Yunzai-Bot/plugins/xianxin-plugin- ./yunzai/plugins/yenai-plugin:/app/Yunzai-Bot/plugins/yenai-pluginports:- 50831:50831#锅巴插件映射端口depends_on:redis: { condition: service_healthy }redis:container_name: yunzai-redisimage: redis:alpinerestart: alwaysvolumes:- ./redis/data:/data- ./redis/logs:/logshealthcheck:test: ["CMD", "redis-cli", "PING"]start_period: 10sinterval: 5stimeout: 1s
配置完后即可使用以下指令
cd /yunzai-bot && docker-compose up -d && docker exec -it yunzai-bot node app login
然后如果机器人私聊你消息,则配置成功
每次上传完插件,需修改docker-compose.yaml
并执行以下命令
cd /yunzai-bot && docker-compose up -d
由于CSDN审核搬家未通过,先发表一篇文章
如果要引用请保留下面版权
文章链接: .html
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自诺依阁的日常记录 !
本文标签: Yunzai
版权声明:本文标题:Yunzai 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/web/1686611743a16951.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论