nonebot2/nonebot/drivers/__init__.py

68 lines
1.3 KiB
Python
Raw Normal View History

2020-07-04 22:51:10 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Optional
from ipaddress import IPv4Address
2020-07-11 17:32:03 +08:00
from nonebot.config import Config
2020-07-04 22:51:10 +08:00
class BaseDriver(object):
2020-07-11 17:32:03 +08:00
def __init__(self, config: Config):
2020-07-05 20:39:34 +08:00
raise NotImplementedError
2020-07-04 22:51:10 +08:00
@property
def server_app(self):
raise NotImplementedError
@property
def asgi(self):
raise NotImplementedError
@property
def logger(self):
raise NotImplementedError
def run(self,
host: Optional[IPv4Address] = None,
port: Optional[int] = None,
*args,
**kwargs):
raise NotImplementedError
2020-07-05 20:39:34 +08:00
async def _handle_http(self):
raise NotImplementedError
async def _handle_ws_reverse(self):
raise NotImplementedError
2020-07-11 17:32:03 +08:00
async def _handle_http_api(self):
raise NotImplementedError
class BaseWebSocket(object):
def __init__(self, websocket):
self._websocket = websocket
@property
def websocket(self):
return self._websocket
@property
def closed(self):
raise NotImplementedError
async def accept(self):
raise NotImplementedError
async def close(self):
raise NotImplementedError
async def receive(self) -> dict:
raise NotImplementedError
async def send(self, data: dict):
raise NotImplementedError