mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 08:09:19 +00:00
↩ revert: 删除冷门功能epic
This commit is contained in:
parent
9405141fb2
commit
faa37c7e9e
@ -51,10 +51,6 @@ export class query extends plugin {
|
||||
{
|
||||
reg: "^#(bookid)(.*)$$",
|
||||
fnc: "searchBookById",
|
||||
},
|
||||
{
|
||||
reg: "^#epic",
|
||||
fnc: "epicGame",
|
||||
}
|
||||
],
|
||||
});
|
||||
@ -364,86 +360,6 @@ export class query extends plugin {
|
||||
this.finish("searchBookContext");
|
||||
}
|
||||
|
||||
// epic游戏查询:逻辑来自于https://github.com/monsterxcn/nonebot_plugin_epicfree/blob/main/nonebot_plugin_epicfree/data_source.py
|
||||
async epicGame(e) {
|
||||
const API = `https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions?locale=zh-CN&country=CN&allowCountries=CN`;
|
||||
const res = await fetch(API, {
|
||||
headers: {
|
||||
Referer: "https://www.epicgames.com/store/zh-CN/",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36",
|
||||
},
|
||||
timeout: 10000,
|
||||
}).then((resp) => resp.json());
|
||||
const games = res.data.Catalog.searchStore.elements;
|
||||
// console.log(games);
|
||||
e.reply(
|
||||
`获取到${games.length}个游戏,${games.map((item) => item.title).join(", ")}`
|
||||
);
|
||||
for (const game of games) {
|
||||
const gameName = game?.title || "未知";
|
||||
if (game?.promotions === undefined) {
|
||||
continue;
|
||||
}
|
||||
const game_promotions = game.promotions?.promotionalOffers;
|
||||
const upcoming_promotions = game.promotions?.upcomingPromotionalOffers;
|
||||
const originalPrice = game.price.totalPrice.fmtPrice.originalPrice;
|
||||
const discount_price = game.price.totalPrice.fmtPrice.discountPrice;
|
||||
if (!game_promotions && upcoming_promotions) {
|
||||
logger.mark(`跳过即将推出免费游玩的游戏:${gameName}(${discount_price})`);
|
||||
continue;
|
||||
} else if (game.price.totalPrice.fmtPrice.discountPrice != "0") {
|
||||
logger.mark(`跳过促销但不免费的游戏:${gameName}(${discount_price})`);
|
||||
continue;
|
||||
}
|
||||
// 图片处理
|
||||
let availableImgUrl = [];
|
||||
const available = [
|
||||
"Thumbnail",
|
||||
"VaultOpened",
|
||||
"DieselStoreFrontWide",
|
||||
"OfferImageWide",
|
||||
];
|
||||
for (const image of game.keyImages) {
|
||||
if ((image.url != null) && available.includes(image.type)) {
|
||||
availableImgUrl.push(image.url);
|
||||
}
|
||||
}
|
||||
// 处理游戏发行信息
|
||||
let gameDev = game.seller.name;
|
||||
let gamePub = game.seller.name;
|
||||
for (const pair of game.customAttributes) {
|
||||
if (pair.key === "developerName") {
|
||||
gameDev = pair.value;
|
||||
} else if (pair.key === "publisherName") {
|
||||
gamePub = pair.value;
|
||||
}
|
||||
}
|
||||
const dev_com = gameDev != gamePub ? `${gameDev} 开发、` : "";
|
||||
const companies =
|
||||
gamePub != "Epic Dev Test Account" ? `由 ${dev_com}${gamePub} 发行,` : "";
|
||||
//处理游戏限免结束时间
|
||||
const dateRfc3339 = game_promotions?.[0].promotionalOffers[0].endDate;
|
||||
let endDate = "不明确";
|
||||
if (dateRfc3339 !== undefined) {
|
||||
const date = new Date(dateRfc3339);
|
||||
const options = {
|
||||
timeZone: "Asia/Shanghai",
|
||||
month: "long",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
};
|
||||
endDate = date
|
||||
.toLocaleString("zh-CN", options)
|
||||
.replace(/(\d{1,2})\s/, "$1日 ");
|
||||
}
|
||||
const resMsg = `${gameName} (${originalPrice})\n\n${game.description}\n\n游戏${companies}\n链接:${game?.url || "暂无"}\n将在 ${endDate} 结束免费游玩,戳上方链接领取吧~`;
|
||||
e.reply([resMsg, ...availableImgUrl.map(url => segment.image(url))])
|
||||
}
|
||||
}
|
||||
|
||||
// 删除标签
|
||||
removeTag(title) {
|
||||
const titleRex = /<[^>]+>/g;
|
||||
|
@ -21,9 +21,6 @@
|
||||
- icon: searchBook
|
||||
title: "#搜书/#bookid"
|
||||
desc: 基于zli的搜书功能
|
||||
- icon: epic
|
||||
title: "#epic"
|
||||
desc: epic免费游戏查询
|
||||
- group: 工具类合集
|
||||
list:
|
||||
- icon: translate
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB |
Loading…
x
Reference in New Issue
Block a user