nonebot2/nonebot/adapters/coolq.py
2020-07-11 17:32:03 +08:00

41 lines
994 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import httpx
from nonebot.event import Event
from nonebot.config import Config
from nonebot.adapters import BaseBot, BaseMessage, BaseMessageSegment
from nonebot.message import handle_event
class Bot(BaseBot):
def __init__(self, type_: str, config: Config, *, websocket=None):
if type_ not in ["http", "websocket"]:
raise ValueError("Unsupported connection type")
self.type = type_
self.config = config
self.websocket = websocket
async def handle_message(self, message: dict):
# TODO: convert message into event
event = Event.from_payload(message)
# TODO: Handle Meta Event
await handle_event(self, event)
async def call_api(self, api: str, data: dict):
if self.type == "websocket":
pass
elif self.type == "http":
pass
class MessageSegment(BaseMessageSegment):
pass
class Message(BaseMessage):
pass