From 687b087f83c6565efdeb72c3b00ff13ef6b8c8f1 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Thu, 6 Apr 2023 08:09:28 +0000 Subject: =?UTF-8?q?:rotating=5Flight:=20=E8=87=AA=E5=8A=A8=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/database/wrapper.py | 12 +++++------- ATRI/plugins/thesaurus/__init__.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'ATRI') diff --git a/ATRI/database/wrapper.py b/ATRI/database/wrapper.py index 7838bd6..df6057f 100644 --- a/ATRI/database/wrapper.py +++ b/ATRI/database/wrapper.py @@ -6,7 +6,7 @@ from tortoise.models import Model class DatabaseWrapper: def __init__(self, model: Type[Model]): self.model = model - + async def __aenter__(self): return self @@ -15,17 +15,15 @@ class DatabaseWrapper: async def add_sub(self, *args, **kwargs): await self.model.create(*args, **kwargs) - + async def update_sub(self, update_map: dict, **kwargs): - await self.model.filter(**kwargs).update( - **update_map - ) + await self.model.filter(**kwargs).update(**update_map) async def del_sub(self, query_map: dict): await self.model.filter(**query_map).delete() - + async def get_sub_list(self, query_map: dict) -> list: return await self.model.filter(**query_map) - + async def get_all_subs(self) -> list: return await self.model.all() diff --git a/ATRI/plugins/thesaurus/__init__.py b/ATRI/plugins/thesaurus/__init__.py index 0409008..4884801 100644 --- a/ATRI/plugins/thesaurus/__init__.py +++ b/ATRI/plugins/thesaurus/__init__.py @@ -228,7 +228,17 @@ async def _add_global_item( ans = unescape(item_a).split(",,") result = await tm.add_item( - item_id, True, unescape(item_q), ans, need_at, item_t, 0, operator, opeartor_id, 0, list() + item_id, + True, + unescape(item_q), + ans, + need_at, + item_t, + 0, + operator, + opeartor_id, + 0, + list(), ) await add_item_for_global.finish(result) -- cgit v1.2.3