mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-18 09:25:46 +08:00
🚧 start working on mirai-api-http adapter
This commit is contained in:
parent
a6fcc1ea2a
commit
8574b2ec72
1
nonebot/adapters/mirai/__init__.py
Normal file
1
nonebot/adapters/mirai/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .bot import MiraiBot
|
39
nonebot/adapters/mirai/bot.py
Normal file
39
nonebot/adapters/mirai/bot.py
Normal file
@ -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)
|
1
nonebot/adapters/mirai/message.py
Normal file
1
nonebot/adapters/mirai/message.py
Normal file
@ -0,0 +1 @@
|
||||
from nonebot.adapters import Message
|
Loading…
Reference in New Issue
Block a user