同步 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 registry=https://registry.npmmirror.com
node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -119,8 +119,6 @@ export class gacha extends plugin {
/** 初始化创建配置文件 */ /** 初始化创建配置文件 */
async init () { async init () {
GachaData.getStr()
let file = './plugins/genshin/config/gacha.set.yaml' let file = './plugins/genshin/config/gacha.set.yaml'
if (fs.existsSync(file)) return 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 () { async init () {
@ -145,12 +145,6 @@ export class gcLog extends plugin {
return return
} }
let friend = Bot.fl.get(Number(this.e.user_id))
if (!friend) {
await this.reply('无法发送文件,请先添加好友')
return
}
let exportLog = new ExportLog(this.e) let exportLog = new ExportLog(this.e)
if (this.e.msg.includes('json')) { if (this.e.msg.includes('json')) {
@ -189,18 +183,18 @@ export class gcLog extends plugin {
} }
async help () { 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 () { async helpPort () {
let msg = this.e.msg.replace(/#|帮助/g, '') let msg = this.e.msg.replace(/#|帮助/g, '')
if (['电脑', 'pc'].includes(msg)) { 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)) { } else if (['安卓'].includes(msg)) {
await this.e.reply(`安卓抽卡记录获取教程:${this.androidUrl}`) await this.e.reply(`安卓抽卡记录获取教程:${this.androidUrl}`)
} else if (['苹果', 'ios'].includes(msg)) { } 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 定轨 十连武器 title: 十连 十连2 定轨 十连武器
desc: 真实模拟抽卡 desc: 真实模拟抽卡
- icon: 浮世 - icon: 浮世
title: '刻晴突破,刻晴素材' title: '刻晴突破、素材、攻略'
desc: 米游社友人A的角色素材图 desc: 角色突破、素材、攻略图
- icon: 刻晴 - icon: 米游社
title: 刻晴攻略 title: '#公告 #资讯 #公告列表'
desc: 西风驿站攻略图 desc: '原神米游社公告资讯'
# - icon: 米游社
# title: '#公告 #资讯 #公告列表'
# desc: '原神米游社公告资讯'
- icon: 史莱姆 - icon: 史莱姆
title: '#添加哈哈 #删除哈哈' title: '#添加哈哈 #删除哈哈'
desc: 添加表情,回复哈哈触发 desc: 添加表情,回复哈哈触发
- icon: 问号 - icon: 问号
title: '#表情列表 #表情哈哈' title: '#表情列表 #表情哈哈'
desc: 查看搜索添加的表情 desc: 查看搜索添加的表情

View File

@ -1,7 +1,7 @@
# 公共查询是否使用用户ck 0-不使用 1-使用 # 公共查询是否使用用户ck 0-不使用 1-使用
allowUseCookie: 0 allowUseCookie: 1
# 默认cookie帮助文档链接地址 # 默认cookie帮助文档链接地址
cookieDoc: docs.qq.com/doc/DUWNVQVFTU3liTVlO cookieDoc: https://docs.qq.com/doc/DUWNVQVFTU3liTVlO
# 别名设置权限 0-所有群员都可以添加 1-群管理员才能添加 2-主人才能添加 # 别名设置权限 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)) 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 () { getNow () {
return moment().format('X') return moment().format('X')
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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