fix: 增加异常捕捉
This commit is contained in:
parent
8fd0c6d922
commit
b1a69bdd94
Binary file not shown.
@ -9,7 +9,8 @@ from nonebot import on_command
|
|||||||
from nonebot.rule import to_me
|
from nonebot.rule import to_me
|
||||||
from requests_html import HTMLSession, HTML
|
from requests_html import HTMLSession, HTML
|
||||||
import json
|
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)
|
tongjiCommand = on_command("统计", rule=to_me(), aliases={'微头条', 'tongji', 'tj'}, priority=10)
|
||||||
|
|
||||||
@ -23,12 +24,19 @@ weitoutiaoMap = {"太能喵": 0, "小小": 0, "大帝强": 0, "叶小欢": 0}
|
|||||||
"""
|
"""
|
||||||
@tongjiCommand.handle()
|
@tongjiCommand.handle()
|
||||||
async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()):
|
async def handle_first_receive(bot: Bot, event: Event, state: T_State, args= CommandArg()):
|
||||||
|
from nonebot.exception import MatcherException
|
||||||
|
try:
|
||||||
# 清空原有的weitoutiaoMap中的统计结果
|
# 清空原有的weitoutiaoMap中的统计结果
|
||||||
for k,v in weitoutiaoMap.items():
|
for k,v in weitoutiaoMap.items():
|
||||||
weitoutiaoMap[k] = 0
|
weitoutiaoMap[k] = 0
|
||||||
getWeiToutiaoInfo()
|
getWeiToutiaoInfo()
|
||||||
# 将上周的微头条考核结果发送给用户
|
# 将上周的微头条考核结果发送给用户
|
||||||
await tongjiCommand.finish(str(weitoutiaoMap))
|
await tongjiCommand.finish(str(weitoutiaoMap))
|
||||||
|
except MatcherException:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
print(e)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
获取微头条数据信息
|
获取微头条数据信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user