mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
fix(daily_report): 添加日报获取错误处理及日志记录
This commit is contained in:
parent
d7f97ac3ee
commit
77f577404b
1 changed files with 6 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ from nonebot.plugin import on_command
|
||||||
from nonebot.adapters.qq import MessageSegment
|
from nonebot.adapters.qq import MessageSegment
|
||||||
from src.clover_report.data_source import Report
|
from src.clover_report.data_source import Report
|
||||||
from src.configs.path_config import temp_path
|
from src.configs.path_config import temp_path
|
||||||
|
from nonebot import logger
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -15,5 +16,9 @@ async def handle_function():
|
||||||
file = Path() / temp_path / f"{now.date()}日报.png"
|
file = Path() / temp_path / f"{now.date()}日报.png"
|
||||||
if not os.path.exists(file):
|
if not os.path.exists(file):
|
||||||
await daily_report.send("您是今天第一个查看日报的哦,来看看世界上都发生了些什么吧💫\nCrunching the latest news, just for you. Hang tight…")
|
await daily_report.send("您是今天第一个查看日报的哦,来看看世界上都发生了些什么吧💫\nCrunching the latest news, just for you. Hang tight…")
|
||||||
await Report.get_report_image()
|
try:
|
||||||
|
await Report.get_report_image()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"日报获取失败:{e}")
|
||||||
|
await daily_report.finish("出错啦,请重试。")
|
||||||
await daily_report.finish(MessageSegment.file_image(Path(temp_path+f"{now.date()}日报.png")))
|
await daily_report.finish(MessageSegment.file_image(Path(temp_path+f"{now.date()}日报.png")))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue