From 39415fd525bb1eba2e29f7fc029f94036b8f1238 Mon Sep 17 00:00:00 2001 From: Komorebi <110453675+KomoriDev@users.noreply.github.com> Date: Wed, 16 Aug 2023 01:57:19 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E4=BD=BF=E7=94=A8=E5=9F=BA=E7=B1=BB=20?= =?UTF-8?q?Event=20=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20(#18)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sora/utils/user.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/sora/utils/user.py b/sora/utils/user.py index 61c702d..007e08f 100644 --- a/sora/utils/user.py +++ b/sora/utils/user.py @@ -3,9 +3,7 @@ from pathlib import Path from nonebot.params import Depends -from nonebot.adapters.qqguild import MessageEvent as GuildMessageEvent -from nonebot.adapters.onebot.v11 import MessageEvent as V11MessageEvent -from nonebot.adapters.telegram.event import MessageEvent as TGMessageEvent +from nonebot.internal.adapter import Event from sora.config import Config from sora.config.path import DATABASE_PATH @@ -18,9 +16,7 @@ def generate_password(length=10, chars=string.ascii_letters + string.digits): return "".join([random.choice(chars) for i in range(length)]) -async def get_user_id( - event: V11MessageEvent | GuildMessageEvent | TGMessageEvent, -) -> str | None: +async def get_user_id(event: Event) -> str | None: """ ι€šθΏ‡ event.userid θŽ·ε– ID @@ -36,9 +32,7 @@ async def get_user_id( return user_id -async def get_bind_info( - event: V11MessageEvent | GuildMessageEvent | TGMessageEvent, account=None -) -> UserBind: +async def get_bind_info(event: Event, account=None) -> UserBind: if account is not None: user = await UserBind.get(account=account) else: @@ -72,9 +66,7 @@ def getUserInfo(): :return: userInfo """ - async def dependency( - event: V11MessageEvent | GuildMessageEvent | TGMessageEvent, - ) -> UserInfo | None: + async def dependency(event: Event) -> UserInfo | None: return await get_user_info(event) return Depends(dependency)