From 465573fff434e94044ff95ca41000896b05c365f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=9A=E7=BE=85=E7=8B=BC?= Date: Sun, 4 Aug 2024 01:55:14 +0800 Subject: [PATCH] Run pre-commit hook --- bots/aiocqhttp/bot.py | 2 +- bots/api/bot.py | 7 +++---- core/parser/message.py | 3 ++- database/__init__.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bots/aiocqhttp/bot.py b/bots/aiocqhttp/bot.py index 850b0cf137..62289deccd 100644 --- a/bots/aiocqhttp/bot.py +++ b/bots/aiocqhttp/bot.py @@ -159,7 +159,7 @@ async def _(event: Event): async def _(event: Event): if event.user_id == int(qq_account): unfriendly_actions = BotDBUtil.UnfriendlyActions(target_id=event.group_id, - sender_id=event.operator_id) + sender_id=event.operator_id) sender_info = BotDBUtil.SenderInfo('QQ|' + str(event.operator_id)) unfriendly_actions.add('mute', str(event.duration)) result = unfriendly_actions.check_mute() diff --git a/bots/api/bot.py b/bots/api/bot.py index a88a28ff07..1d4dbd93a4 100644 --- a/bots/api/bot.py +++ b/bots/api/bot.py @@ -67,7 +67,6 @@ async def get_target(target_id: str): dice_dc_reversed = target.get_option('dice_dc_reversed', False) dice_default_sides = target.get_option('dice_default_sides', 0) - wiki_target = WikiTargetInfo(target_id) wiki_headers = wiki_target.get_headers() @@ -155,7 +154,7 @@ async def enable_modules(target_id: str, request: Request): "detail": "Not Found" }) target_from = '|'.join(target_id.split('|')[:-2]) - + body = await request.json() modules = body["modules"] modules = modules if isinstance(modules, list) else [modules] @@ -167,7 +166,7 @@ async def enable_modules(target_id: str, request: Request): "detail": "Bad Request", "message": "error" }) - + @app.post('/modules/{target_id}/disable') async def enable_modules(target_id: str, request: Request): @@ -178,7 +177,7 @@ async def enable_modules(target_id: str, request: Request): "detail": "Not Found" }) target_from = '|'.join(target_id.split('|')[:-2]) - + body = await request.json() modules = body["modules"] modules = modules if isinstance(modules, list) else [modules] diff --git a/core/parser/message.py b/core/parser/message.py index 1cedb32027..51253ed61b 100644 --- a/core/parser/message.py +++ b/core/parser/message.py @@ -46,7 +46,8 @@ async def remove_temp_ban(target): async def tos_abuse_warning(msg: Bot.MessageSession, e): - if enable_tos and Config('tos_warning_counts', 5) >= 1 and not msg.check_super_user() and not msg.target.sender_info.is_in_allow_list: + if enable_tos and Config('tos_warning_counts', 5) >= 1 and not msg.check_super_user( + ) and not msg.target.sender_info.is_in_allow_list: await warn_target(msg, str(e)) temp_ban_counter[msg.target.sender_id] = {'count': 1, 'ts': datetime.now().timestamp()} diff --git a/database/__init__.py b/database/__init__.py index 748e196400..b18e3b35c4 100644 --- a/database/__init__.py +++ b/database/__init__.py @@ -235,7 +235,7 @@ def __init__(self, sender_id): @property def query_SenderInfo(self): return session.query(SenderInfo).filter_by(id=self.sender_id).first() - + @retry(stop=stop_after_attempt(3)) @auto_rollback_error def init(self): @@ -251,25 +251,25 @@ def is_in_block_list(self): if not self.query: return False return self.query.isInBlockList - + @property def is_in_allow_list(self): if not self.query: return False return self.query.isInAllowList - + @property def is_super_user(self): if not self.query: return False return self.query.isSuperUser - + @property def warns(self): if not self.query: return 0 return self.query.warns - + @property def disable_typing(self): if not self.query: