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 621bf1d commit 9d1493c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,21 @@
},
"author": "feilongproject,rainbowwarmth",
"license": "MIT",
"devDependencies": {
"@types/node": "^22.9.0",
"@types/node-fetch": "^2.6.2",
"@types/node-schedule": "^2.1.0",
"@types/ws": "^8.5.12"
},
"dependencies": {
"art-template": "^4.13.2",
"chalk": "^4.0.0",
"form-data": "^4.0.1",
"log4js": "^6.5.2",
"node-fetch": "^2.6.6",
"node-schedule": "^2.1.0",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"pm2": "^5.3.0",
"puppeteer": "^15.4.0",
"qq-bot-sdk": "^1.9.1",
"redis": "^4.2.0",
"resty-client": "^0.0.5",
"rimraf": "^6.0.1",
"sharp": "^0.33.5",
"ws": "^8.18.0",
"yaml": "^2.7.0"
}
}
51 changes: 23 additions & 28 deletions plugins/mihoyo/apps/mysNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export async function newsListBBS(msg) {
}
export async function changePushTask(msg) {
logger.mark(`[${msg.guild_name}-${msg.channel_name}(${msg.guild_id}-${msg.channel_id}), ${msg.author.username}(${msg.author.id})][${msg.content}]`);
if (msg.messageType !== "GUILD")
return true;
if (msg.messageType !== "GUILD")return true;
const { gid } = getGameIdAndName(msg.content);
const gamePrefix = gamePrefixes[gid] || "unknown";
const value = msg.content.includes("开启");
Expand Down Expand Up @@ -220,40 +219,36 @@ export async function srtaskPushNews() {
export async function zzztaskPushNews() {
await taskPushNews("zzz", zzzmiGetNewsList, zzzmiGetPostFull, "绝区零官方公告检查中");
}

export async function detalData(data) {
var json;
let json;
try {
json = JSON.parse(data.post.content);
} catch (error) {
json = null;
}
catch (error) { }
if (typeof json == "object") {
if (json.imgs && json.imgs.length > 0) {
for (const val of json.imgs) {
data.post.content = ` <div class="ql-image-box"><img src="${val}?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg"></div>`;
}
}
}
else {
for (const img of data.post.images) {
data.post.content = data.post.content.replace(img, img + "?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg");
}
data.post.content = data.post.content.replace(/_\([^)]*\)/g, function (t, e) {
t = t.replace(/_\(|\)/g, "");
if (emoticon?.has(t)) {
return `<img class="emoticon-image" src="${emoticon.get(t)}"/>`;
}
else {
return "";
}
if (json && typeof json === "object" && Array.isArray(json.imgs) && json.imgs.length > 0) {
json.imgs.forEach(val => {
data.post.content += ` <div class="ql-image-box"><img src="${val}?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg"></div>`;
});
var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
data.post.content = data.post.content.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
return arrEntities[t];
} else {
if (Array.isArray(data.post.images)) {
data.post.images.forEach(img => {
data.post.content = data.post.content.replace(img,`${img}?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg`);
});
}
data.post.content = data.post.content.replace(/_\([^)]*\)/g, t => {
const key = t.replace(/_\(|\)/g, "");
return emoticon?.has(key) ? `<img class="emoticon-image" src="${emoticon.get(key)}"/>` : "";
});
const htmlEntities = { lt: "<",gt: ">", nbsp: " ", amp: "&", quot: "\"",};
data.post.content = data.post.content.replace(/&(lt|gt|nbsp|amp|quot);/gi, (match, entity) => htmlEntities[entity] || match);
}
data.post.created_time = new Date(data.post.created_at * 1000).toLocaleString();
for (const i in data.stat) {
data.stat[i] = data.stat[i] > 10000 ? (data.stat[i] / 10000).toFixed(2) + "万" : data.stat[i];
for (const key in data.stat) {
if (Object.hasOwn(data.stat, key)) {
data.stat[key] = data.stat[key] > 10000 ? `${(data.stat[key] / 10000).toFixed(2)}万` : data.stat[key];
}
}
return data;
}

0 comments on commit 9d1493c

Please sign in to comment.