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.
- package/lib/index.js +10 -5
- 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
|
|
486
|
-
|
|
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
|
-
|
|
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
|
-
|
|
501
|
+
// 活动前提醒:只在精确时间点触发(允许30秒误差)
|
|
502
|
+
if (totalSecondsLeft < 0) continue;
|
|
499
503
|
for (const reminderTime of this.cfg.mainActivityReminderTimes) {
|
|
500
|
-
|
|
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} 分钟前`);
|