Skip to content

Commit

Permalink
feat: 增加 cookie 过期提醒
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsuk1ko committed Jul 22, 2023
1 parent 0a3f64c commit 900d7b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/plugin/bilibili/feed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class BiliBiliDynamicFeed {
this.updateBaseline = '';
this.lastFullCheckTime = 0;
this.isChecking = false;
this.isAvailable = true;
this.checkedDynamicIdCache = new NodeCache({
useClones: false,
stdTTL: Math.max(600, global.config.bot.bilibili.feedCheckInterval * 10),
Expand Down Expand Up @@ -47,6 +48,7 @@ export class BiliBiliDynamicFeed {

if (code !== 0) {
console.error(`[BiliBiliDynamicFeed] getNewDynamic error: (${code})${message}`);
this.handleError(code);
return [];
}

Expand Down Expand Up @@ -99,6 +101,7 @@ export class BiliBiliDynamicFeed {

if (code !== 0) {
console.error(`[BiliBiliDynamicFeed] checkUpdateNum error: (${code})${message}`);
this.handleError(code);
return 0;
}

Expand Down Expand Up @@ -129,4 +132,8 @@ export class BiliBiliDynamicFeed {

return [];
}

handleError(code) {
if (code === -101) this.isAvailable = false;
}
}
12 changes: 12 additions & 0 deletions src/plugin/bilibili/push.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ async function checkSeason(type) {
}

async function checkFeed() {
if (!dynamicFeed.isAvailable) {
clearInterval(checkFeedTask);
dynamicFeed = null;
const sendNotice = () =>
global.sendMsg2Admin(
'哔哩哔哩cookie已过期,推送暂停,请配置新cookie后重载配置以重新启用推送(该提醒每6小时重复提醒一次)'
);
checkFeedTask = setInterval(sendNotice, 6 * 3600 * 1000);
sendNotice();
return;
}

const newItems = await dynamicFeed.checkAndGetNewDynamic();
if (!newItems.length) return;

Expand Down

0 comments on commit 900d7b0

Please sign in to comment.