2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00
This commit is contained in:
leiyilu 2022-06-22 12:51:47 +08:00
parent b6c9110141
commit e531d9b0bf
2 changed files with 131 additions and 109 deletions

View File

@ -1,13 +1,24 @@
import { segment } from "oicq";
cimport {
segment
} from "oicq";
import fs from "fs";
import lodash from "lodash";
import { createRequire } from "module";
import { exec } from "child_process";
import { Cfg } from "../components/index.js";
import {
createRequire
} from "module";
import {
exec
} from "child_process";
import {
Cfg
} from "../components/index.js";
import Common from "../components/Common.js";
import {
init
} from "../apps/xiaoyao_image.js"
const require = createRequire(import.meta.url);
const require = createRequire(
import.meta.url);
export const rule = {
@ -53,7 +64,9 @@ export async function updateRes(e) {
if (fs.existsSync(`${resPath}/xiaoyao-plus/`)) {
e.reply("开始尝试更新,请耐心等待~");
command = `git pull`;
exec(command, { cwd: `${resPath}/xiaoyao-plus/` }, function (error, stdout, stderr) {
exec(command, {
cwd: `${resPath}/xiaoyao-plus/`
}, function(error, stdout, stderr) {
//console.log(stdout);
if (/Already up to date/.test(stdout)) {
e.reply("目前所有图片都已经是最新了~");
@ -61,12 +74,14 @@ export async function updateRes(e) {
}
let numRet = /(\d*) files changed,/.exec(stdout);
if (numRet && numRet[1]) {
init()
e.reply(`报告主人,更新成功,此次更新了${numRet[1]}个图片~`);
return true;
}
if (error) {
e.reply("更新失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。");
} else {
init()
e.reply("图片加量包更新成功~");
}
});
@ -79,6 +94,7 @@ export async function updateRes(e) {
if (error) {
e.reply("角色图片加量包安装失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。");
} else {
init()
e.reply("角色图片加量包安装成功!您后续也可以通过 #图鉴更新 命令来更新图像");
}
});
@ -100,7 +116,9 @@ export async function updateMiaoPlugin(e) {
} else {
e.reply("正在执行更新操作,请稍等");
}
exec(command, { cwd: `${_path}/plugins/xiaoyao-cvs-plugin/` }, function (error, stdout, stderr) {
exec(command, {
cwd: `${_path}/plugins/xiaoyao-cvs-plugin/`
}, function(error, stdout, stderr) {
//console.log(stdout);
if (/Already up to date/.test(stdout)) {
e.reply("目前已经是最新版图鉴插件了~");
@ -115,7 +133,9 @@ export async function updateMiaoPlugin(e) {
redis.set("xiaoyao:restart-msg", JSON.stringify({
msg: "重启成功,新版图鉴插件已经生效",
qq: e.user_id
}), { EX: 30 });
}), {
EX: 30
});
timer = setTimeout(function() {
let command = "npm run restart";
exec(command, function(error, stdout, stderr) {
@ -123,7 +143,8 @@ export async function updateMiaoPlugin(e) {
if (/Yunzai not found/.test(error)) {
e.reply("自动重启失败,请手动重启以应用新版图鉴插件。请使用 npm run start 命令启动Yunzai-Bot");
} else {
e.reply("重启失败!\nError code: " + error.code + "\n" + error.stack + "\n 请稍后重试。");
e.reply("重启失败!\nError code: " + error.code + "\n" + error.stack +
"\n 请稍后重试。");
}
return true;
}

View File

@ -48,6 +48,7 @@
"丘丘岩盔王": ["岩丘丘王"],
"丘丘雷兜王": ["雷丘丘王"],
"丘丘霜铠王": ["冰丘丘王"],
"丘丘人":["丘丘人"],
"射手丘丘人": ["弓箭丘丘人"],
"冰弹丘丘人": ["冰丘丘人"],
"冰箭丘丘人": ["冰弓丘丘人"],