From 5a23f519a4c4e70e69557610b70ad3aa00990cf6 Mon Sep 17 00:00:00 2001 From: Stone Date: Sat, 20 Jul 2024 17:37:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(onebot):=20=E4=BF=AE=E5=A4=8D=20OneBot=20?= =?UTF-8?q?=E9=80=82=E9=85=8D=E5=99=A8=20typo=20(#132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alicebot/adapter/onebot/__init__.py | 14 +++++++------- .../alicebot/adapter/onebot/event.py | 8 ++++---- packages/alicebot-adapter-onebot/pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/__init__.py b/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/__init__.py index 0a9973c..005fa18 100644 --- a/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/__init__.py +++ b/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/__init__.py @@ -29,7 +29,7 @@ ConnectMetaEvent, HeartbeatMetaEvent, MetaEvent, - OntBotEvent, + OneBotEvent, StatusUpdateMetaEvent, ) from .exceptions import ActionFailed, ApiTimeout, NetworkError @@ -40,16 +40,16 @@ logger = structlog.stdlib.get_logger() EventModels = dict[ - tuple[Optional[str], Optional[str], Optional[str]], type[OntBotEvent] + tuple[Optional[str], Optional[str], Optional[str]], type[OneBotEvent] ] DEFAULT_EVENT_MODELS: EventModels = {} for _, model in inspect.getmembers(event, inspect.isclass): - if issubclass(model, OntBotEvent): + if issubclass(model, OneBotEvent): DEFAULT_EVENT_MODELS[model.get_event_type()] = model -class OneBotAdapter(WebSocketAdapter[OntBotEvent, Config]): +class OneBotAdapter(WebSocketAdapter[OneBotEvent, Config]): """OneBot 协议适配器。""" name = "onebot" @@ -136,8 +136,8 @@ def _get_api_echo(self) -> int: return self._api_id @classmethod - def add_event_model(cls, event_model: type[OntBotEvent]) -> None: - """添加自定义事件模型,事件模型类必须继承于 `OntBotEvent`。 + def add_event_model(cls, event_model: type[OneBotEvent]) -> None: + """添加自定义事件模型,事件模型类必须继承于 `OneBotEvent`。 Args: event_model: 事件模型类。 @@ -150,7 +150,7 @@ def get_event_model( post_type: Optional[str], detail_type: Optional[str], sub_type: Optional[str], - ) -> type[OntBotEvent]: + ) -> type[OneBotEvent]: """根据接收到的消息类型返回对应的事件类。 Args: diff --git a/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/event.py b/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/event.py index 658589d..576b422 100644 --- a/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/event.py +++ b/packages/alicebot-adapter-onebot/alicebot/adapter/onebot/event.py @@ -1,4 +1,4 @@ -"""OntBot 适配器事件。""" +"""OneBot 适配器事件。""" # pyright: reportIncompatibleVariableOverride=false from typing import TYPE_CHECKING, Any, Literal, Optional, get_args, get_origin @@ -60,7 +60,7 @@ def _get_literal_field(field: Optional[FieldInfo]) -> Optional[str]: return literal_values[0] -class OntBotEvent(Event["OneBotAdapter"]): +class OneBotEvent(Event["OneBotAdapter"]): """OneBot 事件基类""" id: str @@ -83,7 +83,7 @@ def get_event_type(cls) -> tuple[Optional[str], Optional[str], Optional[str]]: ) -class BotEvent(OntBotEvent): +class BotEvent(OneBotEvent): """包含 self 字段的机器人事件""" self: BotSelf @@ -94,7 +94,7 @@ def to_me(self) -> bool: return getattr(self, "user_id", None) == self.self.user_id -class MetaEvent(OntBotEvent): +class MetaEvent(OneBotEvent): """元事件""" type: Literal["meta"] diff --git a/packages/alicebot-adapter-onebot/pyproject.toml b/packages/alicebot-adapter-onebot/pyproject.toml index 53536d3..f5eb6f6 100644 --- a/packages/alicebot-adapter-onebot/pyproject.toml +++ b/packages/alicebot-adapter-onebot/pyproject.toml @@ -5,7 +5,7 @@ description = "OneBot v12 adapter for AliceBot." authors = [{ name = "st1020", email = "stone_1020@qq.com" }] license = { text = "MIT" } readme = "README.md" -keywords = ["bot", "chatbot", "qq", "ontbot", "cqhttp"] +keywords = ["bot", "chatbot", "qq", "onebot", "cqhttp"] classifiers = [ "Development Status :: 3 - Alpha", "Framework :: AsyncIO",