优化时间读取逻辑

This commit is contained in:
2025-10-09 19:55:53 +08:00
parent 8edb999050
commit c35ee57976
4 changed files with 35 additions and 364 deletions

View File

@ -4,6 +4,7 @@ from pathlib import Path
from typing import Any, Literal, cast
import nonebot
import ptimeparse
from loguru import logger
from nonebot import on_message
from nonebot.adapters import Event
@ -19,8 +20,6 @@ from nonebot.adapters.onebot.v11.event import \
from nonebot_plugin_alconna import UniMessage, UniMsg
from pydantic import BaseModel
from konabot.plugins.simple_notify.parse_time import get_target_time
evt = on_message()
(Path(__file__).parent.parent.parent.parent / "data").mkdir(exist_ok=True)
@ -141,10 +140,15 @@ async def _(msg: UniMsg, mEvt: Event):
return
notify_time, notify_text = segments
target_time = get_target_time(notify_time)
if target_time is None:
# target_time = get_target_time(notify_time)
try:
target_time = ptimeparse.parse(notify_time)
except Exception:
logger.info(f"无法从 {notify_time} 中解析出时间")
return
# if target_time is None:
# logger.info(f"无法从 {notify_time} 中解析出时间")
# return
if not notify_text:
return