diff --git a/.npmrc b/.npmrc index 1a4b9ed..ef1cf92 100644 --- a/.npmrc +++ b/.npmrc @@ -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 \ No newline at end of file +registry=https://registry.npmmirror.com +node_sqlite3_binary_host_mirror=https://npmmirror.com/mirrors/sqlite3 \ No newline at end of file diff --git a/.puppeteerrc.cjs b/.puppeteerrc.cjs index 74936b0..2f3a7b5 100644 --- a/.puppeteerrc.cjs +++ b/.puppeteerrc.cjs @@ -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 } \ No newline at end of file diff --git a/lib/config/config.js b/lib/config/config.js index 1f43cbc..3a2ea1f 100644 --- a/lib/config/config.js +++ b/lib/config/config.js @@ -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] diff --git a/lib/config/redis.js b/lib/config/redis.js index 2b67b72..e4b84c0 100644 --- a/lib/config/redis.js +++ b/lib/config/redis.js @@ -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 }) }) }) -} +} \ No newline at end of file diff --git a/lib/renderer/Renderer.js b/lib/renderer/Renderer.js index cc50e93..4b64b00 100644 --- a/lib/renderer/Renderer.js +++ b/lib/renderer/Renderer.js @@ -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}`) } } diff --git a/package.json b/package.json index d0ae5e6..11ec127 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/plugins/genshin/README.md b/plugins/genshin/README.md index d3bac52..a88631e 100644 --- a/plugins/genshin/README.md +++ b/plugins/genshin/README.md @@ -54,8 +54,8 @@ |#记录帮助|抽卡记录导入说明| |#导出记录|抽卡记录xlsx导出| |#导出记录json|抽卡记录json导出| -|xlsx文件导入|xlsx导入,统一可交换祈愿记录v2.2,需要加好友| -|json文件导入|json导入,统一可交换祈愿记录v2.2,需要加好友| +|xlsx文件导入|xlsx导入,统一可交换祈愿记录v2.2| +|json文件导入|json导入,统一可交换祈愿记录v2.2| | 其他指令 | 说明| | :---------------- | --------------- | diff --git a/plugins/genshin/apps/abbrSet.js b/plugins/genshin/apps/abbrSet.js index 48c1569..04f32b0 100644 --- a/plugins/genshin/apps/abbrSet.js +++ b/plugins/genshin/apps/abbrSet.js @@ -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) } diff --git a/plugins/genshin/apps/gacha.js b/plugins/genshin/apps/gacha.js index d1d5155..c945454 100644 --- a/plugins/genshin/apps/gacha.js +++ b/plugins/genshin/apps/gacha.js @@ -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 diff --git a/plugins/genshin/apps/gcLog.js b/plugins/genshin/apps/gcLog.js index 9fd4bdb..2ae81d4 100644 --- a/plugins/genshin/apps/gcLog.js +++ b/plugins/genshin/apps/gcLog.js @@ -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`)) } } diff --git a/plugins/genshin/defSet/bot/help.yaml b/plugins/genshin/defSet/bot/help.yaml index 9bf36b8..a653a8a 100644 --- a/plugins/genshin/defSet/bot/help.yaml +++ b/plugins/genshin/defSet/bot/help.yaml @@ -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: 查看、搜索添加的表情 diff --git a/plugins/genshin/defSet/mys/set.yaml b/plugins/genshin/defSet/mys/set.yaml index 9f0d991..e52ba5b 100644 --- a/plugins/genshin/defSet/mys/set.yaml +++ b/plugins/genshin/defSet/mys/set.yaml @@ -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-主人才能添加 diff --git a/plugins/genshin/model/gachaData.js b/plugins/genshin/model/gachaData.js index 9683ff9..54330a7 100644 --- a/plugins/genshin/model/gachaData.js +++ b/plugins/genshin/model/gachaData.js @@ -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') } diff --git a/plugins/genshin/model/mys/mysApi.js b/plugins/genshin/model/mys/mysApi.js index c04a322..fb3d08d 100644 --- a/plugins/genshin/model/mys/mysApi.js +++ b/plugins/genshin/model/mys/mysApi.js @@ -201,7 +201,7 @@ export default class MysApi { logger.error(err) }) - HttpsProxyAgent = HttpsProxyAgent ? HttpsProxyAgent.default : undefined + HttpsProxyAgent = HttpsProxyAgent ? HttpsProxyAgent.HttpsProxyAgent : undefined } if (HttpsProxyAgent) { diff --git a/plugins/genshin/resources/StarRail/html/calculator/calculator.css b/plugins/genshin/resources/StarRail/html/calculator/calculator.css index d1ae9f9..3cb1300 100644 --- a/plugins/genshin/resources/StarRail/html/calculator/calculator.css +++ b/plugins/genshin/resources/StarRail/html/calculator/calculator.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.css b/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.css index 1b75ce6..88bc8e8 100644 --- a/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.css +++ b/plugins/genshin/resources/StarRail/html/dailyNote/dailyNote.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/gachaAllLog/gachaAllLog.css b/plugins/genshin/resources/StarRail/html/gachaAllLog/gachaAllLog.css index e1449bf..27062d3 100644 --- a/plugins/genshin/resources/StarRail/html/gachaAllLog/gachaAllLog.css +++ b/plugins/genshin/resources/StarRail/html/gachaAllLog/gachaAllLog.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.css b/plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.css index 68d6211..1b24e05 100644 --- a/plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.css +++ b/plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/ledger/ledger.css b/plugins/genshin/resources/StarRail/html/ledger/ledger.css index 3c32af0..cae01a7 100644 --- a/plugins/genshin/resources/StarRail/html/ledger/ledger.css +++ b/plugins/genshin/resources/StarRail/html/ledger/ledger.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/ledgerCount/ledgerCount.css b/plugins/genshin/resources/StarRail/html/ledgerCount/ledgerCount.css index e6561e1..1549cf0 100644 --- a/plugins/genshin/resources/StarRail/html/ledgerCount/ledgerCount.css +++ b/plugins/genshin/resources/StarRail/html/ledgerCount/ledgerCount.css @@ -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; } diff --git a/plugins/genshin/resources/StarRail/html/logCount/logCount.css b/plugins/genshin/resources/StarRail/html/logCount/logCount.css index 4bcf8c5..12e2dec 100644 --- a/plugins/genshin/resources/StarRail/html/logCount/logCount.css +++ b/plugins/genshin/resources/StarRail/html/logCount/logCount.css @@ -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; } diff --git a/resources/font/HYWenHei-55W.ttf b/plugins/genshin/resources/font/HYWenHei-55W.ttf similarity index 100% rename from resources/font/HYWenHei-55W.ttf rename to plugins/genshin/resources/font/HYWenHei-55W.ttf diff --git a/resources/font/tttgbnumber.ttf b/plugins/genshin/resources/font/tttgbnumber.ttf similarity index 100% rename from resources/font/tttgbnumber.ttf rename to plugins/genshin/resources/font/tttgbnumber.ttf diff --git a/resources/font/华文中宋.TTF b/plugins/genshin/resources/font/华文中宋.TTF similarity index 100% rename from resources/font/华文中宋.TTF rename to plugins/genshin/resources/font/华文中宋.TTF diff --git a/plugins/genshin/resources/html/abyss/abyss.css b/plugins/genshin/resources/html/abyss/abyss.css index 0b20c57..04f4226 100644 --- a/plugins/genshin/resources/html/abyss/abyss.css +++ b/plugins/genshin/resources/html/abyss/abyss.css @@ -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; } diff --git a/plugins/genshin/resources/html/abyssFloor/abyssFloor.css b/plugins/genshin/resources/html/abyssFloor/abyssFloor.css index 0cfd799..64ab675 100644 --- a/plugins/genshin/resources/html/abyssFloor/abyssFloor.css +++ b/plugins/genshin/resources/html/abyssFloor/abyssFloor.css @@ -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; } diff --git a/plugins/genshin/resources/html/blueprint/blueprint.css b/plugins/genshin/resources/html/blueprint/blueprint.css index 452dd63..d35f6d3 100644 --- a/plugins/genshin/resources/html/blueprint/blueprint.css +++ b/plugins/genshin/resources/html/blueprint/blueprint.css @@ -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; } diff --git a/plugins/genshin/resources/html/calculator/calculator.css b/plugins/genshin/resources/html/calculator/calculator.css index 0222fc0..4996010 100644 --- a/plugins/genshin/resources/html/calculator/calculator.css +++ b/plugins/genshin/resources/html/calculator/calculator.css @@ -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; } diff --git a/plugins/genshin/resources/html/dailyNote/dailyNote.css b/plugins/genshin/resources/html/dailyNote/dailyNote.css index 4be1fd8..4304bc9 100644 --- a/plugins/genshin/resources/html/dailyNote/dailyNote.css +++ b/plugins/genshin/resources/html/dailyNote/dailyNote.css @@ -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; } diff --git a/plugins/genshin/resources/html/gacha/gacha.css b/plugins/genshin/resources/html/gacha/gacha.css index 25261d0..0090d24 100644 --- a/plugins/genshin/resources/html/gacha/gacha.css +++ b/plugins/genshin/resources/html/gacha/gacha.css @@ -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; } diff --git a/plugins/genshin/resources/html/gachaAllLog/gachaAllLog.css b/plugins/genshin/resources/html/gachaAllLog/gachaAllLog.css index 7e17245..03a06a9 100644 --- a/plugins/genshin/resources/html/gachaAllLog/gachaAllLog.css +++ b/plugins/genshin/resources/html/gachaAllLog/gachaAllLog.css @@ -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; } diff --git a/plugins/genshin/resources/html/gachaLog/gachaLog.css b/plugins/genshin/resources/html/gachaLog/gachaLog.css index f93af9f..8710a5a 100644 --- a/plugins/genshin/resources/html/gachaLog/gachaLog.css +++ b/plugins/genshin/resources/html/gachaLog/gachaLog.css @@ -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; } diff --git a/plugins/genshin/resources/html/help/help.css b/plugins/genshin/resources/html/help/help.css index 79a85c6..8732f02 100644 --- a/plugins/genshin/resources/html/help/help.css +++ b/plugins/genshin/resources/html/help/help.css @@ -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; } diff --git a/plugins/genshin/resources/html/ledger/ledger.css b/plugins/genshin/resources/html/ledger/ledger.css index 2f7d939..9b69310 100644 --- a/plugins/genshin/resources/html/ledger/ledger.css +++ b/plugins/genshin/resources/html/ledger/ledger.css @@ -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; } diff --git a/plugins/genshin/resources/html/ledgerCount/ledgerCount.css b/plugins/genshin/resources/html/ledgerCount/ledgerCount.css index e567a7c..d0cd28f 100644 --- a/plugins/genshin/resources/html/ledgerCount/ledgerCount.css +++ b/plugins/genshin/resources/html/ledgerCount/ledgerCount.css @@ -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; } diff --git a/plugins/genshin/resources/html/logCount/logCount.css b/plugins/genshin/resources/html/logCount/logCount.css index cfcbba6..69fe159 100644 --- a/plugins/genshin/resources/html/logCount/logCount.css +++ b/plugins/genshin/resources/html/logCount/logCount.css @@ -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; } diff --git a/plugins/genshin/resources/html/payLog/payLog.css b/plugins/genshin/resources/html/payLog/payLog.css index b2e58ec..0ba601a 100644 --- a/plugins/genshin/resources/html/payLog/payLog.css +++ b/plugins/genshin/resources/html/payLog/payLog.css @@ -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; } diff --git a/plugins/genshin/resources/html/payLog/payLog.html b/plugins/genshin/resources/html/payLog/payLog.html index 52793f3..9d2db9e 100644 --- a/plugins/genshin/resources/html/payLog/payLog.html +++ b/plugins/genshin/resources/html/payLog/payLog.html @@ -52,7 +52,7 @@
详细统计
- + diff --git a/plugins/genshin/resources/html/roleBag/roleBag.css b/plugins/genshin/resources/html/roleBag/roleBag.css index 8506b64..896c635 100644 --- a/plugins/genshin/resources/html/roleBag/roleBag.css +++ b/plugins/genshin/resources/html/roleBag/roleBag.css @@ -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; } diff --git a/plugins/genshin/resources/html/roleCard/roleCard.css b/plugins/genshin/resources/html/roleCard/roleCard.css index 0f5bb44..d1780f6 100644 --- a/plugins/genshin/resources/html/roleCard/roleCard.css +++ b/plugins/genshin/resources/html/roleCard/roleCard.css @@ -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; } diff --git a/plugins/genshin/resources/html/roleDetail/roleDetail.css b/plugins/genshin/resources/html/roleDetail/roleDetail.css index d2432fa..cd1d200 100644 --- a/plugins/genshin/resources/html/roleDetail/roleDetail.css +++ b/plugins/genshin/resources/html/roleDetail/roleDetail.css @@ -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; } diff --git a/plugins/genshin/resources/html/roleExplore/roleExplore.css b/plugins/genshin/resources/html/roleExplore/roleExplore.css index a586c73..c1fba9f 100644 --- a/plugins/genshin/resources/html/roleExplore/roleExplore.css +++ b/plugins/genshin/resources/html/roleExplore/roleExplore.css @@ -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; } diff --git a/plugins/genshin/resources/html/roleIndex/roleIndex.css b/plugins/genshin/resources/html/roleIndex/roleIndex.css index da9a444..f12b2af 100644 --- a/plugins/genshin/resources/html/roleIndex/roleIndex.css +++ b/plugins/genshin/resources/html/roleIndex/roleIndex.css @@ -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; } diff --git a/plugins/genshin/resources/html/roleList/roleList.css b/plugins/genshin/resources/html/roleList/roleList.css index 0d46fad..3f544ad 100644 --- a/plugins/genshin/resources/html/roleList/roleList.css +++ b/plugins/genshin/resources/html/roleList/roleList.css @@ -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; } diff --git a/plugins/genshin/resources/html/todayMaterial/todayMaterial.css b/plugins/genshin/resources/html/todayMaterial/todayMaterial.css index cf2ba7f..58707f5 100644 --- a/plugins/genshin/resources/html/todayMaterial/todayMaterial.css +++ b/plugins/genshin/resources/html/todayMaterial/todayMaterial.css @@ -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; } diff --git a/plugins/genshin/resources/html/userAdmin/userAdmin.css b/plugins/genshin/resources/html/userAdmin/userAdmin.css index 24fa83e..a6da7ca 100644 --- a/plugins/genshin/resources/html/userAdmin/userAdmin.css +++ b/plugins/genshin/resources/html/userAdmin/userAdmin.css @@ -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; } diff --git a/plugins/genshin/resources/html/userAdmin/userAdmin.html b/plugins/genshin/resources/html/userAdmin/userAdmin.html index 046bc0c..2f4dfc8 100644 --- a/plugins/genshin/resources/html/userAdmin/userAdmin.html +++ b/plugins/genshin/resources/html/userAdmin/userAdmin.html @@ -77,7 +77,7 @@
  • #删除无效用户: 删除当前所有请求失效的用户的CK数据,暂不会删除公共CK
  • - + - \ No newline at end of file + diff --git a/plugins/genshin/resources/html/userAdmin/userAdmin.less b/plugins/genshin/resources/html/userAdmin/userAdmin.less index 94b33a5..f3f5470 100644 --- a/plugins/genshin/resources/html/userAdmin/userAdmin.less +++ b/plugins/genshin/resources/html/userAdmin/userAdmin.less @@ -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; } diff --git a/plugins/genshin/resources/html/weapon/weapon.css b/plugins/genshin/resources/html/weapon/weapon.css index 439f936..e6903ef 100644 --- a/plugins/genshin/resources/html/weapon/weapon.css +++ b/plugins/genshin/resources/html/weapon/weapon.css @@ -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; } diff --git a/plugins/other/restart.js b/plugins/other/restart.js index 6534b9b..2b9e9e7 100644 --- a/plugins/other/restart.js +++ b/plugins/other/restart.js @@ -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 { } }) } -} +} \ No newline at end of file diff --git a/plugins/other/update.js b/plugins/other/update.js index ed434a4..12804e3 100644 --- a/plugins/other/update.js +++ b/plugins/other/update.js @@ -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)) } -} +} \ No newline at end of file