From 14bb245424d946ea264280128be47099efc7ac61 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Tue, 4 Mar 2025 00:19:33 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B7=BB=E5=8A=A0=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E9=80=82=E9=85=8D=E5=99=A8=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20get=5Fclient=20=E6=96=B9=E6=B3=95=E7=9A=84=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/api/platform/__init__.py | 17 +++++++++++++++++ .../aiocqhttp/aiocqhttp_platform_adapter.py | 2 +- .../gewechat/gewechat_platform_adapter.py | 2 +- .../core/platform/sources/lark/lark_adapter.py | 2 +- .../qqofficial/qqofficial_platform_adapter.py | 2 +- .../qqofficial_webhook/qo_webhook_adapter.py | 2 +- .../platform/sources/telegram/tg_adapter.py | 3 ++- .../platform/sources/wecom/wecom_adapter.py | 2 +- 8 files changed, 25 insertions(+), 7 deletions(-) diff --git a/astrbot/api/platform/__init__.py b/astrbot/api/platform/__init__.py index dcc02bb49..0ac829de3 100644 --- a/astrbot/api/platform/__init__.py +++ b/astrbot/api/platform/__init__.py @@ -10,6 +10,15 @@ from astrbot.core.platform import ( from astrbot.core.platform.register import register_platform_adapter from astrbot.core.message.components import * +from astrbot.core.platform.sources.aiocqhttp.aiocqhttp_platform_adapter import AiocqhttpAdapter +from astrbot.core.platform.sources.qqofficial.qqofficial_platform_adapter import QQOfficialPlatformAdapter +from astrbot.core.platform.sources.qqofficial_webhook.qo_webhook_adapter import QQOfficialWebhookPlatformAdapter +from astrbot.core.platform.sources.gewechat.gewechat_platform_adapter import GewechatPlatformAdapter +from astrbot.core.platform.sources.telegram.tg_adapter import TelegramPlatformAdapter +from astrbot.core.platform.sources.webchat.webchat_adapter import WebChatAdapter +from astrbot.core.platform.sources.wecom.wecom_adapter import WecomPlatformAdapter +from astrbot.core.platform.sources.lark.lark_adapter import LarkPlatformAdapter + __all__ = [ "AstrMessageEvent", "Platform", @@ -18,4 +27,12 @@ __all__ = [ "MessageType", "PlatformMetadata", "register_platform_adapter", + "AiocqhttpAdapter", + "QQOfficialPlatformAdapter", + "QQOfficialWebhookPlatformAdapter", + "GewechatPlatformAdapter", + "TelegramPlatformAdapter", + "WebChatAdapter", + "WecomPlatformAdapter", + "LarkPlatformAdapter", ] diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py index f21fda066..525869980 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py @@ -294,5 +294,5 @@ class AiocqhttpAdapter(Platform): self.commit_event(message_event) - async def get_client(self): + def get_client(self) -> CQHttp: return self.bot diff --git a/astrbot/core/platform/sources/gewechat/gewechat_platform_adapter.py b/astrbot/core/platform/sources/gewechat/gewechat_platform_adapter.py index fa7be6bb2..c4751c7b1 100644 --- a/astrbot/core/platform/sources/gewechat/gewechat_platform_adapter.py +++ b/astrbot/core/platform/sources/gewechat/gewechat_platform_adapter.py @@ -93,5 +93,5 @@ class GewechatPlatformAdapter(Platform): self.commit_event(message_event) - def get_client(self): + def get_client(self) -> SimpleGewechatClient: return self.client diff --git a/astrbot/core/platform/sources/lark/lark_adapter.py b/astrbot/core/platform/sources/lark/lark_adapter.py index 282b22149..4188771d0 100644 --- a/astrbot/core/platform/sources/lark/lark_adapter.py +++ b/astrbot/core/platform/sources/lark/lark_adapter.py @@ -185,5 +185,5 @@ class LarkPlatformAdapter(Platform): # self.client.start() await self.client._connect() - async def get_client(self): + def get_client(self) -> lark.Client: return self.client diff --git a/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py b/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py index f932b4ec8..ae1dc2563 100644 --- a/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py +++ b/astrbot/core/platform/sources/qqofficial/qqofficial_platform_adapter.py @@ -202,5 +202,5 @@ class QQOfficialPlatformAdapter(Platform): def run(self): return self.client.start(appid=self.appid, secret=self.secret) - def get_client(self): + def get_client(self) -> botClient: return self.client diff --git a/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py b/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py index 44686e1dc..542233591 100644 --- a/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py +++ b/astrbot/core/platform/sources/qqofficial_webhook/qo_webhook_adapter.py @@ -109,5 +109,5 @@ class QQOfficialWebhookPlatformAdapter(Platform): await self.webhook_helper.initialize() await self.webhook_helper.start_polling() - async def get_client(self): + def get_client(self) -> botClient: return self.client diff --git a/astrbot/core/platform/sources/telegram/tg_adapter.py b/astrbot/core/platform/sources/telegram/tg_adapter.py index b944941c0..c3db89249 100644 --- a/astrbot/core/platform/sources/telegram/tg_adapter.py +++ b/astrbot/core/platform/sources/telegram/tg_adapter.py @@ -27,6 +27,7 @@ from telegram.constants import ChatType from telegram.ext import MessageHandler as TelegramMessageHandler from .tg_event import TelegramPlatformEvent from astrbot.api import logger +from telegram.ext import ExtBot if sys.version_info >= (3, 12): from typing import override @@ -167,5 +168,5 @@ class TelegramPlatformAdapter(Platform): ) self.commit_event(message_event) - async def get_client(self): + def get_client(self) -> ExtBot: return self.client diff --git a/astrbot/core/platform/sources/wecom/wecom_adapter.py b/astrbot/core/platform/sources/wecom/wecom_adapter.py index 16f3fdd13..77eae03d6 100644 --- a/astrbot/core/platform/sources/wecom/wecom_adapter.py +++ b/astrbot/core/platform/sources/wecom/wecom_adapter.py @@ -230,5 +230,5 @@ class WecomPlatformAdapter(Platform): ) self.commit_event(message_event) - def get_client(self): + def get_client(self) -> WeChatClient: return self.client