From ec3fe28cc595d0bcf46806274f23ebe976a79bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wuyi=E6=97=A0=E7=96=91?= <444835641@qq.com> Date: Thu, 16 Feb 2023 00:02:35 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=B8=80=E4=BA=9B=E5=B0=8F?= =?UTF-8?q?=E4=BF=AE=E5=B0=8F=E8=A1=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gsuid_core/__init__.py | 5 +++++ gsuid_core/core.py | 1 + gsuid_core/server.py | 8 +++++++- gsuid_core/sv.py | 9 +++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/gsuid_core/__init__.py b/gsuid_core/__init__.py index 1b305ab..4c30586 100644 --- a/gsuid_core/__init__.py +++ b/gsuid_core/__init__.py @@ -1 +1,6 @@ +import sys +from pathlib import Path + from .version import __version__ as __version__ # noqa: F401 + +sys.path.append(str(Path(__file__).parents[1])) diff --git a/gsuid_core/core.py b/gsuid_core/core.py index bdd3e6b..803d305 100644 --- a/gsuid_core/core.py +++ b/gsuid_core/core.py @@ -35,3 +35,4 @@ async def websocket_endpoint(websocket: WebSocket, bot_id: str): if __name__ == "__main__": uvicorn.run(app, host=HOST, port=PORT) + uvicorn.run(app, host=HOST, port=PORT) diff --git a/gsuid_core/server.py b/gsuid_core/server.py index 4a46549..04d5075 100644 --- a/gsuid_core/server.py +++ b/gsuid_core/server.py @@ -29,7 +29,13 @@ class Bot: message = [MessageSegment.image(message)] else: message = [MessageSegment.text(message)] - send = MessageSend(content=message, bot_id=self.bot_id) + send = MessageSend( + content=message, + bot_id=self.bot_id, + target_type=self.user_type, + target_id=self.group_id if self.group_id else self.user_id, + ) + print(f'[发送消息] {send}') await self.bot.send_bytes(msgjson.encode(send)) async def _process(self): diff --git a/gsuid_core/sv.py b/gsuid_core/sv.py index 6880ab7..2437877 100644 --- a/gsuid_core/sv.py +++ b/gsuid_core/sv.py @@ -1,5 +1,7 @@ +from __future__ import annotations + from functools import wraps -from typing import Dict, List, Self, Tuple, Union, Literal, Callable, Optional +from typing import Dict, List, Tuple, Union, Literal, Callable, Optional from trigger import Trigger from config import core_config @@ -21,7 +23,7 @@ config_sv = core_config.get_config('sv') class SV: is_initialized = False - def __new__(cls: type[Self], *args): + def __new__(cls, *args): # 判断sv是否已经被初始化 if args[0] in SL.lst: return SL.lst[args[0]] @@ -113,3 +115,6 @@ class SV: def on_keyword(self, keyword: Union[str, Tuple[str, ...]]) -> Callable: return self._on('keyword', keyword) + return self._on('keyword', keyword) + return self._on('keyword', keyword) + return self._on('keyword', keyword)