perf: 添加多个平台适配器并更新 get_client 方法的返回类型
This commit is contained in:
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -93,5 +93,5 @@ class GewechatPlatformAdapter(Platform):
|
||||
|
||||
self.commit_event(message_event)
|
||||
|
||||
def get_client(self):
|
||||
def get_client(self) -> SimpleGewechatClient:
|
||||
return self.client
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -230,5 +230,5 @@ class WecomPlatformAdapter(Platform):
|
||||
)
|
||||
self.commit_event(message_event)
|
||||
|
||||
def get_client(self):
|
||||
def get_client(self) -> WeChatClient:
|
||||
return self.client
|
||||
|
||||
Reference in New Issue
Block a user