From 8574b2ec72365ab07bf21b7d9a2ac85cb5378599 Mon Sep 17 00:00:00 2001 From: Mix Date: Fri, 29 Jan 2021 17:37:44 +0800 Subject: [PATCH] :construction: start working on mirai-api-http adapter --- nonebot/adapters/mirai/__init__.py | 1 + nonebot/adapters/mirai/bot.py | 39 ++++++++++++++++++++++++++++++ nonebot/adapters/mirai/message.py | 1 + 3 files changed, 41 insertions(+) create mode 100644 nonebot/adapters/mirai/__init__.py create mode 100644 nonebot/adapters/mirai/bot.py create mode 100644 nonebot/adapters/mirai/message.py diff --git a/nonebot/adapters/mirai/__init__.py b/nonebot/adapters/mirai/__init__.py new file mode 100644 index 00000000..c832d378 --- /dev/null +++ b/nonebot/adapters/mirai/__init__.py @@ -0,0 +1 @@ +from .bot import MiraiBot \ No newline at end of file diff --git a/nonebot/adapters/mirai/bot.py b/nonebot/adapters/mirai/bot.py new file mode 100644 index 00000000..8b192b37 --- /dev/null +++ b/nonebot/adapters/mirai/bot.py @@ -0,0 +1,39 @@ +from pprint import pprint +from typing import Optional + +from nonebot.adapters import Bot as BaseBot +from nonebot.drivers import Driver, WebSocket +from nonebot.typing import overrides + + +class MiraiBot(BaseBot): + + def __init__(self, + connection_type: str, + self_id: str, + *, + websocket: Optional["WebSocket"] = None): + super().__init__(connection_type, self_id, websocket=websocket) + + @property + @overrides(BaseBot) + def type(self) -> str: + return "mirai" + + @classmethod + @overrides(BaseBot) + async def check_permission(cls, driver: "Driver", connection_type: str, + headers: dict, body: Optional[dict]) -> str: + return '' + + @overrides(BaseBot) + async def handle_message(self, message: dict): + pprint(message) + + @overrides(BaseBot) + async def call_api(self, api: str, **data): + return super().call_api(api, **data) + + @overrides(BaseBot) + async def send(self, event: "Event", message: str, **kwargs): + return super().send(event, message, **kwargs) diff --git a/nonebot/adapters/mirai/message.py b/nonebot/adapters/mirai/message.py new file mode 100644 index 00000000..edf1b6d0 --- /dev/null +++ b/nonebot/adapters/mirai/message.py @@ -0,0 +1 @@ +from nonebot.adapters import Message \ No newline at end of file