Skip to content

Commit

Permalink
improvement: 优化部分内容
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowwarmth committed Jan 18, 2025
1 parent 9d1493c commit af3e35b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import logger from "./lib/config/logger.js";
import { Bot } from "./lib/config/config.js";
import chalk from "chalk";
initialize().then(() => {
logger.mark(chalk.cyan('kazuhaBot' + ' v' + Bot.version + '启动成功'));
logger.mark(chalk.cyan('KazuhaBot' + ' v' + Bot.version + '启动成功'));
});
5 changes: 2 additions & 3 deletions lib/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import * as path from 'path';
const configFilePath = path.resolve(process.cwd(), 'config', 'config.json');
const botFilePath = path.resolve(process.cwd(), 'package.json');
if (!fs.existsSync(configFilePath)) {
process.exit(1);
}
if (!fs.existsSync(botFilePath)) {
console.log(`配置文件 config.json 不存在`)
console.log(`退出运行`)
process.exit(1);
}
const config = JSON.parse(fs.readFileSync(configFilePath, 'utf8'));
Expand Down
4 changes: 2 additions & 2 deletions lib/config/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import loadGuildTree from '../../lib/core/loadGuildTree.js';
import database from '../../lib/config/redis.js';
export async function init() {
logger.mark(`-------(≡^∇^≡)-------`);
logger.mark(chalk.cyan(Bot.name + ' v' + Bot.version + '启动中...'));
logger.mark(chalk.cyan('KazuhaBot' + ' v' + Bot.version + '启动中...'));
logger.mark(chalk.greenBright('https://github.com/rainbowwarmth/KazuhaBot_Newmys.git'));
process.title = 'kazuhaBot' + ' v' + Bot.version + ' © 2023-2024 ' + '@' + Bot.author;
process.title = 'KazuhaBot' + ' v' + Bot.version + ' © 2023-2025 ' + '@' + Bot.author;
process.env.TZ = "Asia/Shanghai";
await initGlobals();
await Task();
Expand Down
8 changes: 4 additions & 4 deletions lib/render/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ async function doRender(renderData) {
fs.renameSync(jsonResponse.screenshotPath, savePic); // 直接覆盖保存图片
}
else {
logger.error("外部浏览器渲染失败未返回截图路径");
logger.error("外部浏览器渲染失败未返回截图路径");
}
}
}
catch (err) {
logger.error("外部浏览器请求失败", err);
logger.error("外部浏览器请求失败", err);
}
}
else {
Expand Down Expand Up @@ -192,7 +192,7 @@ async function browserInit() {
}
}
catch (err) {
logger.error("外部浏览器初始化失败", err);
logger.error("外部浏览器初始化失败", err);
}
}
else {
Expand Down Expand Up @@ -224,7 +224,7 @@ async function browserInit() {
});
}
catch (err) {
logger.error("启动 puppeteer 浏览器失败", err);
logger.error("启动 puppeteer 浏览器失败", err);
}
}
lock = false;
Expand Down
16 changes: 8 additions & 8 deletions plugins/mihoyo/apps/mysNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { redis } from '../../../lib/global/global.js';
import { miGetNewsList, miGetPostFull } from "../../mihoyo/models/mysNew.js";
import render from "../../../lib/render/render.js";
import { bbbmiGetNewsList, bbbmiGetPostFull, bbmiGetNewsList, bbmiGetPostFull, dbymiGetNewsList, dbymiGetPostFull, srmiGetNewsList, srmiGetPostFull, wdmiGetNewsList, wdmiGetPostFull, ysmiGetNewsList, ysmiGetPostFull, zzzmiGetNewsList, zzzmiGetPostFull } from "../../mihoyo/models/mysNew.js";
import {getIgnoreReg} from '../models/cfg.js'
import getIgnoreReg from '../models/cfg.js'

var emoticon = null;
const gameIds = {
Expand Down Expand Up @@ -199,25 +199,25 @@ export async function taskPushNews(gamePrefix, getNewsList, getPostFull, logMess
logger.debug(`${logMessage}检查完成`);
}
export async function bbbtaskPushNews() {
await taskPushNews("bbb", bbbmiGetNewsList, bbbmiGetPostFull, "崩坏三官方公告检查中");
await taskPushNews("bbb", bbbmiGetNewsList, bbbmiGetPostFull, "崩坏三官方公告推送");
}
export async function ystaskPushNews() {
await taskPushNews("ys", ysmiGetNewsList, ysmiGetPostFull, "原神官方公告检查中");
await taskPushNews("ys", ysmiGetNewsList, ysmiGetPostFull, "原神官方公告推送");
}
export async function bbtaskPushNews() {
await taskPushNews("bb", bbmiGetNewsList, bbmiGetPostFull, "崩坏学园2官方公告检查中");
await taskPushNews("bb", bbmiGetNewsList, bbmiGetPostFull, "崩坏学园2官方公告推送");
}
export async function wdtaskPushNews() {
await taskPushNews("wd", wdmiGetNewsList, wdmiGetPostFull, "未定事件簿官方公告检查中");
await taskPushNews("wd", wdmiGetNewsList, wdmiGetPostFull, "未定事件簿官方公告推送");
}
export async function dbytaskPushNews() {
await taskPushNews("dby", dbymiGetNewsList, dbymiGetPostFull, "大别野官方公告检查中");
await taskPushNews("dby", dbymiGetNewsList, dbymiGetPostFull, "大别野官方公告推送");
}
export async function srtaskPushNews() {
await taskPushNews("sr", srmiGetNewsList, srmiGetPostFull, "崩坏星穹铁道官方公告检查中");
await taskPushNews("sr", srmiGetNewsList, srmiGetPostFull, "崩坏星穹铁道官方公告推送");
}
export async function zzztaskPushNews() {
await taskPushNews("zzz", zzzmiGetNewsList, zzzmiGetPostFull, "绝区零官方公告检查中");
await taskPushNews("zzz", zzzmiGetNewsList, zzzmiGetPostFull, "绝区零官方公告推送");
}

export async function detalData(data) {
Expand Down
6 changes: 4 additions & 2 deletions plugins/mihoyo/models/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ const configFile = fs.readFileSync(configFilePath, 'utf8');
const config = parse(configFile);

// 根据游戏前缀加载 ignoreReg 正则
export function getIgnoreReg(gamePrefix) {
function getIgnoreReg(gamePrefix) {
const gameConfig = config[gamePrefix];
if (!gameConfig || !gameConfig.ignoreReg) {
console.error(`未找到 ${gamePrefix} 的 ignoreReg 配置`);
return null;
}
return new RegExp(gameConfig.ignoreReg.join('|'));
}
}

export default getIgnoreReg

0 comments on commit af3e35b

Please sign in to comment.