From fcb78f2426719dbb1200f0b5dec195cf4b8b5d83 Mon Sep 17 00:00:00 2001 From: Qian23333 <119576779+Qian23333@users.noreply.github.com> Date: Sat, 16 Aug 2025 11:18:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=95=B4=E5=8D=81?= =?UTF-8?q?=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/manage/remind.js | 10 +++++++++- apps/remind.js | 34 ++++++++++++++++++++++------------ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/apps/manage/remind.js b/apps/manage/remind.js index 82e3a2f..9c0e067 100644 --- a/apps/manage/remind.js +++ b/apps/manage/remind.js @@ -6,9 +6,17 @@ export async function setGlobalRemind() { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); return false; } - const match = this.e.msg.match(/设置全局提醒时间\s*(每日\d+时|每周.\d+时)/); + const match = this.e.msg.match(/设置全局提醒时间\s*(每日\d+时(?:(\d+)分)?)|每周.\d+时(?:(\d+)分)?))/); if (!match) return; const remindTime = match[1]; + const minute = Number(match[2]) || Number(match[3]) || 0; + + // 验证分钟格式 + if (minute % 10 !== 0 || minute < 0 || minute >= 60) { + await this.reply('分钟必须为整十分钟'); + return; + } + settings.setSingleConfig('remind', 'globalRemindTime', remindTime); await this.reply(`全局提醒时间已更新为: ${remindTime}。`); } \ No newline at end of file diff --git a/apps/remind.js b/apps/remind.js index ef4614a..ef1913c 100644 --- a/apps/remind.js +++ b/apps/remind.js @@ -36,7 +36,7 @@ export class Remind extends ZZZPlugin { fnc: 'checkNow', }, { - reg: `${rulePrefix}设置个人提醒时间\\s*(每日\\d+时|每周.\\d+时)`, + reg: `${rulePrefix}设置个人提醒时间\\s*(每日\\d+时(?:(\\d+)分)?|每周.\\d+时(?:(\\d+)分)?)`, fnc: 'setMyRemindTime', }, { @@ -54,7 +54,7 @@ export class Remind extends ZZZPlugin { if (globalRemindConfig.enable) { this.task = { name: 'ZZZ-Plugin式舆防卫战/危局强袭战提醒任务', - cron: '0 * * * * ?', // 每小时的第0分钟执行 + cron: '0 0/10 * * * *', fnc: () => this.runTask(), }; } @@ -72,23 +72,26 @@ export class Remind extends ZZZPlugin { isTimeMatch(remindTime, date) { if (!remindTime) return false; - const currentHour = date.getHours(); const currentDay = date.getDay(); // 0 = 周日, 1 = 周一, ..., 6 = 周六 + const currentHour = date.getHours(); + const currentMinute = date.getMinutes(); if (remindTime.includes('每日')) { - const match = remindTime.match(/每日(\d+)时/); + const match = remindTime.match(/每日(\d+)时(?:(\d+)分)?/); if (match) { - const hour = parseInt(match[1], 10); - return currentHour === hour; + const hour = parseInt(match[1]); + const minute = match[2] ? parseInt(match[2]) : 0; + return currentHour === hour && currentMinute === minute; } } else if (remindTime.includes('每周')) { - const dayMap = { '日': 0, '一': 1, '二': 2, '三': 3, '四': 4, '五': 5, '六': 6 }; - const match = remindTime.match(/每周(.)(\d+)时/); + const dayMap = { '日': 0, '天': 0, '一': 1, '二': 2, '三': 3, '四': 4, '五': 5, '六': 6 }; + const match = remindTime.match(/每周(.)(\d+)时(?:(\d+)分)?/); if (match) { const dayChar = match[1]; - const hour = parseInt(match[2], 10); - const day = dayMap[dayChar] || parseInt(dayChar, 10); - return currentDay === day && currentHour === hour; + const day = dayMap[dayChar]; + const hour = parseInt(match[2]); + const minute = match[3] ? parseInt(match[3]) : 0; + return currentDay === day && currentHour === hour && currentMinute === minute; } } return false; @@ -300,9 +303,16 @@ export class Remind extends ZZZPlugin { } async setMyRemindTime() { - const match = this.e.msg.match(/设置个人提醒时间\s*(每日\d+时|每周.\d+时)/); + const match = this.e.msg.match(/设置个人提醒时间\s*(每日\d+时(?:(\d+)分)?|每周.\d+时(?:(\d+)分)?)/); if (!match) return; const remindTime = match[1]; + const minute = Number(match[2]) || Number(match[3]) || 0; + + // 验证分钟格式 + if (minute % 10 !== 0 || minute < 0 || minute >= 60) { + await this.reply('分钟必须为整十分钟'); + return; + } let userConfig = await this.getUserConfig(this.e.user_id); if (!userConfig) {