From fe3b08bae4fe5d26993ca2a89791ea90408d7812 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Mon, 17 Jun 2024 02:39:11 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E6=8E=92=E5=90=8D=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=A2=91=E7=8E=87=E4=B8=BA=E6=AF=8F20=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schedule/index.ts | 4 ++-- schedule/rank.ts | 59 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/schedule/index.ts b/schedule/index.ts index 21e5bfe..6e90f30 100644 --- a/schedule/index.ts +++ b/schedule/index.ts @@ -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(); diff --git a/schedule/rank.ts b/schedule/rank.ts index 50187b3..ccb9868 100644 --- a/schedule/rank.ts +++ b/schedule/rank.ts @@ -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();