koishi-plugin-ets2-tools-tmp 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +10 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -482,10 +482,13 @@ class ActivityService {
482
482
  }
483
483
 
484
484
  const timeDiff = activityStartTime.getTime() - now.getTime();
485
- const minutesLeft = Math.floor(timeDiff / (1e3 * 60));
486
- this.logger.debug(`活动 "${activity.themeName}" 剩余时间: ${minutesLeft} 分钟`);
485
+ const totalSecondsLeft = Math.floor(timeDiff / 1000);
486
+ const minutesLeft = Math.floor(totalSecondsLeft / 60);
487
+ const secondsLeft = totalSecondsLeft % 60;
488
+ this.logger.debug(`活动 "${activity.themeName}" 剩余时间: ${minutesLeft} 分 ${secondsLeft} 秒`);
487
489
 
488
- if (minutesLeft <= 0 && minutesLeft > -1) {
490
+ // 活动开始提醒:只在活动开始时间点触发(允许30秒误差)
491
+ if (totalSecondsLeft >= -30 && totalSecondsLeft <= 0) {
489
492
  const startReminderKey = `${activity.id}_started`;
490
493
  if (!this.sentReminders.has(startReminderKey)) {
491
494
  this.logger.debug(`触发活动开始提醒: ${activity.themeName}`);
@@ -495,9 +498,11 @@ class ActivityService {
495
498
  }
496
499
  }
497
500
 
498
- if (minutesLeft < 0) continue;
501
+ // 活动前提醒:只在精确时间点触发(允许30秒误差)
502
+ if (totalSecondsLeft < 0) continue;
499
503
  for (const reminderTime of this.cfg.mainActivityReminderTimes) {
500
- if (minutesLeft <= reminderTime && minutesLeft > reminderTime - 1) {
504
+ const reminderTimeSeconds = reminderTime * 60;
505
+ if (totalSecondsLeft <= reminderTimeSeconds && totalSecondsLeft > reminderTimeSeconds - 30) {
501
506
  const reminderKey = `${activity.id}_${reminderTime}`;
502
507
  if (!this.sentReminders.has(reminderKey)) {
503
508
  this.logger.debug(`触发提醒: ${activity.themeName} - ${reminderTime} 分钟前`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ets2-tools-tmp",
3
3
  "description": "欧卡2 TMP在线查询、车队平台查询及活动提醒",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "contributors": [
6
6
  "opwop <slhp1013@qq.com>",
7
7
  "bot_actions <168329908@qq.com>"