Skip to content

Commit

Permalink
fix(onebot): 修复 OneBot 适配器 typo (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
st1020 authored Jul 20, 2024
1 parent 35d85b0 commit 5a23f51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
ConnectMetaEvent,
HeartbeatMetaEvent,
MetaEvent,
OntBotEvent,
OneBotEvent,
StatusUpdateMetaEvent,
)
from .exceptions import ActionFailed, ApiTimeout, NetworkError
Expand All @@ -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"
Expand Down Expand Up @@ -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: 事件模型类。
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""OntBot 适配器事件。"""
"""OneBot 适配器事件。"""
# pyright: reportIncompatibleVariableOverride=false

from typing import TYPE_CHECKING, Any, Literal, Optional, get_args, get_origin
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion packages/alicebot-adapter-onebot/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "OneBot v12 adapter for AliceBot."
authors = [{ name = "st1020", email = "[email protected]" }]
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",
Expand Down

0 comments on commit 5a23f51

Please sign in to comment.