nonebot2/nonebot/adapters/coolq.py

41 lines
994 B
Python
Raw Normal View History

2020-07-05 20:39:34 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2020-07-11 17:32:03 +08:00
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
2020-07-05 20:39:34 +08:00
class Bot(BaseBot):
2020-07-11 17:32:03 +08:00
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