Skip to content

Commit

Permalink
update injection
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Jun 6, 2024
1 parent 44c2a7d commit 0aed9b9
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,18 @@ global.Hydro.model.luogu = {
export async function apply(ctx: Context) {
ctx.inject(['vjudge'], (c) => {
c.vjudge.addProvider('luogu', LuoguProvider);
});

ctx.on('task/daily', async () => {
const status = await ctx.vjudge.checkStatus();
const id = Object.keys(status).find((k) => k.startsWith('luogu/'));
const quota = status[id].status;
const info = `${quota.orgName} 剩余点数: ${quota.availablePoints}
c.on('task/daily', async () => {
const status = await c.vjudge.checkStatus();
const id = Object.keys(status).find((k) => k.startsWith('luogu/'));
const quota = status[id].status;
const info = `${quota.orgName} 剩余点数: ${quota.availablePoints}
(点数有效期: ${moment(quota.createTime).format('YYYY/MM/DD')}-${moment(quota.expireTime).format('YYYY/MM/DD')})`;
if (moment(quota.expireTime).diff(moment(), 'days') <= 3) {
MessageModel.sendNotification(['Hydro & 洛谷开放平台提醒:', info, '点数有效期已不足3天,请及时联系Hydro开发组或洛谷官方进行充值或续费。'].join('\n'));
}
if (quota.availablePoints > 0 && quota.availablePoints < 1000) {
MessageModel.sendNotification(['Hydro & 洛谷开放平台提醒:', info, '点数已不足1000,请及时联系Hydro开发组或洛谷官方进行充值或续费。'].join('\n'));
}
if (moment(quota.expireTime).diff(moment(), 'days') <= 3) {
MessageModel.sendNotification(['Hydro & 洛谷开放平台提醒:', info, '点数有效期已不足3天,请及时联系Hydro开发组或洛谷官方进行充值或续费。'].join('\n'));
}
if (quota.availablePoints > 0 && quota.availablePoints < 1000) {
MessageModel.sendNotification(['Hydro & 洛谷开放平台提醒:', info, '点数已不足1000,请及时联系Hydro开发组或洛谷官方进行充值或续费。'].join('\n'));
}
});
});
}

0 comments on commit 0aed9b9

Please sign in to comment.