fix: 增加异常捕捉

This commit is contained in:
xiaoyan 2023-09-28 17:37:38 +08:00
parent 8fd0c6d922
commit b1a69bdd94
2 changed files with 15 additions and 7 deletions

Binary file not shown.

View File

@ -9,7 +9,8 @@ from nonebot import on_command
from nonebot.rule import to_me
from requests_html import HTMLSession, HTML
import json
from selenium.webdriver import Chrome, ChromeOptions
from nonebot import logger
# from selenium.webdriver import Chrome, ChromeOptions
tongjiCommand = on_command("统计", rule=to_me(), aliases={'微头条', 'tongji', 'tj'}, priority=10)
@ -23,12 +24,19 @@ weitoutiaoMap = {"太能喵": 0, "小小": 0, "大帝强": 0, "叶小欢": 0}
"""
@tongjiCommand.handle()
async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()):
# 清空原有的weitoutiaoMap中的统计结果
for k,v in weitoutiaoMap.items():
weitoutiaoMap[k] = 0
getWeiToutiaoInfo()
# 将上周的微头条考核结果发送给用户
await tongjiCommand.finish(str(weitoutiaoMap))
from nonebot.exception import MatcherException
try:
# 清空原有的weitoutiaoMap中的统计结果
for k,v in weitoutiaoMap.items():
weitoutiaoMap[k] = 0
getWeiToutiaoInfo()
# 将上周的微头条考核结果发送给用户
await tongjiCommand.finish(str(weitoutiaoMap))
except MatcherException:
raise
except Exception as e:
logger.error(e)
print(e)
"""
获取微头条数据信息