From 48ccaabf66828594051de919c9b52098debf95a3 Mon Sep 17 00:00:00 2001 From: Kyomotoi Date: Sat, 18 Jun 2022 00:19:13 +0800 Subject: =?UTF-8?q?=F0=9F=9A=9A=F0=9F=92=A9=20=E7=A7=BB=E5=8A=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E7=9B=B8=E5=85=B3=E5=87=BD=E6=95=B0,=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/essential.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'ATRI/plugins/essential.py') diff --git a/ATRI/plugins/essential.py b/ATRI/plugins/essential.py index 763b137..b0c1d02 100644 --- a/ATRI/plugins/essential.py +++ b/ATRI/plugins/essential.py @@ -31,6 +31,7 @@ import ATRI from ATRI.service import Service from ATRI.log import logger as log from ATRI.config import BotSelfConfig +from ATRI.database import init_database, close_database_connection from ATRI.utils import MessageChecker from ATRI.utils.apscheduler import scheduler from ATRI.utils.check_update import CheckUpdate @@ -77,6 +78,10 @@ async def shutdown(): log.info("Thanks for using.") +driver.on_startup(init_database) +driver.on_shutdown(close_database_connection) + + @run_preprocessor async def _check_block(event: MessageEvent): user_file = "block_user.json" @@ -87,7 +92,7 @@ async def _check_block(event: MessageEvent): try: data = json.loads(path.read_bytes()) - except BaseException: + except Exception: data = dict() user_id = event.get_user_id() @@ -103,7 +108,7 @@ async def _check_block(event: MessageEvent): try: data = json.loads(path.read_bytes()) - except BaseException: + except Exception: data = dict() group_id = str(event.group_id) @@ -290,7 +295,7 @@ async def _recall_group_event(bot: Bot, event: GroupRecallNoticeEvent): try: repo = await bot.get_msg(message_id=event.message_id) - except BaseException: + except Exception: return log.debug(f"Recall raw msg:\n{repo}") @@ -300,7 +305,7 @@ async def _recall_group_event(bot: Bot, event: GroupRecallNoticeEvent): try: m = recall_msg_dealer(repo) - except: + except Exception: check = MessageChecker(repo).check_cq_code if not check: m = repo @@ -322,7 +327,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent): try: repo = await bot.get_msg(message_id=event.message_id) - except BaseException: + except Exception: return log.debug(f"Recall raw msg:\n{repo}") @@ -331,7 +336,7 @@ async def _recall_private_event(bot: Bot, event: FriendRecallNoticeEvent): try: m = recall_msg_dealer(repo) - except: + except Exception: check = MessageChecker(repo).check_cq_code if not check: m = repo -- cgit v1.2.3