feat: 更新定时发送排名信息的频率为每20分钟
All checks were successful
Egg CI/CD / build-image (push) Successful in 54s
Egg CI/CD / deploy (push) Successful in 36s

This commit is contained in:
zhaoyingbo 2024-06-17 02:39:11 +00:00
parent 1793fb38ff
commit fe3b08bae4
2 changed files with 55 additions and 8 deletions

View File

@ -5,8 +5,8 @@ import sendRank from "./rank";
export const initSchedule = async () => {
// 定时任务每15分钟刷新一次token
schedule.scheduleJob("*/15 * * * *", resetAccessToken);
// 每天的早九到晚九点,每小时请求一次
schedule.scheduleJob("0 9-21 * * *", sendRank);
// 每天的早九到晚九点,每20分钟发送一次排行榜
schedule.scheduleJob("*/20 9-21 * * *", sendRank);
// 立即执行一次
resetAccessToken();
sendRank();

View File

@ -30,19 +30,64 @@ const sendRank = async () => {
);
const data = (await res.json()) as any;
const list = data.data.votedInfoList as any[];
const noNeedTeam = [
"福尔摩丝与花生",
"赛博疾风",
"滴滴滴",
"大爱老师",
"愿世界没有调休",
"萌宠守卫队",
"说花就花我都队",
"公路合唱团",
"APTX4869",
"su7666",
"三等奖",
"你好我有一个帽衫",
"暖暖的很贴心",
"AI舞团",
"人像智绘师",
"刚刚好",
"PromptsEngineer",
"快码加编",
"驭魔智控",
"Magicians",
];
const overHandred = list.filter(
(v) => v.voteCount >= 100 && !noNeedTeam.includes(v.teamName)
);
// 排序
list.sort((a: any, b: any) => b.voteCount - a.voteCount);
const index = list.findIndex((v) => v.teamName === "聚光灯");
const diff = list[0].voteCount - list[index].voteCount;
const content = `当前票数:${list[index].voteCount},排名:${
overHandred.sort((a: any, b: any) => b.voteCount - a.voteCount);
const index = overHandred.findIndex((v) => v.teamName === "聚光灯");
const diff = overHandred[0].voteCount - overHandred[index].voteCount;
const selfContent = `当前票数:${list[index].voteCount},排名:${
index + 1
}${diff}`;
const overHandredContent = overHandred
.map((v) => `**${v.voteCount}**${v.subjectDesc}`)
.join("\n");
service.lark.message.send("egg")(
"chat_id",
"oc_bafb83413e933e25994dd313f5d76c7e",
"text",
content
"interactive",
JSON.stringify({
elements: [
{
tag: "markdown",
content: selfContent,
},
{ tag: "markdown", content: "**票数超过100 & 未在前20的队伍**" },
{
tag: "markdown",
content: overHandredContent,
},
],
header: {
template: "green",
title: { content: "寻TA票数监控", tag: "plain_text" },
},
})
);
} catch (e) {
console.error(e);
@ -50,3 +95,5 @@ const sendRank = async () => {
};
export default sendRank;
sendRank();