同步 TRSS-Yunzai 部分更新 (#242)

* 同步 TRSS-Yunzai 部分更新

* 错误修复
This commit is contained in:
时雨◎星空 2023-09-06 03:00:17 +08:00 committed by GitHub
parent 7b12cedc83
commit ff8a9289ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 199 additions and 353 deletions

8
.npmrc
View File

@ -1,6 +1,2 @@
# sqlite3
node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3
# pup
PUPPETER_DOWNLOAD_BASE_URL=https://npmmirror.com/mirrors/chrome-for-testing
# 改为 npm 依赖安装方式
node-linker=hoisted
registry=https://registry.npmmirror.com
node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3

View File

@ -1,88 +1,39 @@
const os = require("os");
const { existsSync, realpathSync } = require("fs");
const { execSync } = require("child_process");
const arch = os.arch();
/**
* Downloa
*/
let skipDownload = false;
/**
* Path
*/
let executablePath;
/**
* windows path
*/
const win32Edge =
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";
/**
* linux | android
*/
if (process.platform == "linux" || process.platform == "android") {
const chromium = [
"whereis chrome-browser",
"whereis chrome",
"whereis chromium-browser",
"whereis chromium",
"whereis firefox",
];
/**
* get path
*/
for (const item of chromium) {
try {
const chromiumPath = execSync(item).toString().split(" ")[1]?.trim();
if (chromiumPath) {
skipDownload = true;
executablePath = realpathSync(chromiumPath);
console.info("[Chromium] start");
break;
}
} catch (error) {
console.error("Failed to get Chromium path:", error);
continue;
const os = require("os")
const { existsSync, realpathSync } = require("fs")
const { execSync } = require("child_process")
const arch = os.arch()
let skipDownload = false
let executablePath
if (process.platform == "linux" || process.platform == "android")
for (const item of [
"chromium",
"chromium-browser",
"chrome",
"chrome-browser",
]) try {
const chromiumPath = execSync(`command -v ${item}`).toString().trim()
if (chromiumPath && existsSync(chromiumPath)) {
executablePath = realpathSync(chromiumPath)
break
}
}
/**
* not path
*/
if (!skipDownload) {
/**
* search
*/
const arr = [
"/usr/bin/chromium",
"/snap/bin/chromium",
"/usr/bin/chromium-browser",
];
for (const item of arr) {
if (existsSync(item)) {
skipDownload = true;
executablePath = item;
console.info("[Chromium] start");
break;
}
}
}
/**
* arm64/arrch64
*/
if (arch == "arm64" || arch == "aarch64") {
console.info("[arm64/aarch64] system");
skipDownload = true;
}
} else if (process.platform == "win32" && existsSync(win32Edge)) {
/**
* win32 Edge
*/
skipDownload = true;
executablePath = win32Edge;
console.info("[Win32 Edge] start");
} catch (err) {}
if (!executablePath) for (const item of [
"C:/Program Files/Google/Chrome/Application/chrome.exe",
"C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe",
"/usr/bin/chromium",
"/usr/bin/chromium-browser",
"/snap/bin/chromium",
]) if (existsSync(item)) {
executablePath = item
break
}
/**
* @type {import("puppeteer").Configuration}
*/
module.exports = {
skipDownload,
executablePath,
};
if (executablePath || arch == "arm64" || arch == "aarch64") {
(typeof logger == "object" ? logger : console).info(`[Chromium] ${executablePath}`)
skipDownload = true
}
module.exports = { skipDownload, executablePath }

View File

@ -15,14 +15,16 @@ class Cfg {
/** 初始化配置 */
initCfg () {
let path = './config/config/'
let pathDef = './config/default_config/'
let path = 'config/config/'
let pathDef = 'config/default_config/'
const files = fs.readdirSync(pathDef).filter(file => file.endsWith('.yaml'))
for (let file of files) {
if (!fs.existsSync(`${path}${file}`)) {
fs.copyFileSync(`${pathDef}${file}`, `${path}${file}`)
}
}
if (!fs.existsSync("data")) fs.mkdirSync("data")
if (!fs.existsSync("resources")) fs.mkdirSync("resources")
}
/** 机器人qq号 */
@ -82,7 +84,7 @@ class Cfg {
get package () {
if (this._package) return this._package
this._package = JSON.parse(fs.readFileSync('./package.json', 'utf8'))
this._package = JSON.parse(fs.readFileSync('package.json', 'utf8'))
return this._package
}
@ -129,7 +131,7 @@ class Cfg {
* @param name 名称
*/
getYaml (type, name) {
let file = `./config/${type}/${name}.yaml`
let file = `config/${type}/${name}.yaml`
let key = `${type}.${name}`
if (this.config[key]) return this.config[key]

View File

@ -1,121 +1,76 @@
import cfg from './config.js'
import common from '../common/common.js'
import { createClient } from 'redis'
import { exec } from 'node:child_process'
import cfg from "./config.js"
import common from "../common/common.js"
import { createClient } from "redis"
import { exec } from "node:child_process"
/**
* 初始化全局redis客户端
*/
export default async function redisInit () {
export default async function redisInit() {
const rc = cfg.redis
let redisUn = rc.username || ''
let redisPw = rc.password ? `:${rc.password}` : ''
if (rc.username || rc.password) redisPw += '@'
let redisUrl = `redis://${redisUn}${redisPw}${rc.host}:${rc.port}/${rc.db}`
// 初始化reids
const redisUn = rc.username || ""
let redisPw = rc.password ? `:${rc.password}` : ""
if (rc.username || rc.password)
redisPw += "@"
const redisUrl = `redis://${redisUn}${redisPw}${rc.host}:${rc.port}/${rc.db}`
let client = createClient({ url: redisUrl })
try {
logger.mark(`正在连接 Redis...`)
logger.mark(redisUrl)
logger.info(`正在连接 ${logger.blue(redisUrl)}`)
await client.connect()
} catch (error) {
let err = error.toString()
} catch (err) {
logger.error(`Redis 错误:${logger.red(err)}`)
if (err != 'Error: connect ECONNREFUSED 127.0.0.1:6379') {
logger.error('连接 Redis 失败!')
process.exit()
}
const cmd = "redis-server --save 900 1 --save 300 10 --daemonize yes" + await aarch64()
logger.info("正在启动 Redis...")
await execSync(cmd)
await common.sleep(1000)
/** windows */
if (process.platform == 'win32') {
logger.error('请先启动 Redis')
logger.error('Window 系统:双击 redis-server.exe 启动')
try {
client = createClient({ url: redisUrl })
await client.connect()
} catch (err) {
logger.error(`Redis 错误:${logger.red(err)}`)
logger.error(`请先启动 Redis${logger.blue(cmd)}`)
process.exit()
} else {
let cmd = 'redis-server --save 900 1 --save 300 10 --daemonize yes'
let arm = await aarch64()
/** 安卓端自动启动redis */
if (arm) {
client = await startRedis(`${cmd}${arm}`, client, redisUrl)
} else {
logger.error('请先启动 Redis')
logger.error(`Redis 启动命令:${cmd} ${arm}`)
process.exit()
}
}
}
client.on('error', async (err) => {
let log = { error: (log) => console.log(log) }
if (typeof logger != 'undefined') log = logger
if (err == 'Error: connect ECONNREFUSED 127.0.0.1:6379') {
if (process.platform == 'win32') {
log.error('请先启动 Redis')
log.error('Window 系统:双击 redis-server.exe 启动')
} else {
let cmd = 'redis-server --save 900 1 --save 300 10 --daemonize yes'
let arm = await aarch64()
log.error('请先启动 Redis')
log.error(`Redis 启动命令:${cmd} ${arm}`)
}
} else {
log.error(`Redis 错误:${err}`)
}
client.on("error", async err => {
logger.error(`Redis 错误:${logger.red(err)}`)
const cmd = "redis-server --save 900 1 --save 300 10 --daemonize yes" + await aarch64()
logger.error(`请先启动 Redis${cmd}`)
process.exit()
})
/** 全局变量 redis */
global.redis = client
logger.mark('Redis 连接成功')
logger.info("Redis 连接成功")
return client
}
async function aarch64 () {
let tips = ''
async function aarch64() {
if (process.platform == "win32")
return ""
/** 判断arch */
let arch = await execSync('arch')
if (arch.stdout && arch.stdout.includes('aarch64')) {
const arch = await execSync("uname -m")
if (arch.stdout && arch.stdout.includes("aarch64")) {
/** 判断redis版本 */
let v = await execSync('redis-server -v')
let v = await execSync("redis-server -v")
if (v.stdout) {
v = v.stdout.match(/v=(\d)./)
/** 忽略arm警告 */
if (v && v[1] >= 6) tips = ' --ignore-warnings ARM64-COW-BUG'
if (v && v[1] >= 6)
return " --ignore-warnings ARM64-COW-BUG"
}
}
tips = ' --ignore-warnings ARM64-COW-BUG'
return tips
return ""
}
/** 尝试自动启动redis */
async function startRedis (cmd, client, redisUrl) {
logger.mark('正在启动 Redis...')
await execSync(cmd)
await common.sleep(500)
try {
/** 重新链接 */
client = createClient({ url: redisUrl })
await client.connect()
} catch (error) {
let err = error.toString()
logger.mark(err)
logger.error('请先启动 Redis')
logger.error(`Redis 启动命令:${cmd}`)
process.exit()
}
return client
}
async function execSync (cmd) {
function execSync (cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
resolve({ error, stdout, stderr })
})
})
}
}

View File

@ -25,7 +25,7 @@ async function registerRendererBackends () {
logger.warn('渲染后端 ' + (renderer.id || subFolder.name) + ' 不可用')
}
rendererBackends[renderer.id] = renderer
logger.mark('[渲染后端加载]: 导入 ' + renderer.id)
logger.info(`加载渲染后端 ${renderer.id}`)
}
}

View File

@ -18,40 +18,36 @@
},
"dependencies": {
"art-template": "^4.13.2",
"chalk": "^5.2.0",
"chalk": "^5.3.0",
"chokidar": "^3.5.3",
"https-proxy-agent": "5.0.1",
"https-proxy-agent": "7.0.1",
"icqq": "^0.5.3",
"image-size": "^1.0.2",
"inquirer": "^8.2.5",
"inquirer": "^9.2.10",
"lodash": "^4.17.21",
"log4js": "^6.9.1",
"md5": "^2.3.0",
"moment": "^2.29.4",
"node-fetch": "^3.3.1",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"node-xlsx": "^0.21.2",
"node-xlsx": "^0.23.0",
"oicq": "^2.3.1",
"pm2": "^5.3.0",
"puppeteer": "^20.2.1",
"redis": "^4.6.6",
"sequelize": "^6.31.1",
"puppeteer": "^21.1.1",
"redis": "^4.6.8",
"sequelize": "^6.32.1",
"sqlite3": "^5.1.6",
"yaml": "^2.2.2"
"yaml": "^2.3.2"
},
"devDependencies": {
"eslint": "^8.41.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint": "^8.48.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.0.2",
"eslint-plugin-promise": "^6.1.1",
"express": "^4.18.2",
"express-art-template": "^1.0.1"
},
"workspaces": [
"renderers/*",
"plugins/*"
],
"imports": {
"#miao": "./plugins/miao-plugin/components/index.js",
"#miao.models": "./plugins/miao-plugin/models/index.js"

View File

@ -54,8 +54,8 @@
|#记录帮助|抽卡记录导入说明|
|#导出记录|抽卡记录xlsx导出|
|#导出记录json|抽卡记录json导出|
|xlsx文件导入|xlsx导入统一可交换祈愿记录v2.2,需要加好友|
|json文件导入|json导入统一可交换祈愿记录v2.2,需要加好友|
|xlsx文件导入|xlsx导入统一可交换祈愿记录v2.2|
|json文件导入|json导入统一可交换祈愿记录v2.2|
| 其他指令 | 说明|
| :---------------- | --------------- |

View File

@ -162,9 +162,7 @@ export class abbrSet extends plugin {
msg.push(`${num}.${list[i]}`)
}
let title = `${role.name}别名,${list.length}`
msg = await common.makeForwardMsg(this.e, [title, msg.join("\n")], title)
msg = await common.makeForwardMsg(this.e, [msg.join("\n")], `${role.name}别名,${list.length}`)
await this.e.reply(msg)
}

View File

@ -119,8 +119,6 @@ export class gacha extends plugin {
/** 初始化创建配置文件 */
async init () {
GachaData.getStr()
let file = './plugins/genshin/config/gacha.set.yaml'
if (fs.existsSync(file)) return

View File

@ -54,7 +54,7 @@ export class gcLog extends plugin {
]
})
this.androidUrl = 'docs.qq.com/doc/DUWpYaXlvSklmVXlX'
this.androidUrl = 'https://docs.qq.com/doc/DUWpYaXlvSklmVXlX'
}
async init () {
@ -145,12 +145,6 @@ export class gcLog extends plugin {
return
}
let friend = Bot.fl.get(Number(this.e.user_id))
if (!friend) {
await this.reply('无法发送文件,请先添加好友')
return
}
let exportLog = new ExportLog(this.e)
if (this.e.msg.includes('json')) {
@ -189,18 +183,18 @@ export class gcLog extends plugin {
}
async help () {
await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助.png`))
await this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助.png`))
}
async helpPort () {
let msg = this.e.msg.replace(/#|帮助/g, '')
if (['电脑', 'pc'].includes(msg)) {
await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助-电脑.png`))
await this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助-电脑.png`))
} else if (['安卓'].includes(msg)) {
await this.e.reply(`安卓抽卡记录获取教程:${this.androidUrl}`)
} else if (['苹果', 'ios'].includes(msg)) {
await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助-苹果.png`))
await this.e.reply(segment.image(`file://${_path}/resources/logHelp/记录帮助-苹果.png`))
}
}

View File

@ -45,17 +45,14 @@
title: 十连 十连2 定轨 十连武器
desc: 真实模拟抽卡
- icon: 浮世
title: '刻晴突破,刻晴素材'
desc: 米游社友人A的角色素材图
- icon: 刻晴
title: 刻晴攻略
desc: 西风驿站攻略图
# - icon: 米游社
# title: '#公告 #资讯 #公告列表'
# desc: '原神米游社公告资讯'
title: '刻晴突破、素材、攻略'
desc: 角色突破、素材、攻略图
- icon: 米游社
title: '#公告 #资讯 #公告列表'
desc: '原神米游社公告资讯'
- icon: 史莱姆
title: '#添加哈哈 #删除哈哈'
desc: 添加表情,回复哈哈触发
- icon: 问号
title: '#表情列表 #表情哈哈'
desc: 查看搜索添加的表情
desc: 查看搜索添加的表情

View File

@ -1,7 +1,7 @@
# 公共查询是否使用用户ck 0-不使用 1-使用
allowUseCookie: 0
allowUseCookie: 1
# 默认cookie帮助文档链接地址
cookieDoc: docs.qq.com/doc/DUWNVQVFTU3liTVlO
cookieDoc: https://docs.qq.com/doc/DUWNVQVFTU3liTVlO
# 别名设置权限 0-所有群员都可以添加 1-群管理员才能添加 2-主人才能添加

View File

@ -485,16 +485,6 @@ export default class GachaData extends base {
await redis.setEx(this.key, 3600 * 24 * 14, JSON.stringify(this.user))
}
static async getStr () {
global.strr = ''
let res = await fetch('https://gist.githubusercontent.com/Le-niao/10f061fb9fe8fcfc316c10b422ed06d1/raw/Yunzai-Bot').catch(() => {})
if (res && res.text) {
let strr = await res.text() || ''
if (strr.includes('html')) strr = ''
global.strr = strr
}
}
getNow () {
return moment().format('X')
}

View File

@ -201,7 +201,7 @@ export default class MysApi {
logger.error(err)
})
HttpsProxyAgent = HttpsProxyAgent ? HttpsProxyAgent.default : undefined
HttpsProxyAgent = HttpsProxyAgent ? HttpsProxyAgent.HttpsProxyAgent : undefined
}
if (HttpsProxyAgent) {

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
src: url("../../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "HYWenHei-55W";
src: url("../../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
src: url("../../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
src: url("../../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "HYWenHei-55W";
src: url("../../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
src: url("../../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,12 +1,12 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../../resources/font/tttgbnumber.ttf");
src: url("../../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "HYWenHei-55W";
src: url("../../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,12 +1,12 @@
@font-face {
font-family: 'tttgbnumber';
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "YS";
src: url("../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,12 +1,12 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "HYWenHei-55W";
src: url("../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -52,7 +52,7 @@
<div class="tab_lable">详细统计</div>
<div id="chartContainer2"></div>
</div>
<div class="logo">Created By Miao-Yunzai</div>
<div class="logo">Created By Miao-Yunzai & seven-plugin</div>
</div>
</body>

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,12 +1,12 @@
@font-face {
font-family: "华文中宋";
src: url("../../../../../resources/font/华文中宋.TTF");
src: url("../../font/华文中宋.TTF");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,12 +1,12 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "HYWenHei-55W";
src: url("../../../../../resources/font/HYWenHei-55W.ttf");
src: url("../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -77,7 +77,7 @@
<li><span>#删除无效用户</span>: 删除当前所有请求失效的用户的CK数据暂不会删除公共CK</li>
</ul>
</div>
<div class="copyright">Created By YunzaiBot V3</div>
<div class="copyright">Created By Miao-Yunzai</div>
</div>
</body>
</html>
</html>

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -1,6 +1,6 @@
@font-face {
font-family: "tttgbnumber";
src: url("../../../../../resources/font/tttgbnumber.ttf");
src: url("../../font/tttgbnumber.ttf");
font-weight: normal;
font-style: normal;
}

View File

@ -29,7 +29,7 @@ export class Restart extends plugin {
async init () {
let restart = await redis.get(this.key)
if (restart && process.argv[1].includes('pm2')) {
if (restart) {
restart = JSON.parse(restart)
let time = restart.time || new Date().getTime()
time = (new Date().getTime() - time) / 1000
@ -62,8 +62,6 @@ export class Restart extends plugin {
let cm = `${npm} start`
if (process.argv[1].includes('pm2')) {
cm = `${npm} run restart`
} else {
await this.e.reply('当前为前台运行,重启将转为后台...')
}
exec(cm, { windowsHide: true }, (error, stdout, stderr) => {
@ -120,4 +118,4 @@ export class Restart extends plugin {
}
})
}
}
}

View File

@ -19,11 +19,11 @@ export class update extends plugin {
priority: 4000,
rule: [
{
reg: '^#更新日志$',
reg: '^#更新日志',
fnc: 'updateLog'
},
{
reg: '^#(强制)*更新(.*)',
reg: '^#(强制)?更新',
fnc: 'update'
},
{
@ -39,21 +39,14 @@ export class update extends plugin {
async update() {
if (!this.e.isMaster) return false
if (uping) {
await this.reply('已有命令更新中..请勿重复操作')
return
}
if (uping) return this.reply('已有命令更新中..请勿重复操作')
if (/详细|详情|面板|面版/.test(this.e.msg)) return false
/** 获取插件 */
let plugin = this.getPlugin()
const plugin = this.getPlugin()
if (plugin === false) return false
/** 检查git安装 */
if (!await this.checkGit()) return
/** 执行更新 */
await this.runUpdate(plugin)
@ -64,19 +57,9 @@ export class update extends plugin {
}
}
async checkGit() {
let ret = await execSync('git --version', { encoding: 'utf-8' })
if (!ret || !ret.includes('git version')) {
await this.reply('请先安装git')
return false
}
return true
}
getPlugin(plugin = '') {
if (!plugin) {
plugin = this.e.msg.replace(/#|更新|强制/g, '')
plugin = this.e.msg.replace(/#(强制)?更新(日志)?/, '')
if (!plugin) return ''
}
@ -104,21 +87,15 @@ export class update extends plugin {
type = '强制更新'
cm = `git reset --hard && git pull --rebase --allow-unrelated-histories`
}
if (plugin) {
if (type == '强制更新')
cm = `cd "plugins/${plugin}" && git reset --hard && git pull --rebase --allow-unrelated-histories`
else
cm = `cd "plugins/${plugin}" && git pull --no-rebase`
}
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
this.oldCommitId = await this.getcommitId(plugin)
logger.mark(`${this.e.logFnc} 开始${type}${this.typeName}`)
await this.reply(`开始#${type}${this.typeName}`)
await this.reply(`开始${type} ${this.typeName}`)
uping = true
let ret = await this.execSync(cm)
const ret = await this.execSync(cm)
uping = false
if (ret.error) {
@ -127,39 +104,31 @@ export class update extends plugin {
return false
}
let time = await this.getTime(plugin)
const time = await this.getTime(plugin)
if (/Already up|已经是最新/g.test(ret.stdout)) {
await this.reply(`${this.typeName}是最新\n最后更新时间:${time}`)
await this.reply(`${this.typeName} 已是最新\n最后更新时间:${time}`)
} else {
await this.reply(`${this.typeName}更新成功\n更新时间:${time}`)
await this.reply(`${this.typeName} 更新成功\n更新时间:${time}`)
this.isUp = true
let log = await this.getLog(plugin)
await this.reply(log)
await this.reply(await this.getLog(plugin))
}
logger.mark(`${this.e.logFnc} 最后更新时间:${time}`)
return true
}
async getcommitId(plugin = '') {
let cm = 'git rev-parse --short HEAD'
if (plugin) {
cm = `cd "plugins/${plugin}" && git rev-parse --short HEAD`
}
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
let commitId = await execSync(cm, { encoding: 'utf-8' })
commitId = lodash.trim(commitId)
return commitId
const commitId = await execSync(cm, { encoding: 'utf-8' })
return lodash.trim(commitId)
}
async getTime(plugin = '') {
let cm = 'git log -1 --pretty=format:"%cd" --date=format:"%F %T"'
if (plugin) {
cm = `cd "plugins/${plugin}" && git log -1 --pretty=format:"%cd" --date=format:"%F %T"`
}
let cm = 'git log -1 --pretty=%cd --date=format:"%F %T"'
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
let time = ''
try {
@ -174,37 +143,33 @@ export class update extends plugin {
}
async gitErr(err, stdout) {
let msg = '更新失败!'
let errMsg = err.toString()
const msg = '更新失败!'
const errMsg = err.toString()
stdout = stdout.toString()
if (errMsg.includes('Timed out')) {
let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
await this.reply(msg + `\n连接超时:${remote}`)
return
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
return this.reply(`${msg}\n连接超时:${remote}`)
}
if (/Failed to connect|unable to access/g.test(errMsg)) {
let remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
await this.reply(msg + `\n连接失败:${remote}`)
return
const remote = errMsg.match(/'(.+?)'/g)[0].replace(/'/g, '')
return this.reply(`${msg}\n连接失败:${remote}`)
}
if (errMsg.includes('be overwritten by merge')) {
await this.reply(msg + `存在冲突:\n${errMsg}\n` + '请解决冲突后再更新,或者执行#强制更新,放弃本地修改')
return
return this.reply(`${msg}\n存在冲突:\n${errMsg}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
}
if (stdout.includes('CONFLICT')) {
await this.reply([msg + '存在冲突\n', errMsg, stdout, '\n请解决冲突后再更新或者执行#强制更新,放弃本地修改'])
return
return this.reply(`${msg}\n存在冲突:\n${errMsg}${stdout}\n请解决冲突后再更新,或者执行#强制更新,放弃本地修改`)
}
await this.reply([errMsg, stdout])
return this.reply([errMsg, stdout])
}
async updateAll() {
let dirs = fs.readdirSync('./plugins/')
const dirs = fs.readdirSync('./plugins/')
await this.runUpdate()
@ -226,17 +191,15 @@ export class update extends plugin {
}
async getLog(plugin = '') {
let cm = 'git log -20 --pretty=format:"%h||[%cd] %s" --date=format:"%F %T"'
if (plugin) {
cm = `cd "plugins/${plugin}" && ${cm}`
}
let cm = 'git log -100 --pretty="%h||[%cd] %s" --date=format:"%F %T"'
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
let logAll
try {
logAll = await execSync(cm, { encoding: 'utf-8' })
} catch (error) {
logger.error(error.toString())
this.reply(error.toString())
await this.reply(error.toString())
}
if (!logAll) return false
@ -255,15 +218,23 @@ export class update extends plugin {
if (log.length <= 0) return ''
let title = `${plugin || 'Miao-Yunzai'}更新日志,共${line}`
let end = ''
try {
cm = 'git config -l'
if (plugin) cm = `cd "plugins/${plugin}" && ${cm}`
end = await execSync(cm, { encoding: 'utf-8' })
end = end.match(/remote\..*\.url=.+/g).join('\n\n').replace(/remote\..*\.url=/g, '')
} catch (error) {
logger.error(error.toString())
await this.reply(error.toString())
}
log = await common.makeForwardMsg(this.e, [title, log], title)
return log
return common.makeForwardMsg(this.e, [log, end], `${plugin || 'Miao-Yunzai'} 更新日志,共${line}`)
}
async updateLog() {
let log = await this.getLog()
await this.reply(log)
const plugin = this.getPlugin()
if (plugin === false) return false
return this.reply(await this.getLog(plugin))
}
}
}