mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 08:41:29 +00:00
🏗️ change nonebot project structure
This commit is contained in:
0
packages/nonebot-adapter-cqhttp/README.md
Normal file
0
packages/nonebot-adapter-cqhttp/README.md
Normal file
0
packages/nonebot-adapter-cqhttp/nonebot/__init__.py
Normal file
0
packages/nonebot-adapter-cqhttp/nonebot/__init__.py
Normal file
@ -0,0 +1,18 @@
|
||||
"""
|
||||
CQHTTP (OneBot) v11 协议适配
|
||||
============================
|
||||
|
||||
协议详情请看: `CQHTTP`_ | `OneBot`_
|
||||
|
||||
.. _CQHTTP:
|
||||
https://github.com/howmanybots/onebot/blob/master/README.md
|
||||
.. _OneBot:
|
||||
https://github.com/howmanybots/onebot/blob/master/README.md
|
||||
"""
|
||||
|
||||
from .event import *
|
||||
from .permission import *
|
||||
from .message import Message, MessageSegment
|
||||
from .utils import log, escape, unescape, _b2s
|
||||
from .bot import Bot, _check_at_me, _check_nickname, _check_reply, _handle_api_result
|
||||
from .exception import CQHTTPAdapterException, ApiNotAvailable, ActionFailed, NetworkError
|
454
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/bot.py
Normal file
454
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/bot.py
Normal file
@ -0,0 +1,454 @@
|
||||
import re
|
||||
import sys
|
||||
import hmac
|
||||
import json
|
||||
import asyncio
|
||||
from typing import Any, Dict, Union, Optional, TYPE_CHECKING
|
||||
|
||||
import httpx
|
||||
from nonebot.log import logger
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.message import handle_event
|
||||
from nonebot.adapters import Bot as BaseBot
|
||||
from nonebot.exception import RequestDenied
|
||||
|
||||
from .utils import log, escape
|
||||
from .config import Config as CQHTTPConfig
|
||||
from .message import Message, MessageSegment
|
||||
from .event import Reply, Event, MessageEvent, get_event_model
|
||||
from .exception import NetworkError, ApiNotAvailable, ActionFailed
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from nonebot.config import Config
|
||||
from nonebot.drivers import Driver, WebSocket
|
||||
|
||||
|
||||
def get_auth_bearer(access_token: Optional[str] = None) -> Optional[str]:
|
||||
if not access_token:
|
||||
return None
|
||||
scheme, _, param = access_token.partition(" ")
|
||||
if scheme.lower() not in ["bearer", "token"]:
|
||||
raise RequestDenied(401, "Not authenticated")
|
||||
return param
|
||||
|
||||
|
||||
async def _check_reply(bot: "Bot", event: "Event"):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
检查消息中存在的回复,去除并赋值 ``event.reply``, ``event.to_me``
|
||||
|
||||
:参数:
|
||||
|
||||
* ``bot: Bot``: Bot 对象
|
||||
* ``event: Event``: Event 对象
|
||||
"""
|
||||
if not isinstance(event, MessageEvent):
|
||||
return
|
||||
|
||||
try:
|
||||
index = list(map(lambda x: x.type == "reply",
|
||||
event.message)).index(True)
|
||||
except ValueError:
|
||||
return
|
||||
msg_seg = event.message[index]
|
||||
event.reply = Reply.parse_obj(await
|
||||
bot.get_msg(message_id=msg_seg.data["id"]))
|
||||
# ensure string comparation
|
||||
if str(event.reply.sender.user_id) == str(event.self_id):
|
||||
event.to_me = True
|
||||
del event.message[index]
|
||||
if len(event.message) > index and event.message[index].type == "at":
|
||||
del event.message[index]
|
||||
if len(event.message) > index and event.message[index].type == "text":
|
||||
event.message[index].data["text"] = event.message[index].data[
|
||||
"text"].lstrip()
|
||||
if not event.message[index].data["text"]:
|
||||
del event.message[index]
|
||||
if not event.message:
|
||||
event.message.append(MessageSegment.text(""))
|
||||
|
||||
|
||||
def _check_at_me(bot: "Bot", event: "Event"):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
检查消息开头或结尾是否存在 @机器人,去除并赋值 ``event.to_me``
|
||||
|
||||
:参数:
|
||||
|
||||
* ``bot: Bot``: Bot 对象
|
||||
* ``event: Event``: Event 对象
|
||||
"""
|
||||
if not isinstance(event, MessageEvent):
|
||||
return
|
||||
|
||||
# ensure message not empty
|
||||
if not event.message:
|
||||
event.message.append(MessageSegment.text(""))
|
||||
|
||||
if event.message_type == "private":
|
||||
event.to_me = True
|
||||
else:
|
||||
at_me_seg = MessageSegment.at(event.self_id)
|
||||
|
||||
# check the first segment
|
||||
if event.message[0] == at_me_seg:
|
||||
event.to_me = True
|
||||
del event.message[0]
|
||||
if event.message and event.message[0].type == "text":
|
||||
event.message[0].data["text"] = event.message[0].data[
|
||||
"text"].lstrip()
|
||||
if not event.message[0].data["text"]:
|
||||
del event.message[0]
|
||||
if event.message and event.message[0] == at_me_seg:
|
||||
del event.message[0]
|
||||
if event.message and event.message[0].type == "text":
|
||||
event.message[0].data["text"] = event.message[0].data[
|
||||
"text"].lstrip()
|
||||
if not event.message[0].data["text"]:
|
||||
del event.message[0]
|
||||
|
||||
if not event.to_me:
|
||||
# check the last segment
|
||||
i = -1
|
||||
last_msg_seg = event.message[i]
|
||||
if last_msg_seg.type == "text" and \
|
||||
not last_msg_seg.data["text"].strip() and \
|
||||
len(event.message) >= 2:
|
||||
i -= 1
|
||||
last_msg_seg = event.message[i]
|
||||
|
||||
if last_msg_seg == at_me_seg:
|
||||
event.to_me = True
|
||||
del event.message[i:]
|
||||
|
||||
if not event.message:
|
||||
event.message.append(MessageSegment.text(""))
|
||||
|
||||
|
||||
def _check_nickname(bot: "Bot", event: "Event"):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
检查消息开头是否存在,去除并赋值 ``event.to_me``
|
||||
|
||||
:参数:
|
||||
|
||||
* ``bot: Bot``: Bot 对象
|
||||
* ``event: Event``: Event 对象
|
||||
"""
|
||||
if not isinstance(event, MessageEvent):
|
||||
return
|
||||
|
||||
first_msg_seg = event.message[0]
|
||||
if first_msg_seg.type != "text":
|
||||
return
|
||||
|
||||
first_text = first_msg_seg.data["text"]
|
||||
|
||||
nicknames = set(filter(lambda n: n, bot.config.nickname))
|
||||
if nicknames:
|
||||
# check if the user is calling me with my nickname
|
||||
nickname_regex = "|".join(nicknames)
|
||||
m = re.search(rf"^({nickname_regex})([\s,,]*|$)", first_text,
|
||||
re.IGNORECASE)
|
||||
if m:
|
||||
nickname = m.group(1)
|
||||
log("DEBUG", f"User is calling me {nickname}")
|
||||
event.to_me = True
|
||||
first_msg_seg.data["text"] = first_text[m.end():]
|
||||
|
||||
|
||||
def _handle_api_result(result: Optional[Dict[str, Any]]) -> Any:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
处理 API 请求返回值。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``result: Optional[Dict[str, Any]]``: API 返回数据
|
||||
|
||||
:返回:
|
||||
|
||||
- ``Any``: API 调用返回数据
|
||||
|
||||
:异常:
|
||||
|
||||
- ``ActionFailed``: API 调用失败
|
||||
"""
|
||||
if isinstance(result, dict):
|
||||
if result.get("status") == "failed":
|
||||
raise ActionFailed(**result)
|
||||
return result.get("data")
|
||||
|
||||
|
||||
class ResultStore:
|
||||
_seq = 1
|
||||
_futures: Dict[int, asyncio.Future] = {}
|
||||
|
||||
@classmethod
|
||||
def get_seq(cls) -> int:
|
||||
s = cls._seq
|
||||
cls._seq = (cls._seq + 1) % sys.maxsize
|
||||
return s
|
||||
|
||||
@classmethod
|
||||
def add_result(cls, result: Dict[str, Any]):
|
||||
if isinstance(result.get("echo"), dict) and \
|
||||
isinstance(result["echo"].get("seq"), int):
|
||||
future = cls._futures.get(result["echo"]["seq"])
|
||||
if future:
|
||||
future.set_result(result)
|
||||
|
||||
@classmethod
|
||||
async def fetch(cls, seq: int, timeout: Optional[float]) -> Dict[str, Any]:
|
||||
future = asyncio.get_event_loop().create_future()
|
||||
cls._futures[seq] = future
|
||||
try:
|
||||
return await asyncio.wait_for(future, timeout)
|
||||
except asyncio.TimeoutError:
|
||||
raise NetworkError("WebSocket API call timeout") from None
|
||||
finally:
|
||||
del cls._futures[seq]
|
||||
|
||||
|
||||
class Bot(BaseBot):
|
||||
"""
|
||||
CQHTTP 协议 Bot 适配。继承属性参考 `BaseBot <./#class-basebot>`_ 。
|
||||
"""
|
||||
cqhttp_config: CQHTTPConfig
|
||||
|
||||
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:
|
||||
"""
|
||||
- 返回: ``"cqhttp"``
|
||||
"""
|
||||
return "cqhttp"
|
||||
|
||||
@classmethod
|
||||
def register(cls, driver: "Driver", config: "Config"):
|
||||
super().register(driver, config)
|
||||
cls.cqhttp_config = CQHTTPConfig(**config.dict())
|
||||
|
||||
@classmethod
|
||||
@overrides(BaseBot)
|
||||
async def check_permission(cls, driver: "Driver", connection_type: str,
|
||||
headers: dict, body: Optional[dict]) -> str:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
CQHTTP (OneBot) 协议鉴权。参考 `鉴权 <https://github.com/howmanybots/onebot/blob/master/v11/specs/communication/authorization.md>`_
|
||||
"""
|
||||
x_self_id = headers.get("x-self-id")
|
||||
x_signature = headers.get("x-signature")
|
||||
token = get_auth_bearer(headers.get("authorization"))
|
||||
cqhttp_config = CQHTTPConfig(**driver.config.dict())
|
||||
|
||||
# 检查连接方式
|
||||
if connection_type not in ["http", "websocket"]:
|
||||
log("WARNING", "Unsupported connection type")
|
||||
raise RequestDenied(405, "Unsupported connection type")
|
||||
|
||||
# 检查self_id
|
||||
if not x_self_id:
|
||||
log("WARNING", "Missing X-Self-ID Header")
|
||||
raise RequestDenied(400, "Missing X-Self-ID Header")
|
||||
|
||||
# 检查签名
|
||||
secret = cqhttp_config.secret
|
||||
if secret and connection_type == "http":
|
||||
if not x_signature:
|
||||
log("WARNING", "Missing Signature Header")
|
||||
raise RequestDenied(401, "Missing Signature")
|
||||
sig = hmac.new(secret.encode("utf-8"),
|
||||
json.dumps(body).encode(), "sha1").hexdigest()
|
||||
if x_signature != "sha1=" + sig:
|
||||
log("WARNING", "Signature Header is invalid")
|
||||
raise RequestDenied(403, "Signature is invalid")
|
||||
|
||||
access_token = cqhttp_config.access_token
|
||||
if access_token and access_token != token:
|
||||
log(
|
||||
"WARNING", "Authorization Header is invalid"
|
||||
if token else "Missing Authorization Header")
|
||||
raise RequestDenied(
|
||||
403, "Authorization Header is invalid"
|
||||
if token else "Missing Authorization Header")
|
||||
return str(x_self_id)
|
||||
|
||||
@overrides(BaseBot)
|
||||
async def handle_message(self, message: dict):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
调用 `_check_reply <#async-check-reply-bot-event>`_, `_check_at_me <#check-at-me-bot-event>`_, `_check_nickname <#check-nickname-bot-event>`_ 处理事件并转换为 `Event <#class-event>`_
|
||||
"""
|
||||
if not message:
|
||||
return
|
||||
|
||||
if "post_type" not in message:
|
||||
ResultStore.add_result(message)
|
||||
return
|
||||
|
||||
try:
|
||||
post_type = message['post_type']
|
||||
detail_type = message.get(f"{post_type}_type")
|
||||
detail_type = f".{detail_type}" if detail_type else ""
|
||||
sub_type = message.get("sub_type")
|
||||
sub_type = f".{sub_type}" if sub_type else ""
|
||||
models = get_event_model(post_type + detail_type + sub_type)
|
||||
for model in models:
|
||||
try:
|
||||
event = model.parse_obj(message)
|
||||
break
|
||||
except Exception as e:
|
||||
log("DEBUG", "Event Parser Error", e)
|
||||
else:
|
||||
event = Event.parse_obj(message)
|
||||
|
||||
# Check whether user is calling me
|
||||
await _check_reply(self, event)
|
||||
_check_at_me(self, event)
|
||||
_check_nickname(self, event)
|
||||
|
||||
await handle_event(self, event)
|
||||
except Exception as e:
|
||||
logger.opt(colors=True, exception=e).error(
|
||||
f"<r><bg #f8bbd0>Failed to handle event. Raw: {message}</bg #f8bbd0></r>"
|
||||
)
|
||||
|
||||
@overrides(BaseBot)
|
||||
async def call_api(self, api: str, **data) -> Any:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
调用 CQHTTP 协议 API
|
||||
|
||||
:参数:
|
||||
|
||||
* ``api: str``: API 名称
|
||||
* ``**data: Any``: API 参数
|
||||
|
||||
:返回:
|
||||
|
||||
- ``Any``: API 调用返回数据
|
||||
|
||||
:异常:
|
||||
|
||||
- ``NetworkError``: 网络错误
|
||||
- ``ActionFailed``: API 调用失败
|
||||
"""
|
||||
if "self_id" in data:
|
||||
self_id = data.pop("self_id")
|
||||
if self_id:
|
||||
bot = self.driver.bots[str(self_id)]
|
||||
return await bot.call_api(api, **data)
|
||||
|
||||
log("DEBUG", f"Calling API <y>{api}</y>")
|
||||
if self.connection_type == "websocket":
|
||||
seq = ResultStore.get_seq()
|
||||
await self.websocket.send({
|
||||
"action": api,
|
||||
"params": data,
|
||||
"echo": {
|
||||
"seq": seq
|
||||
}
|
||||
})
|
||||
return _handle_api_result(await ResultStore.fetch(
|
||||
seq, self.config.api_timeout))
|
||||
|
||||
elif self.connection_type == "http":
|
||||
api_root = self.config.api_root.get(self.self_id)
|
||||
if not api_root:
|
||||
raise ApiNotAvailable
|
||||
elif not api_root.endswith("/"):
|
||||
api_root += "/"
|
||||
|
||||
headers = {}
|
||||
if self.cqhttp_config.access_token is not None:
|
||||
headers[
|
||||
"Authorization"] = "Bearer " + self.cqhttp_config.access_token
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient(headers=headers) as client:
|
||||
response = await client.post(
|
||||
api_root + api,
|
||||
json=data,
|
||||
timeout=self.config.api_timeout)
|
||||
|
||||
if 200 <= response.status_code < 300:
|
||||
result = response.json()
|
||||
return _handle_api_result(result)
|
||||
raise NetworkError(f"HTTP request received unexpected "
|
||||
f"status code: {response.status_code}")
|
||||
except httpx.InvalidURL:
|
||||
raise NetworkError("API root url invalid")
|
||||
except httpx.HTTPError:
|
||||
raise NetworkError("HTTP request failed")
|
||||
|
||||
@overrides(BaseBot)
|
||||
async def send(self,
|
||||
event: Event,
|
||||
message: Union[str, Message, MessageSegment],
|
||||
at_sender: bool = False,
|
||||
**kwargs) -> Any:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
根据 ``event`` 向触发事件的主体发送消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``event: Event``: Event 对象
|
||||
* ``message: Union[str, Message, MessageSegment]``: 要发送的消息
|
||||
* ``at_sender: bool``: 是否 @ 事件主体
|
||||
* ``**kwargs``: 覆盖默认参数
|
||||
|
||||
:返回:
|
||||
|
||||
- ``Any``: API 调用返回数据
|
||||
|
||||
:异常:
|
||||
|
||||
- ``ValueError``: 缺少 ``user_id``, ``group_id``
|
||||
- ``NetworkError``: 网络错误
|
||||
- ``ActionFailed``: API 调用失败
|
||||
"""
|
||||
message = escape(message, escape_comma=False) if isinstance(
|
||||
message, str) else message
|
||||
msg = message if isinstance(message, Message) else Message(message)
|
||||
|
||||
at_sender = at_sender and getattr(event, "user_id", None)
|
||||
|
||||
params = {}
|
||||
if getattr(event, "user_id", None):
|
||||
params["user_id"] = getattr(event, "user_id")
|
||||
if getattr(event, "group_id", None):
|
||||
params["group_id"] = getattr(event, "group_id")
|
||||
params.update(kwargs)
|
||||
|
||||
if "message_type" not in params:
|
||||
if params.get("group_id", None):
|
||||
params["message_type"] = "group"
|
||||
elif params.get("user_id", None):
|
||||
params["message_type"] = "private"
|
||||
else:
|
||||
raise ValueError("Cannot guess message type to reply!")
|
||||
|
||||
if at_sender and params["message_type"] != "private":
|
||||
params["message"] = MessageSegment.at(params["user_id"]) + \
|
||||
MessageSegment.text(" ") + msg
|
||||
else:
|
||||
params["message"] = msg
|
||||
return await self.send_msg(**params)
|
746
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/bot.pyi
Normal file
746
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/bot.pyi
Normal file
@ -0,0 +1,746 @@
|
||||
import asyncio
|
||||
from typing import Any, Dict, List, Union, Optional
|
||||
|
||||
from nonebot.config import Config
|
||||
from nonebot.adapters import Bot as BaseBot
|
||||
from nonebot.drivers import Driver, WebSocket
|
||||
|
||||
from .event import Event
|
||||
from .message import Message, MessageSegment
|
||||
|
||||
|
||||
def get_auth_bearer(access_token: Optional[str] = ...) -> Optional[str]:
|
||||
...
|
||||
|
||||
|
||||
async def _check_reply(bot: "Bot", event: Event):
|
||||
...
|
||||
|
||||
|
||||
def _check_at_me(bot: "Bot", event: Event):
|
||||
...
|
||||
|
||||
|
||||
def _check_nickname(bot: "Bot", event: Event):
|
||||
...
|
||||
|
||||
|
||||
def _handle_api_result(result: Optional[Dict[str, Any]]) -> Any:
|
||||
...
|
||||
|
||||
|
||||
class ResultStore:
|
||||
_seq: int = ...
|
||||
_futures: Dict[int, asyncio.Future] = ...
|
||||
|
||||
@classmethod
|
||||
def get_seq(cls) -> int:
|
||||
...
|
||||
|
||||
@classmethod
|
||||
def add_result(cls, result: Dict[str, Any]):
|
||||
...
|
||||
|
||||
@classmethod
|
||||
async def fetch(cls, seq: int, timeout: Optional[float]) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
|
||||
class Bot(BaseBot):
|
||||
|
||||
def __init__(self,
|
||||
driver: Driver,
|
||||
connection_type: str,
|
||||
config: Config,
|
||||
self_id: str,
|
||||
*,
|
||||
websocket: WebSocket = None):
|
||||
...
|
||||
|
||||
def type(self) -> str:
|
||||
...
|
||||
|
||||
@classmethod
|
||||
async def check_permission(cls, driver: Driver, connection_type: str,
|
||||
headers: dict, body: Optional[dict]) -> str:
|
||||
...
|
||||
|
||||
async def handle_message(self, message: dict):
|
||||
...
|
||||
|
||||
async def call_api(self, api: str, **data) -> Any:
|
||||
...
|
||||
|
||||
async def send(self, event: Event, message: Union[str, Message,
|
||||
MessageSegment],
|
||||
**kwargs) -> Any:
|
||||
...
|
||||
|
||||
async def send_private_msg(self,
|
||||
*,
|
||||
user_id: int,
|
||||
message: Union[str, Message],
|
||||
auto_escape: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
发送私聊消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``user_id``: 对方 QQ 号
|
||||
* ``message``: 要发送的内容
|
||||
* ``auto_escape``: 消息内容是否作为纯文本发送(即不解析 CQ 码),只在 ``message`` 字段是字符串时有效
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def send_group_msg(self,
|
||||
*,
|
||||
group_id: int,
|
||||
message: Union[str, Message],
|
||||
auto_escape: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
发送群消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``message``: 要发送的内容
|
||||
* ``auto_escape``: 消息内容是否作为纯文本发送(即不解析 CQ 码),只在 ``message`` 字段是字符串时有效
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def send_msg(self,
|
||||
*,
|
||||
message_type: Optional[str] = ...,
|
||||
user_id: Optional[int] = ...,
|
||||
group_id: Optional[int] = ...,
|
||||
message: Union[str, Message],
|
||||
auto_escape: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
发送消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``message_type``: 消息类型,支持 ``private``、``group``,分别对应私聊、群组、讨论组,如不传入,则根据传入的 ``*_id`` 参数判断
|
||||
* ``user_id``: 对方 QQ 号(消息类型为 ``private`` 时需要)
|
||||
* ``group_id``: 群号(消息类型为 ``group`` 时需要)
|
||||
* ``message``: 要发送的内容
|
||||
* ``auto_escape``: 消息内容是否作为纯文本发送(即不解析 CQ 码),只在 ``message`` 字段是字符串时有效
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def delete_msg(self,
|
||||
*,
|
||||
message_id: int,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
撤回消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``message_id``: 消息 ID
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_msg(self,
|
||||
*,
|
||||
message_id: int,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``message_id``: 消息 ID
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_forward_msg(self,
|
||||
*,
|
||||
id: int,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取合并转发消息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``id``: 合并转发 ID
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def send_like(self,
|
||||
*,
|
||||
user_id: int,
|
||||
times: int = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
发送好友赞。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``user_id``: 对方 QQ 号
|
||||
* ``times``: 赞的次数,每个好友每天最多 10 次
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_kick(self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
reject_add_request: bool = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组踢人。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: 要踢的 QQ 号
|
||||
* ``reject_add_request``: 拒绝此人的加群请求
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_ban(self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
duration: int = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组单人禁言。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: 要禁言的 QQ 号
|
||||
* ``duration``: 禁言时长,单位秒,``0`` 表示取消禁言
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_anonymous_ban(self,
|
||||
*,
|
||||
group_id: int,
|
||||
anonymous: Optional[Dict[str, Any]] = ...,
|
||||
anonymous_flag: Optional[str] = ...,
|
||||
duration: int = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组匿名用户禁言。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``anonymous``: 可选,要禁言的匿名用户对象(群消息上报的 ``anonymous`` 字段)
|
||||
* ``anonymous_flag``: 可选,要禁言的匿名用户的 flag(需从群消息上报的数据中获得)
|
||||
* ``duration``: 禁言时长,单位秒,无法取消匿名用户禁言
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_whole_ban(self,
|
||||
*,
|
||||
group_id: int,
|
||||
enable: bool = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组全员禁言。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``enable``: 是否禁言
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_admin(self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
enable: bool = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组设置管理员。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: 要设置管理员的 QQ 号
|
||||
* ``enable``: ``True`` 为设置,``False`` 为取消
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_anonymous(self,
|
||||
*,
|
||||
group_id: int,
|
||||
enable: bool = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
群组匿名。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``enable``: 是否允许匿名聊天
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_card(self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
card: str = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
设置群名片(群备注)。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: 要设置的 QQ 号
|
||||
* ``card``: 群名片内容,不填或空字符串表示删除群名片
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_name(self,
|
||||
*,
|
||||
group_id: int,
|
||||
group_name: str,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
设置群名。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``group_name``: 新群名
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_leave(self,
|
||||
*,
|
||||
group_id: int,
|
||||
is_dismiss: bool = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
退出群组。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``is_dismiss``: 是否解散,如果登录号是群主,则仅在此项为 True 时能够解散
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_special_title(self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
special_title: str = ...,
|
||||
duration: int = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
设置群组专属头衔。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: 要设置的 QQ 号
|
||||
* ``special_title``: 专属头衔,不填或空字符串表示删除专属头衔
|
||||
* ``duration``: 专属头衔有效期,单位秒,-1 表示永久,不过此项似乎没有效果,可能是只有某些特殊的时间长度有效,有待测试
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_friend_add_request(self,
|
||||
*,
|
||||
flag: str,
|
||||
approve: bool = ...,
|
||||
remark: str = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
处理加好友请求。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``flag``: 加好友请求的 flag(需从上报的数据中获得)
|
||||
* ``approve``: 是否同意请求
|
||||
* ``remark``: 添加后的好友备注(仅在同意时有效)
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_group_add_request(self,
|
||||
*,
|
||||
flag: str,
|
||||
sub_type: str,
|
||||
approve: bool = ...,
|
||||
reason: str = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
处理加群请求/邀请。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``flag``: 加群请求的 flag(需从上报的数据中获得)
|
||||
* ``sub_type``: ``add`` 或 ``invite``,请求类型(需要和上报消息中的 ``sub_type`` 字段相符)
|
||||
* ``approve``: 是否同意请求/邀请
|
||||
* ``reason``: 拒绝理由(仅在拒绝时有效)
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_login_info(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取登录号信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_stranger_info(self,
|
||||
*,
|
||||
user_id: int,
|
||||
no_cache: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取陌生人信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``user_id``: QQ 号
|
||||
* ``no_cache``: 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_friend_list(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取好友列表。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_group_info(self,
|
||||
*,
|
||||
group_id: int,
|
||||
no_cache: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取群信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``no_cache``: 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_group_list(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取群列表。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_group_member_info(
|
||||
self,
|
||||
*,
|
||||
group_id: int,
|
||||
user_id: int,
|
||||
no_cache: bool = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取群成员信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``user_id``: QQ 号
|
||||
* ``no_cache``: 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_group_member_list(
|
||||
self,
|
||||
*,
|
||||
group_id: int,
|
||||
self_id: Optional[int] = ...) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取群成员列表。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_group_honor_info(self,
|
||||
*,
|
||||
group_id: int,
|
||||
type: str = ...,
|
||||
self_id: Optional[int] = ...
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取群荣誉信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``group_id``: 群号
|
||||
* ``type``: 要获取的群荣誉类型,可传入 ``talkative`` ``performer`` ``legend`` ``strong_newbie`` ``emotion`` 以分别获取单个类型的群荣誉数据,或传入 ``all`` 获取所有数据
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_cookies(self,
|
||||
*,
|
||||
domain: str = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取 Cookies。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``domain``: 需要获取 cookies 的域名
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_csrf_token(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取 CSRF Token。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_credentials(self,
|
||||
*,
|
||||
domain: str = ...,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取 QQ 相关接口凭证。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``domain``: 需要获取 cookies 的域名
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_record(self,
|
||||
*,
|
||||
file: str,
|
||||
out_format: str,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取语音。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``file``: 收到的语音文件名(CQ 码的 ``file`` 参数),如 ``0B38145AA44505000B38145AA4450500.silk``
|
||||
* ``out_format``: 要转换到的格式,目前支持 ``mp3``、``amr``、``wma``、``m4a``、``spx``、``ogg``、``wav``、``flac``
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_image(self,
|
||||
*,
|
||||
file: str,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取图片。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``file``: 收到的图片文件名(CQ 码的 ``file`` 参数),如 ``6B4DE3DFD1BD271E3297859D41C530F5.jpg``
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def can_send_image(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
检查是否可以发送图片。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def can_send_record(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
检查是否可以发送语音。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_status(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取插件运行状态。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def get_version_info(self,
|
||||
*,
|
||||
self_id: Optional[int] = ...) -> Dict[str, Any]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
获取版本信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def set_restart(self,
|
||||
*,
|
||||
delay: int = ...,
|
||||
self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
重启 OneBot 实现。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``delay``: 要延迟的毫秒数,如果默认情况下无法重启,可以尝试设置延迟为 2000 左右
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
||||
|
||||
async def clean_cache(self, *, self_id: Optional[int] = ...) -> None:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
清理数据目录。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``self_id``: 机器人 QQ 号
|
||||
"""
|
||||
...
|
@ -0,0 +1,21 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field, BaseModel
|
||||
|
||||
|
||||
# priority: alias > origin
|
||||
class Config(BaseModel):
|
||||
"""
|
||||
CQHTTP 配置类
|
||||
|
||||
:配置项:
|
||||
|
||||
- ``access_token`` / ``cqhttp_access_token``: CQHTTP 协议授权令牌
|
||||
- ``secret`` / ``cqhttp_secret``: CQHTTP HTTP 上报数据签名口令
|
||||
"""
|
||||
access_token: Optional[str] = Field(default=None,
|
||||
alias="cqhttp_access_token")
|
||||
secret: Optional[str] = Field(default=None, alias="cqhttp_secret")
|
||||
|
||||
class Config:
|
||||
extra = "ignore"
|
568
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/event.py
Normal file
568
packages/nonebot-adapter-cqhttp/nonebot/adapters/cqhttp/event.py
Normal file
@ -0,0 +1,568 @@
|
||||
import inspect
|
||||
from typing_extensions import Literal
|
||||
from typing import Type, List, Optional, TYPE_CHECKING
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pygtrie import StringTrie
|
||||
from nonebot.utils import escape_tag
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.exception import NoLogException
|
||||
from nonebot.adapters import Event as BaseEvent
|
||||
|
||||
from .message import Message
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .bot import Bot
|
||||
|
||||
|
||||
class Event(BaseEvent):
|
||||
"""
|
||||
CQHTTP 协议事件,字段与 CQHTTP 一致。各事件字段参考 `CQHTTP 文档`_
|
||||
|
||||
.. _CQHTTP 文档:
|
||||
https://github.com/howmanybots/onebot/blob/master/README.md
|
||||
"""
|
||||
__event__ = ""
|
||||
time: int
|
||||
self_id: int
|
||||
post_type: Literal["message", "notice", "request", "meta_event"]
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_type(self) -> Literal["message", "notice", "request", "meta_event"]:
|
||||
return self.post_type
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_event_name(self) -> str:
|
||||
return self.post_type
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_event_description(self) -> str:
|
||||
return str(self.dict())
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_message(self) -> Message:
|
||||
raise ValueError("Event has no message!")
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_plaintext(self) -> str:
|
||||
raise ValueError("Event has no message!")
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_user_id(self) -> str:
|
||||
raise ValueError("Event has no message!")
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def get_session_id(self) -> str:
|
||||
raise ValueError("Event has no message!")
|
||||
|
||||
@overrides(BaseEvent)
|
||||
def is_tome(self) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
# Models
|
||||
class Sender(BaseModel):
|
||||
user_id: Optional[int] = None
|
||||
nickname: Optional[str] = None
|
||||
sex: Optional[str] = None
|
||||
age: Optional[int] = None
|
||||
card: Optional[str] = None
|
||||
area: Optional[str] = None
|
||||
level: Optional[str] = None
|
||||
role: Optional[str] = None
|
||||
title: Optional[str] = None
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
|
||||
class Reply(BaseModel):
|
||||
time: int
|
||||
message_type: str
|
||||
message_id: int
|
||||
real_id: int
|
||||
sender: Sender
|
||||
message: Message
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
|
||||
class Anonymous(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
flag: str
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
|
||||
class File(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
size: int
|
||||
busid: int
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
|
||||
class Status(BaseModel):
|
||||
online: bool
|
||||
good: bool
|
||||
|
||||
class Config:
|
||||
extra = "allow"
|
||||
|
||||
|
||||
# Message Events
|
||||
class MessageEvent(Event):
|
||||
"""消息事件"""
|
||||
__event__ = "message"
|
||||
post_type: Literal["message"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
message_type: str
|
||||
message_id: int
|
||||
message: Message
|
||||
raw_message: str
|
||||
font: int
|
||||
sender: Sender
|
||||
to_me: bool = False
|
||||
"""
|
||||
:说明: 消息是否与机器人有关
|
||||
|
||||
:类型: ``bool``
|
||||
"""
|
||||
reply: Optional[Reply] = None
|
||||
"""
|
||||
:说明: 消息中提取的回复消息,内容为 ``get_msg`` API 返回结果
|
||||
|
||||
:类型: ``Optional[Reply]``
|
||||
"""
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_name(self) -> str:
|
||||
sub_type = getattr(self, "sub_type", None)
|
||||
return f"{self.post_type}.{self.message_type}" + (f".{sub_type}"
|
||||
if sub_type else "")
|
||||
|
||||
@overrides(Event)
|
||||
def get_message(self) -> Message:
|
||||
return self.message
|
||||
|
||||
@overrides(Event)
|
||||
def get_plaintext(self) -> str:
|
||||
return self.message.extract_plain_text()
|
||||
|
||||
@overrides(Event)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(Event)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(Event)
|
||||
def is_tome(self) -> bool:
|
||||
return self.to_me
|
||||
|
||||
|
||||
class PrivateMessageEvent(MessageEvent):
|
||||
"""私聊消息"""
|
||||
__event__ = "message.private"
|
||||
message_type: Literal["private"]
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_description(self) -> str:
|
||||
return (f'Message {self.message_id} from {self.user_id} "' + "".join(
|
||||
map(
|
||||
lambda x: escape_tag(str(x))
|
||||
if x.is_text() else f"<le>{escape_tag(str(x))}</le>",
|
||||
self.message)) + '"')
|
||||
|
||||
|
||||
class GroupMessageEvent(MessageEvent):
|
||||
"""群消息"""
|
||||
__event__ = "message.group"
|
||||
message_type: Literal["group"]
|
||||
group_id: int
|
||||
anonymous: Optional[Anonymous] = None
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_description(self) -> str:
|
||||
return (
|
||||
f'Message {self.message_id} from {self.user_id}@[群:{self.group_id}] "'
|
||||
+ "".join(
|
||||
map(
|
||||
lambda x: escape_tag(str(x))
|
||||
if x.is_text() else f"<le>{escape_tag(str(x))}</le>",
|
||||
self.message)) + '"')
|
||||
|
||||
|
||||
# Notice Events
|
||||
class NoticeEvent(Event):
|
||||
"""通知事件"""
|
||||
__event__ = "notice"
|
||||
post_type: Literal["notice"]
|
||||
notice_type: str
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_name(self) -> str:
|
||||
sub_type = getattr(self, "sub_type", None)
|
||||
return f"{self.post_type}.{self.notice_type}" + (f".{sub_type}"
|
||||
if sub_type else "")
|
||||
|
||||
|
||||
class GroupUploadNoticeEvent(NoticeEvent):
|
||||
"""群文件上传事件"""
|
||||
__event__ = "notice.group_upload"
|
||||
notice_type: Literal["group_upload"]
|
||||
user_id: int
|
||||
group_id: int
|
||||
file: File
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class GroupAdminNoticeEvent(NoticeEvent):
|
||||
"""群管理员变动"""
|
||||
__event__ = "notice.group_admin"
|
||||
notice_type: Literal["group_admin"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
group_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class GroupDecreaseNoticeEvent(NoticeEvent):
|
||||
"""群成员减少事件"""
|
||||
__event__ = "notice.group_decrease"
|
||||
notice_type: Literal["group_decrease"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
group_id: int
|
||||
operator_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class GroupIncreaseNoticeEvent(NoticeEvent):
|
||||
"""群成员增加事件"""
|
||||
__event__ = "notice.group_increase"
|
||||
notice_type: Literal["group_increase"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
group_id: int
|
||||
operator_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class GroupBanNoticeEvent(NoticeEvent):
|
||||
"""群禁言事件"""
|
||||
__event__ = "notice.group_ban"
|
||||
notice_type: Literal["group_ban"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
group_id: int
|
||||
operator_id: int
|
||||
duration: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class FriendAddNoticeEvent(NoticeEvent):
|
||||
"""好友添加事件"""
|
||||
__event__ = "notice.friend_add"
|
||||
notice_type: Literal["friend_add"]
|
||||
user_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class GroupRecallNoticeEvent(NoticeEvent):
|
||||
"""群消息撤回事件"""
|
||||
__event__ = "notice.group_recall"
|
||||
notice_type: Literal["group_recall"]
|
||||
user_id: int
|
||||
group_id: int
|
||||
operator_id: int
|
||||
message_id: int
|
||||
|
||||
@overrides(Event)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class FriendRecallNoticeEvent(NoticeEvent):
|
||||
"""好友消息撤回事件"""
|
||||
__event__ = "notice.friend_recall"
|
||||
notice_type: Literal["friend_recall"]
|
||||
user_id: int
|
||||
message_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class NotifyEvent(NoticeEvent):
|
||||
"""提醒事件"""
|
||||
__event__ = "notice.notify"
|
||||
notice_type: Literal["notify"]
|
||||
sub_type: str
|
||||
user_id: int
|
||||
group_id: int
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(NoticeEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
|
||||
class PokeNotifyEvent(NotifyEvent):
|
||||
"""戳一戳提醒事件"""
|
||||
__event__ = "notice.notify.poke"
|
||||
sub_type: Literal["poke"]
|
||||
target_id: int
|
||||
group_id: Optional[int] = None
|
||||
|
||||
@overrides(Event)
|
||||
def is_tome(self) -> bool:
|
||||
return self.target_id == self.self_id
|
||||
|
||||
|
||||
class LuckyKingNotifyEvent(NotifyEvent):
|
||||
"""群红包运气王提醒事件"""
|
||||
__event__ = "notice.notify.lucky_king"
|
||||
sub_type: Literal["lucky_king"]
|
||||
target_id: int
|
||||
|
||||
@overrides(Event)
|
||||
def is_tome(self) -> bool:
|
||||
return self.target_id == self.self_id
|
||||
|
||||
@overrides(NotifyEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.target_id)
|
||||
|
||||
@overrides(NotifyEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.target_id)
|
||||
|
||||
|
||||
class HonorNotifyEvent(NotifyEvent):
|
||||
"""群荣誉变更提醒事件"""
|
||||
__event__ = "notice.notify.honor"
|
||||
sub_type: Literal["honor"]
|
||||
honor_type: str
|
||||
|
||||
@overrides(Event)
|
||||
def is_tome(self) -> bool:
|
||||
return self.user_id == self.self_id
|
||||
|
||||
|
||||
# Request Events
|
||||
class RequestEvent(Event):
|
||||
"""请求事件"""
|
||||
__event__ = "request"
|
||||
post_type: Literal["request"]
|
||||
request_type: str
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_name(self) -> str:
|
||||
sub_type = getattr(self, "sub_type", None)
|
||||
return f"{self.post_type}.{self.request_type}" + (f".{sub_type}"
|
||||
if sub_type else "")
|
||||
|
||||
|
||||
class FriendRequestEvent(RequestEvent):
|
||||
"""加好友请求事件"""
|
||||
__event__ = "request.friend"
|
||||
request_type: Literal["friend"]
|
||||
user_id: int
|
||||
comment: str
|
||||
flag: str
|
||||
|
||||
@overrides(RequestEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(RequestEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
async def approve(self, bot: "Bot", remark: str = ""):
|
||||
return await bot.set_friend_add_request(flag=self.flag,
|
||||
approve=True,
|
||||
remark=remark)
|
||||
|
||||
async def reject(self, bot: "Bot"):
|
||||
return await bot.set_friend_add_request(flag=self.flag, approve=False)
|
||||
|
||||
|
||||
class GroupRequestEvent(RequestEvent):
|
||||
"""加群请求/邀请事件"""
|
||||
__event__ = "request.group"
|
||||
request_type: Literal["group"]
|
||||
sub_type: str
|
||||
group_id: int
|
||||
user_id: int
|
||||
comment: str
|
||||
flag: str
|
||||
|
||||
@overrides(RequestEvent)
|
||||
def get_user_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
@overrides(RequestEvent)
|
||||
def get_session_id(self) -> str:
|
||||
return str(self.user_id)
|
||||
|
||||
async def approve(self, bot: "Bot"):
|
||||
return await bot.set_group_add_request(flag=self.flag,
|
||||
sub_type=self.sub_type,
|
||||
approve=True)
|
||||
|
||||
async def reject(self, bot: "Bot", reason: str = ""):
|
||||
return await bot.set_group_add_request(flag=self.flag,
|
||||
sub_type=self.sub_type,
|
||||
approve=False,
|
||||
reason=reason)
|
||||
|
||||
|
||||
# Meta Events
|
||||
class MetaEvent(Event):
|
||||
"""元事件"""
|
||||
__event__ = "meta_event"
|
||||
post_type: Literal["meta_event"]
|
||||
meta_event_type: str
|
||||
|
||||
@overrides(Event)
|
||||
def get_event_name(self) -> str:
|
||||
sub_type = getattr(self, "sub_type", None)
|
||||
return f"{self.post_type}.{self.meta_event_type}" + (f".{sub_type}" if
|
||||
sub_type else "")
|
||||
|
||||
@overrides(Event)
|
||||
def get_log_string(self) -> str:
|
||||
raise NoLogException
|
||||
|
||||
|
||||
class LifecycleMetaEvent(MetaEvent):
|
||||
"""生命周期元事件"""
|
||||
__event__ = "meta_event.lifecycle"
|
||||
meta_event_type: Literal["lifecycle"]
|
||||
sub_type: str
|
||||
|
||||
|
||||
class HeartbeatMetaEvent(MetaEvent):
|
||||
"""心跳元事件"""
|
||||
__event__ = "meta_event.heartbeat"
|
||||
meta_event_type: Literal["heartbeat"]
|
||||
status: Status
|
||||
interval: int
|
||||
|
||||
|
||||
_t = StringTrie(separator=".")
|
||||
|
||||
# define `model` first to avoid globals changing while `for`
|
||||
model = None
|
||||
for model in globals().values():
|
||||
if not inspect.isclass(model) or not issubclass(model, Event):
|
||||
continue
|
||||
_t["." + model.__event__] = model
|
||||
|
||||
|
||||
def get_event_model(event_name) -> List[Type[Event]]:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
根据事件名获取对应 ``Event Model`` 及 ``FallBack Event Model`` 列表
|
||||
|
||||
:返回:
|
||||
|
||||
- ``List[Type[Event]]``
|
||||
"""
|
||||
return [model.value for model in _t.prefixes("." + event_name)][::-1]
|
||||
|
||||
|
||||
__all__ = [
|
||||
"Event", "MessageEvent", "PrivateMessageEvent", "GroupMessageEvent",
|
||||
"NoticeEvent", "GroupUploadNoticeEvent", "GroupAdminNoticeEvent",
|
||||
"GroupDecreaseNoticeEvent", "GroupIncreaseNoticeEvent",
|
||||
"GroupBanNoticeEvent", "FriendAddNoticeEvent", "GroupRecallNoticeEvent",
|
||||
"FriendRecallNoticeEvent", "NotifyEvent", "PokeNotifyEvent",
|
||||
"LuckyKingNotifyEvent", "HonorNotifyEvent", "RequestEvent",
|
||||
"FriendRequestEvent", "GroupRequestEvent", "MetaEvent",
|
||||
"LifecycleMetaEvent", "HeartbeatMetaEvent", "get_event_model"
|
||||
]
|
@ -0,0 +1,61 @@
|
||||
from typing import Optional
|
||||
|
||||
from nonebot.exception import (AdapterException, ActionFailed as
|
||||
BaseActionFailed, NetworkError as
|
||||
BaseNetworkError, ApiNotAvailable as
|
||||
BaseApiNotAvailable)
|
||||
|
||||
|
||||
class CQHTTPAdapterException(AdapterException):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__("cqhttp")
|
||||
|
||||
|
||||
class ActionFailed(BaseActionFailed, CQHTTPAdapterException):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
API 请求返回错误信息。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``retcode: Optional[int]``: 错误码
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__()
|
||||
self.info = kwargs
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ActionFailed " + ", ".join(
|
||||
f"{k}={v}" for k, v in self.info.items()) + ">"
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
class NetworkError(BaseNetworkError, CQHTTPAdapterException):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
网络错误。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``retcode: Optional[int]``: 错误码
|
||||
"""
|
||||
|
||||
def __init__(self, msg: Optional[str] = None):
|
||||
super().__init__()
|
||||
self.msg = msg
|
||||
|
||||
def __repr__(self):
|
||||
return f"<NetWorkError message={self.msg}>"
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
|
||||
class ApiNotAvailable(BaseApiNotAvailable, CQHTTPAdapterException):
|
||||
pass
|
@ -0,0 +1,261 @@
|
||||
import re
|
||||
from functools import reduce
|
||||
from typing import Any, Dict, Union, Tuple, Mapping, Iterable, Optional
|
||||
|
||||
from nonebot.typing import overrides
|
||||
from nonebot.adapters import Message as BaseMessage, MessageSegment as BaseMessageSegment
|
||||
|
||||
from .utils import log, escape, unescape, _b2s
|
||||
|
||||
|
||||
class MessageSegment(BaseMessageSegment):
|
||||
"""
|
||||
CQHTTP 协议 MessageSegment 适配。具体方法参考协议消息段类型或源码。
|
||||
"""
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def __init__(self, type: str, data: Dict[str, Any]) -> None:
|
||||
super().__init__(type=type, data=data)
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def __str__(self) -> str:
|
||||
type_ = self.type
|
||||
data = self.data.copy()
|
||||
|
||||
# process special types
|
||||
if type_ == "text":
|
||||
return escape(
|
||||
data.get("text", ""), # type: ignore
|
||||
escape_comma=False)
|
||||
|
||||
params = ",".join(
|
||||
[f"{k}={escape(str(v))}" for k, v in data.items() if v is not None])
|
||||
return f"[CQ:{type_}{',' if params else ''}{params}]"
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def __add__(self, other) -> "Message":
|
||||
return Message(self) + other
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def __radd__(self, other) -> "Message":
|
||||
return Message(other) + self
|
||||
|
||||
@overrides(BaseMessageSegment)
|
||||
def is_text(self) -> bool:
|
||||
return self.type == "text"
|
||||
|
||||
@staticmethod
|
||||
def anonymous(ignore_failure: Optional[bool] = None) -> "MessageSegment":
|
||||
return MessageSegment("anonymous", {"ignore": _b2s(ignore_failure)})
|
||||
|
||||
@staticmethod
|
||||
def at(user_id: Union[int, str]) -> "MessageSegment":
|
||||
return MessageSegment("at", {"qq": str(user_id)})
|
||||
|
||||
@staticmethod
|
||||
def contact(type_: str, id: int) -> "MessageSegment":
|
||||
return MessageSegment("contact", {"type": type_, "id": str(id)})
|
||||
|
||||
@staticmethod
|
||||
def contact_group(group_id: int) -> "MessageSegment":
|
||||
return MessageSegment("contact", {"type": "group", "id": str(group_id)})
|
||||
|
||||
@staticmethod
|
||||
def contact_user(user_id: int) -> "MessageSegment":
|
||||
return MessageSegment("contact", {"type": "qq", "id": str(user_id)})
|
||||
|
||||
@staticmethod
|
||||
def dice() -> "MessageSegment":
|
||||
return MessageSegment("dice", {})
|
||||
|
||||
@staticmethod
|
||||
def face(id_: int) -> "MessageSegment":
|
||||
return MessageSegment("face", {"id": str(id_)})
|
||||
|
||||
@staticmethod
|
||||
def forward(id_: str) -> "MessageSegment":
|
||||
log("WARNING", "Forward Message only can be received!")
|
||||
return MessageSegment("forward", {"id": id_})
|
||||
|
||||
@staticmethod
|
||||
def image(file: str,
|
||||
type_: Optional[str] = None,
|
||||
cache: bool = True,
|
||||
proxy: bool = True,
|
||||
timeout: Optional[int] = None) -> "MessageSegment":
|
||||
return MessageSegment(
|
||||
"image", {
|
||||
"file": file,
|
||||
"type": type_,
|
||||
"cache": cache,
|
||||
"proxy": proxy,
|
||||
"timeout": timeout
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def json(data: str) -> "MessageSegment":
|
||||
return MessageSegment("json", {"data": data})
|
||||
|
||||
@staticmethod
|
||||
def location(latitude: float,
|
||||
longitude: float,
|
||||
title: Optional[str] = None,
|
||||
content: Optional[str] = None) -> "MessageSegment":
|
||||
return MessageSegment(
|
||||
"location", {
|
||||
"lat": str(latitude),
|
||||
"lon": str(longitude),
|
||||
"title": title,
|
||||
"content": content
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def music(type_: str, id_: int) -> "MessageSegment":
|
||||
return MessageSegment("music", {"type": type_, "id": id_})
|
||||
|
||||
@staticmethod
|
||||
def music_custom(url: str,
|
||||
audio: str,
|
||||
title: str,
|
||||
content: Optional[str] = None,
|
||||
img_url: Optional[str] = None) -> "MessageSegment":
|
||||
return MessageSegment(
|
||||
"music", {
|
||||
"type": "custom",
|
||||
"url": url,
|
||||
"audio": audio,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"image": img_url
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def node(id_: int) -> "MessageSegment":
|
||||
return MessageSegment("node", {"id": str(id_)})
|
||||
|
||||
@staticmethod
|
||||
def node_custom(user_id: int, nickname: str,
|
||||
content: Union[str, "Message"]) -> "MessageSegment":
|
||||
return MessageSegment("node", {
|
||||
"user_id": str(user_id),
|
||||
"nickname": nickname,
|
||||
"content": content
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def poke(type_: str, id_: str) -> "MessageSegment":
|
||||
return MessageSegment("poke", {"type": type_, "id": id_})
|
||||
|
||||
@staticmethod
|
||||
def record(file: str,
|
||||
magic: Optional[bool] = None,
|
||||
cache: Optional[bool] = None,
|
||||
proxy: Optional[bool] = None,
|
||||
timeout: Optional[int] = None) -> "MessageSegment":
|
||||
return MessageSegment(
|
||||
"record", {
|
||||
"file": file,
|
||||
"magic": _b2s(magic),
|
||||
"cache": cache,
|
||||
"proxy": proxy,
|
||||
"timeout": timeout
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def reply(id_: int) -> "MessageSegment":
|
||||
return MessageSegment("reply", {"id": str(id_)})
|
||||
|
||||
@staticmethod
|
||||
def rps() -> "MessageSegment":
|
||||
return MessageSegment("rps", {})
|
||||
|
||||
@staticmethod
|
||||
def shake() -> "MessageSegment":
|
||||
return MessageSegment("shake", {})
|
||||
|
||||
@staticmethod
|
||||
def share(url: str = "",
|
||||
title: str = "",
|
||||
content: Optional[str] = None,
|
||||
image: Optional[str] = None) -> "MessageSegment":
|
||||
return MessageSegment("share", {
|
||||
"url": url,
|
||||
"title": title,
|
||||
"content": content,
|
||||
"image": image
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def text(text: str) -> "MessageSegment":
|
||||
return MessageSegment("text", {"text": text})
|
||||
|
||||
@staticmethod
|
||||
def video(file: str,
|
||||
cache: Optional[bool] = None,
|
||||
proxy: Optional[bool] = None,
|
||||
timeout: Optional[int] = None) -> "MessageSegment":
|
||||
return MessageSegment("video", {
|
||||
"file": file,
|
||||
"cache": cache,
|
||||
"proxy": proxy,
|
||||
"timeout": timeout
|
||||
})
|
||||
|
||||
@staticmethod
|
||||
def xml(data: str) -> "MessageSegment":
|
||||
return MessageSegment("xml", {"data": data})
|
||||
|
||||
|
||||
class Message(BaseMessage):
|
||||
"""
|
||||
CQHTTP 协议 Message 适配。
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
@overrides(BaseMessage)
|
||||
def _construct(
|
||||
msg: Union[str, Mapping,
|
||||
Iterable[Mapping]]) -> Iterable[MessageSegment]:
|
||||
if isinstance(msg, Mapping):
|
||||
yield MessageSegment(msg["type"], msg.get("data") or {})
|
||||
return
|
||||
elif isinstance(msg, Iterable) and not isinstance(msg, str):
|
||||
for seg in msg:
|
||||
yield MessageSegment(seg["type"], seg.get("data") or {})
|
||||
return
|
||||
elif isinstance(msg, str):
|
||||
|
||||
def _iter_message(msg: str) -> Iterable[Tuple[str, str]]:
|
||||
text_begin = 0
|
||||
for cqcode in re.finditer(
|
||||
r"\[CQ:(?P<type>[a-zA-Z0-9-_.]+)"
|
||||
r"(?P<params>"
|
||||
r"(?:,[a-zA-Z0-9-_.]+=[^,\]]+)*"
|
||||
r"),?\]", msg):
|
||||
yield "text", msg[text_begin:cqcode.pos + cqcode.start()]
|
||||
text_begin = cqcode.pos + cqcode.end()
|
||||
yield cqcode.group("type"), cqcode.group("params").lstrip(
|
||||
",")
|
||||
yield "text", msg[text_begin:]
|
||||
|
||||
for type_, data in _iter_message(msg):
|
||||
if type_ == "text":
|
||||
if data:
|
||||
# only yield non-empty text segment
|
||||
yield MessageSegment(type_, {"text": unescape(data)})
|
||||
else:
|
||||
data = {
|
||||
k: unescape(v) for k, v in map(
|
||||
lambda x: x.split("=", maxsplit=1),
|
||||
filter(lambda x: x, (
|
||||
x.lstrip() for x in data.split(","))))
|
||||
}
|
||||
yield MessageSegment(type_, data)
|
||||
|
||||
def extract_plain_text(self) -> str:
|
||||
|
||||
def _concat(x: str, y: MessageSegment) -> str:
|
||||
return f"{x} {y.data['text']}" if y.is_text() else x
|
||||
|
||||
plain_text = reduce(_concat, self, "")
|
||||
return plain_text[1:] if plain_text else plain_text
|
@ -0,0 +1,86 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from nonebot.permission import Permission
|
||||
|
||||
from .event import PrivateMessageEvent, GroupMessageEvent
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from nonebot.adapters import Bot, Event
|
||||
|
||||
|
||||
async def _private(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, PrivateMessageEvent)
|
||||
|
||||
|
||||
async def _private_friend(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, PrivateMessageEvent) and event.sub_type == "friend"
|
||||
|
||||
|
||||
async def _private_group(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, PrivateMessageEvent) and event.sub_type == "group"
|
||||
|
||||
|
||||
async def _private_other(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, PrivateMessageEvent) and event.sub_type == "other"
|
||||
|
||||
|
||||
PRIVATE = Permission(_private)
|
||||
"""
|
||||
- **说明**: 匹配任意私聊消息类型事件
|
||||
"""
|
||||
PRIVATE_FRIEND = Permission(_private_friend)
|
||||
"""
|
||||
- **说明**: 匹配任意好友私聊消息类型事件
|
||||
"""
|
||||
PRIVATE_GROUP = Permission(_private_group)
|
||||
"""
|
||||
- **说明**: 匹配任意群临时私聊消息类型事件
|
||||
"""
|
||||
PRIVATE_OTHER = Permission(_private_other)
|
||||
"""
|
||||
- **说明**: 匹配任意其他私聊消息类型事件
|
||||
"""
|
||||
|
||||
|
||||
async def _group(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, GroupMessageEvent)
|
||||
|
||||
|
||||
async def _group_member(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event,
|
||||
GroupMessageEvent) and event.sender.role == "member"
|
||||
|
||||
|
||||
async def _group_admin(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, GroupMessageEvent) and event.sender.role == "admin"
|
||||
|
||||
|
||||
async def _group_owner(bot: "Bot", event: "Event") -> bool:
|
||||
return isinstance(event, GroupMessageEvent) and event.sender.role == "owner"
|
||||
|
||||
|
||||
GROUP = Permission(_group)
|
||||
"""
|
||||
- **说明**: 匹配任意群聊消息类型事件
|
||||
"""
|
||||
GROUP_MEMBER = Permission(_group_member)
|
||||
"""
|
||||
- **说明**: 匹配任意群员群聊消息类型事件
|
||||
|
||||
\:\:\:warning 警告
|
||||
该权限通过 event.sender 进行判断且不包含管理员以及群主!
|
||||
\:\:\:
|
||||
"""
|
||||
GROUP_ADMIN = Permission(_group_admin)
|
||||
"""
|
||||
- **说明**: 匹配任意群管理员群聊消息类型事件
|
||||
"""
|
||||
GROUP_OWNER = Permission(_group_owner)
|
||||
"""
|
||||
- **说明**: 匹配任意群主群聊消息类型事件
|
||||
"""
|
||||
|
||||
__all__ = [
|
||||
"PRIVATE", "PRIVATE_FRIEND", "PRIVATE_GROUP", "PRIVATE_OTHER", "GROUP",
|
||||
"GROUP_MEMBER", "GROUP_ADMIN", "GROUP_OWNER"
|
||||
]
|
@ -0,0 +1,45 @@
|
||||
from typing import Optional
|
||||
|
||||
from nonebot.utils import logger_wrapper
|
||||
|
||||
log = logger_wrapper("CQHTTP")
|
||||
|
||||
|
||||
def escape(s: str, *, escape_comma: bool = True) -> str:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
对字符串进行 CQ 码转义。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``s: str``: 需要转义的字符串
|
||||
* ``escape_comma: bool``: 是否转义逗号(``,``)。
|
||||
"""
|
||||
s = s.replace("&", "&") \
|
||||
.replace("[", "[") \
|
||||
.replace("]", "]")
|
||||
if escape_comma:
|
||||
s = s.replace(",", ",")
|
||||
return s
|
||||
|
||||
|
||||
def unescape(s: str) -> str:
|
||||
"""
|
||||
:说明:
|
||||
|
||||
对字符串进行 CQ 码去转义。
|
||||
|
||||
:参数:
|
||||
|
||||
* ``s: str``: 需要转义的字符串
|
||||
"""
|
||||
return s.replace(",", ",") \
|
||||
.replace("[", "[") \
|
||||
.replace("]", "]") \
|
||||
.replace("&", "&")
|
||||
|
||||
|
||||
def _b2s(b: Optional[bool]) -> Optional[str]:
|
||||
"""转换布尔值为字符串。"""
|
||||
return b if b is None else str(b).lower()
|
524
packages/nonebot-adapter-cqhttp/poetry.lock
generated
Normal file
524
packages/nonebot-adapter-cqhttp/poetry.lock
generated
Normal file
@ -0,0 +1,524 @@
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2020.12.5"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "7.1.2"
|
||||
description = "Composable command line interface toolkit"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.4"
|
||||
description = "Cross-platform colored terminal text."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "fastapi"
|
||||
version = "0.63.0"
|
||||
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
pydantic = ">=1.0.0,<2.0.0"
|
||||
starlette = "0.13.6"
|
||||
|
||||
[package.extras]
|
||||
all = ["requests (>=2.24.0,<3.0.0)", "aiofiles (>=0.5.0,<0.6.0)", "jinja2 (>=2.11.2,<3.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "itsdangerous (>=1.1.0,<2.0.0)", "pyyaml (>=5.3.1,<6.0.0)", "graphene (>=2.1.8,<3.0.0)", "ujson (>=3.0.0,<4.0.0)", "orjson (>=3.2.1,<4.0.0)", "email_validator (>=1.1.1,<2.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)"]
|
||||
dev = ["python-jose[cryptography] (>=3.1.0,<4.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.14.0)", "graphene (>=2.1.8,<3.0.0)"]
|
||||
doc = ["mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=6.1.4,<7.0.0)", "markdown-include (>=0.5.1,<0.6.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.2.0)", "typer-cli (>=0.0.9,<0.0.10)", "pyyaml (>=5.3.1,<6.0.0)"]
|
||||
test = ["pytest (==5.4.3)", "pytest-cov (==2.10.0)", "pytest-asyncio (>=0.14.0,<0.15.0)", "mypy (==0.790)", "flake8 (>=3.8.3,<4.0.0)", "black (==20.8b1)", "isort (>=5.0.6,<6.0.0)", "requests (>=2.24.0,<3.0.0)", "httpx (>=0.14.0,<0.15.0)", "email_validator (>=1.1.1,<2.0.0)", "sqlalchemy (>=1.3.18,<2.0.0)", "peewee (>=3.13.3,<4.0.0)", "databases[sqlite] (>=0.3.2,<0.4.0)", "orjson (>=3.2.1,<4.0.0)", "async_exit_stack (>=1.0.1,<2.0.0)", "async_generator (>=1.10,<2.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "aiofiles (>=0.5.0,<0.6.0)", "flask (>=1.1.2,<2.0.0)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
version = "0.9.0"
|
||||
description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "httpcore"
|
||||
version = "0.12.3"
|
||||
description = "A minimal low-level HTTP client."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
h11 = "<1.0.0"
|
||||
sniffio = ">=1.0.0,<2.0.0"
|
||||
|
||||
[package.extras]
|
||||
http2 = ["h2 (>=3,<5)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "httptools"
|
||||
version = "0.1.1"
|
||||
description = "A collection of framework independent HTTP protocol utils."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.extras]
|
||||
test = ["Cython (==0.29.14)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "httpx"
|
||||
version = "0.16.1"
|
||||
description = "The next generation HTTP client."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
certifi = "*"
|
||||
httpcore = ">=0.12.0,<0.13.0"
|
||||
rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]}
|
||||
sniffio = "*"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotlipy (>=0.7.0,<0.8.0)"]
|
||||
http2 = ["h2 (>=3.0.0,<4.0.0)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.1"
|
||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.4"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "loguru"
|
||||
version = "0.5.3"
|
||||
description = "Python logging made (stupidly) simple"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""}
|
||||
win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""}
|
||||
|
||||
[package.extras]
|
||||
dev = ["codecov (>=2.0.15)", "colorama (>=0.3.4)", "flake8 (>=3.7.7)", "tox (>=3.9.0)", "tox-travis (>=0.12)", "pytest (>=4.6.2)", "pytest-cov (>=2.7.1)", "Sphinx (>=2.2.1)", "sphinx-autobuild (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "black (>=19.10b0)", "isort (>=5.1.1)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "nonebot2"
|
||||
version = "2.0.0a11"
|
||||
description = "An asynchronous python bot framework."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "^3.7"
|
||||
develop = true
|
||||
|
||||
[package.dependencies]
|
||||
fastapi = "^0.63.0"
|
||||
httpx = "^0.16.1"
|
||||
loguru = "^0.5.1"
|
||||
pydantic = {version = "^1.7.3", extras = ["dotenv", "typing_extensions"]}
|
||||
pygtrie = "^2.4.1"
|
||||
uvicorn = "^0.11.5"
|
||||
websockets = "^8.1"
|
||||
|
||||
[package.extras]
|
||||
quart = ["Quart (>=0.14.1,<0.15.0)"]
|
||||
all = ["Quart (>=0.14.1,<0.15.0)"]
|
||||
|
||||
[package.source]
|
||||
type = "directory"
|
||||
url = "../.."
|
||||
|
||||
[[package]]
|
||||
name = "pydantic"
|
||||
version = "1.7.3"
|
||||
description = "Data validation and settings management using python 3.6 type hinting"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
python-dotenv = {version = ">=0.10.4", optional = true, markers = "extra == \"dotenv\""}
|
||||
typing-extensions = {version = ">=3.7.2", optional = true, markers = "extra == \"typing_extensions\""}
|
||||
|
||||
[package.extras]
|
||||
dotenv = ["python-dotenv (>=0.10.4)"]
|
||||
email = ["email-validator (>=1.0.3)"]
|
||||
typing_extensions = ["typing-extensions (>=3.7.2)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "pygtrie"
|
||||
version = "2.4.2"
|
||||
description = "A pure Python trie data structure implementation."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "python-dotenv"
|
||||
version = "0.15.0"
|
||||
description = "Add .env support to your django/flask apps in development and deployments"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.extras]
|
||||
cli = ["click (>=5.0)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "rfc3986"
|
||||
version = "1.4.0"
|
||||
description = "Validating URI References per RFC 3986"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
idna = {version = "*", optional = true, markers = "extra == \"idna2008\""}
|
||||
|
||||
[package.extras]
|
||||
idna2008 = ["idna"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "sniffio"
|
||||
version = "1.2.0"
|
||||
description = "Sniff out which async library your code is running under"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "starlette"
|
||||
version = "0.13.6"
|
||||
description = "The little ASGI library that shines."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.extras]
|
||||
full = ["aiofiles", "graphene", "itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "ujson"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "typing-extensions"
|
||||
version = "3.7.4.3"
|
||||
description = "Backported and Experimental Type Hints for Python 3.5+"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "uvicorn"
|
||||
version = "0.11.8"
|
||||
description = "The lightning-fast ASGI server."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=7.0.0,<8.0.0"
|
||||
h11 = ">=0.8,<0.10"
|
||||
httptools = {version = ">=0.1.0,<0.2.0", markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\""}
|
||||
uvloop = {version = ">=0.14.0", markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\""}
|
||||
websockets = ">=8.0.0,<9.0.0"
|
||||
|
||||
[package.extras]
|
||||
watchgodreload = ["watchgod (>=0.6,<0.7)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "uvloop"
|
||||
version = "0.15.0"
|
||||
description = "Fast implementation of asyncio event loop on top of libuv"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.extras]
|
||||
dev = ["Cython (>=0.29.20,<0.30.0)", "pytest (>=3.6.0)", "Sphinx (>=1.7.3,<1.8.0)", "sphinxcontrib-asyncio (>=0.2.0,<0.3.0)", "sphinx_rtd_theme (>=0.2.4,<0.3.0)", "aiohttp", "flake8 (>=3.8.4,<3.9.0)", "psutil", "pycodestyle (>=2.6.0,<2.7.0)", "pyOpenSSL (>=19.0.0,<19.1.0)", "mypy (>=0.800)"]
|
||||
docs = ["Sphinx (>=1.7.3,<1.8.0)", "sphinxcontrib-asyncio (>=0.2.0,<0.3.0)", "sphinx_rtd_theme (>=0.2.4,<0.3.0)"]
|
||||
test = ["aiohttp", "flake8 (>=3.8.4,<3.9.0)", "psutil", "pycodestyle (>=2.6.0,<2.7.0)", "pyOpenSSL (>=19.0.0,<19.1.0)", "mypy (>=0.800)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "websockets"
|
||||
version = "8.1"
|
||||
description = "An implementation of the WebSocket Protocol (RFC 6455 & 7692)"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6.1"
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[[package]]
|
||||
name = "win32-setctime"
|
||||
version = "1.0.3"
|
||||
description = "A small Python utility to set file creation time on Windows"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[package.extras]
|
||||
dev = ["pytest (>=4.6.2)", "black (>=19.3b0)"]
|
||||
|
||||
[package.source]
|
||||
type = "legacy"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple"
|
||||
reference = "aliyun"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "43729f1b5c2a4a46f74bc173731cb24140330429947f4babbfd40041fa38ef22"
|
||||
|
||||
[metadata.files]
|
||||
certifi = [
|
||||
{file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"},
|
||||
{file = "certifi-2020.12.5.tar.gz", hash = "sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c"},
|
||||
]
|
||||
click = [
|
||||
{file = "click-7.1.2-py2.py3-none-any.whl", hash = "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"},
|
||||
{file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"},
|
||||
]
|
||||
colorama = [
|
||||
{file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"},
|
||||
{file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"},
|
||||
]
|
||||
fastapi = [
|
||||
{file = "fastapi-0.63.0-py3-none-any.whl", hash = "sha256:98d8ea9591d8512fdadf255d2a8fa56515cdd8624dca4af369da73727409508e"},
|
||||
{file = "fastapi-0.63.0.tar.gz", hash = "sha256:63c4592f5ef3edf30afa9a44fa7c6b7ccb20e0d3f68cd9eba07b44d552058dcb"},
|
||||
]
|
||||
h11 = [
|
||||
{file = "h11-0.9.0-py2.py3-none-any.whl", hash = "sha256:4bc6d6a1238b7615b266ada57e0618568066f57dd6fa967d1290ec9309b2f2f1"},
|
||||
{file = "h11-0.9.0.tar.gz", hash = "sha256:33d4bca7be0fa039f4e84d50ab00531047e53d6ee8ffbc83501ea602c169cae1"},
|
||||
]
|
||||
httpcore = [
|
||||
{file = "httpcore-0.12.3-py3-none-any.whl", hash = "sha256:93e822cd16c32016b414b789aeff4e855d0ccbfc51df563ee34d4dbadbb3bcdc"},
|
||||
{file = "httpcore-0.12.3.tar.gz", hash = "sha256:37ae835fb370049b2030c3290e12ed298bf1473c41bb72ca4aa78681eba9b7c9"},
|
||||
]
|
||||
httptools = [
|
||||
{file = "httptools-0.1.1-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:a2719e1d7a84bb131c4f1e0cb79705034b48de6ae486eb5297a139d6a3296dce"},
|
||||
{file = "httptools-0.1.1-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:fa3cd71e31436911a44620473e873a256851e1f53dee56669dae403ba41756a4"},
|
||||
{file = "httptools-0.1.1-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:86c6acd66765a934e8730bf0e9dfaac6fdcf2a4334212bd4a0a1c78f16475ca6"},
|
||||
{file = "httptools-0.1.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:bc3114b9edbca5a1eb7ae7db698c669eb53eb8afbbebdde116c174925260849c"},
|
||||
{file = "httptools-0.1.1-cp36-cp36m-win_amd64.whl", hash = "sha256:ac0aa11e99454b6a66989aa2d44bca41d4e0f968e395a0a8f164b401fefe359a"},
|
||||
{file = "httptools-0.1.1-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:96da81e1992be8ac2fd5597bf0283d832287e20cb3cfde8996d2b00356d4e17f"},
|
||||
{file = "httptools-0.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:56b6393c6ac7abe632f2294da53f30d279130a92e8ae39d8d14ee2e1b05ad1f2"},
|
||||
{file = "httptools-0.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:96eb359252aeed57ea5c7b3d79839aaa0382c9d3149f7d24dd7172b1bcecb009"},
|
||||
{file = "httptools-0.1.1-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:fea04e126014169384dee76a153d4573d90d0cbd1d12185da089f73c78390437"},
|
||||
{file = "httptools-0.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:3592e854424ec94bd17dc3e0c96a64e459ec4147e6d53c0a42d0ebcef9cb9c5d"},
|
||||
{file = "httptools-0.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:0a4b1b2012b28e68306575ad14ad5e9120b34fccd02a81eb08838d7e3bbb48be"},
|
||||
{file = "httptools-0.1.1.tar.gz", hash = "sha256:41b573cf33f64a8f8f3400d0a7faf48e1888582b6f6e02b82b9bd4f0bf7497ce"},
|
||||
]
|
||||
httpx = [
|
||||
{file = "httpx-0.16.1-py3-none-any.whl", hash = "sha256:9cffb8ba31fac6536f2c8cde30df859013f59e4bcc5b8d43901cb3654a8e0a5b"},
|
||||
{file = "httpx-0.16.1.tar.gz", hash = "sha256:126424c279c842738805974687e0518a94c7ae8d140cd65b9c4f77ac46ffa537"},
|
||||
]
|
||||
idna = [
|
||||
{file = "idna-3.1-py3-none-any.whl", hash = "sha256:5205d03e7bcbb919cc9c19885f9920d622ca52448306f2377daede5cf3faac16"},
|
||||
{file = "idna-3.1.tar.gz", hash = "sha256:c5b02147e01ea9920e6b0a3f1f7bb833612d507592c837a6c49552768f4054e1"},
|
||||
]
|
||||
loguru = [
|
||||
{file = "loguru-0.5.3-py3-none-any.whl", hash = "sha256:f8087ac396b5ee5f67c963b495d615ebbceac2796379599820e324419d53667c"},
|
||||
{file = "loguru-0.5.3.tar.gz", hash = "sha256:b28e72ac7a98be3d28ad28570299a393dfcd32e5e3f6a353dec94675767b6319"},
|
||||
]
|
||||
nonebot2 = []
|
||||
pydantic = [
|
||||
{file = "pydantic-1.7.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c59ea046aea25be14dc22d69c97bee629e6d48d2b2ecb724d7fe8806bf5f61cd"},
|
||||
{file = "pydantic-1.7.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:a4143c8d0c456a093387b96e0f5ee941a950992904d88bc816b4f0e72c9a0009"},
|
||||
{file = "pydantic-1.7.3-cp36-cp36m-manylinux2014_i686.whl", hash = "sha256:d8df4b9090b595511906fa48deda47af04e7d092318bfb291f4d45dfb6bb2127"},
|
||||
{file = "pydantic-1.7.3-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:514b473d264671a5c672dfb28bdfe1bf1afd390f6b206aa2ec9fed7fc592c48e"},
|
||||
{file = "pydantic-1.7.3-cp36-cp36m-win_amd64.whl", hash = "sha256:dba5c1f0a3aeea5083e75db9660935da90216f8a81b6d68e67f54e135ed5eb23"},
|
||||
{file = "pydantic-1.7.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:59e45f3b694b05a69032a0d603c32d453a23f0de80844fb14d55ab0c6c78ff2f"},
|
||||
{file = "pydantic-1.7.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:5b24e8a572e4b4c18f614004dda8c9f2c07328cb5b6e314d6e1bbd536cb1a6c1"},
|
||||
{file = "pydantic-1.7.3-cp37-cp37m-manylinux2014_i686.whl", hash = "sha256:b2b054d095b6431cdda2f852a6d2f0fdec77686b305c57961b4c5dd6d863bf3c"},
|
||||
{file = "pydantic-1.7.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:025bf13ce27990acc059d0c5be46f416fc9b293f45363b3d19855165fee1874f"},
|
||||
{file = "pydantic-1.7.3-cp37-cp37m-win_amd64.whl", hash = "sha256:6e3874aa7e8babd37b40c4504e3a94cc2023696ced5a0500949f3347664ff8e2"},
|
||||
{file = "pydantic-1.7.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e682f6442ebe4e50cb5e1cfde7dda6766fb586631c3e5569f6aa1951fd1a76ef"},
|
||||
{file = "pydantic-1.7.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:185e18134bec5ef43351149fe34fda4758e53d05bb8ea4d5928f0720997b79ef"},
|
||||
{file = "pydantic-1.7.3-cp38-cp38-manylinux2014_i686.whl", hash = "sha256:f5b06f5099e163295b8ff5b1b71132ecf5866cc6e7f586d78d7d3fd6e8084608"},
|
||||
{file = "pydantic-1.7.3-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:24ca47365be2a5a3cc3f4a26dcc755bcdc9f0036f55dcedbd55663662ba145ec"},
|
||||
{file = "pydantic-1.7.3-cp38-cp38-win_amd64.whl", hash = "sha256:d1fe3f0df8ac0f3a9792666c69a7cd70530f329036426d06b4f899c025aca74e"},
|
||||
{file = "pydantic-1.7.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f6864844b039805add62ebe8a8c676286340ba0c6d043ae5dea24114b82a319e"},
|
||||
{file = "pydantic-1.7.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:ecb54491f98544c12c66ff3d15e701612fc388161fd455242447083350904730"},
|
||||
{file = "pydantic-1.7.3-cp39-cp39-manylinux2014_i686.whl", hash = "sha256:ffd180ebd5dd2a9ac0da4e8b995c9c99e7c74c31f985ba090ee01d681b1c4b95"},
|
||||
{file = "pydantic-1.7.3-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:8d72e814c7821125b16f1553124d12faba88e85405b0864328899aceaad7282b"},
|
||||
{file = "pydantic-1.7.3-cp39-cp39-win_amd64.whl", hash = "sha256:475f2fa134cf272d6631072554f845d0630907fce053926ff634cc6bc45bf1af"},
|
||||
{file = "pydantic-1.7.3-py3-none-any.whl", hash = "sha256:38be427ea01a78206bcaf9a56f835784afcba9e5b88fbdce33bbbfbcd7841229"},
|
||||
{file = "pydantic-1.7.3.tar.gz", hash = "sha256:213125b7e9e64713d16d988d10997dabc6a1f73f3991e1ff8e35ebb1409c7dc9"},
|
||||
]
|
||||
pygtrie = [
|
||||
{file = "pygtrie-2.4.2.tar.gz", hash = "sha256:43205559d28863358dbbf25045029f58e2ab357317a59b11f11ade278ac64692"},
|
||||
]
|
||||
python-dotenv = [
|
||||
{file = "python-dotenv-0.15.0.tar.gz", hash = "sha256:587825ed60b1711daea4832cf37524dfd404325b7db5e25ebe88c495c9f807a0"},
|
||||
{file = "python_dotenv-0.15.0-py2.py3-none-any.whl", hash = "sha256:0c8d1b80d1a1e91717ea7d526178e3882732420b03f08afea0406db6402e220e"},
|
||||
]
|
||||
rfc3986 = [
|
||||
{file = "rfc3986-1.4.0-py2.py3-none-any.whl", hash = "sha256:af9147e9aceda37c91a05f4deb128d4b4b49d6b199775fd2d2927768abdc8f50"},
|
||||
{file = "rfc3986-1.4.0.tar.gz", hash = "sha256:112398da31a3344dc25dbf477d8df6cb34f9278a94fee2625d89e4514be8bb9d"},
|
||||
]
|
||||
sniffio = [
|
||||
{file = "sniffio-1.2.0-py3-none-any.whl", hash = "sha256:471b71698eac1c2112a40ce2752bb2f4a4814c22a54a3eed3676bc0f5ca9f663"},
|
||||
{file = "sniffio-1.2.0.tar.gz", hash = "sha256:c4666eecec1d3f50960c6bdf61ab7bc350648da6c126e3cf6898d8cd4ddcd3de"},
|
||||
]
|
||||
starlette = [
|
||||
{file = "starlette-0.13.6-py3-none-any.whl", hash = "sha256:bd2ffe5e37fb75d014728511f8e68ebf2c80b0fa3d04ca1479f4dc752ae31ac9"},
|
||||
{file = "starlette-0.13.6.tar.gz", hash = "sha256:ebe8ee08d9be96a3c9f31b2cb2a24dbdf845247b745664bd8a3f9bd0c977fdbc"},
|
||||
]
|
||||
typing-extensions = [
|
||||
{file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"},
|
||||
{file = "typing_extensions-3.7.4.3-py3-none-any.whl", hash = "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918"},
|
||||
{file = "typing_extensions-3.7.4.3.tar.gz", hash = "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c"},
|
||||
]
|
||||
uvicorn = [
|
||||
{file = "uvicorn-0.11.8-py3-none-any.whl", hash = "sha256:4b70ddb4c1946e39db9f3082d53e323dfd50634b95fd83625d778729ef1730ef"},
|
||||
{file = "uvicorn-0.11.8.tar.gz", hash = "sha256:46a83e371f37ea7ff29577d00015f02c942410288fb57def6440f2653fff1d26"},
|
||||
]
|
||||
uvloop = [
|
||||
{file = "uvloop-0.15.0-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:e17cc3f32288daf8476368ddb60cad0f00ab13c979f6f4003ee773f1d90cab58"},
|
||||
{file = "uvloop-0.15.0-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:9ae0b0e86ffcfe11c208fdb1552894911aa0915280e904a3757ebd4505792568"},
|
||||
{file = "uvloop-0.15.0-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:9900020313c158cbc7befdd5ad60eb7b5443d7d1e83ad57c310e330fe7b2d858"},
|
||||
{file = "uvloop-0.15.0-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:1c114eafd3c53cab74024d122742ed9001611e8f341421dba84a8ea7d886cc2f"},
|
||||
{file = "uvloop-0.15.0-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:08547ec0d40005da5c5f969f406cc90e6d589b41388958e326d78ea63fb5d2f9"},
|
||||
{file = "uvloop-0.15.0-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:cb121716f4ff5c01dd9b9a12b2193e59383243c21d14c916f588fd626bd3c74b"},
|
||||
{file = "uvloop-0.15.0-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:ad5391ce33ac1c745dec6f8a394387b3247c374e93b12a1f0403791f6be4bb8a"},
|
||||
{file = "uvloop-0.15.0-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:fab95c88d0c3694089c93a8c46fdab30117c4ce0d1afa2ab7d6f4d0607495857"},
|
||||
{file = "uvloop-0.15.0-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:2d76da5529025f9771855505cfde7bf16b9b0001e2fe05b0abf3e4fc01a5dfdb"},
|
||||
{file = "uvloop-0.15.0.tar.gz", hash = "sha256:1a503d5b49da6e3dd5607d6e533a5315b1caedbf629901807c65a23a09cad065"},
|
||||
]
|
||||
websockets = [
|
||||
{file = "websockets-8.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:3762791ab8b38948f0c4d281c8b2ddfa99b7e510e46bd8dfa942a5fff621068c"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:3db87421956f1b0779a7564915875ba774295cc86e81bc671631379371af1170"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:4f9f7d28ce1d8f1295717c2c25b732c2bc0645db3215cf757551c392177d7cb8"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:295359a2cc78736737dd88c343cd0747546b2174b5e1adc223824bcaf3e164cb"},
|
||||
{file = "websockets-8.1-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:1d3f1bf059d04a4e0eb4985a887d49195e15ebabc42364f4eb564b1d065793f5"},
|
||||
{file = "websockets-8.1-cp36-cp36m-win32.whl", hash = "sha256:2db62a9142e88535038a6bcfea70ef9447696ea77891aebb730a333a51ed559a"},
|
||||
{file = "websockets-8.1-cp36-cp36m-win_amd64.whl", hash = "sha256:0e4fb4de42701340bd2353bb2eee45314651caa6ccee80dbd5f5d5978888fed5"},
|
||||
{file = "websockets-8.1-cp37-cp37m-macosx_10_6_intel.whl", hash = "sha256:9b248ba3dd8a03b1a10b19efe7d4f7fa41d158fdaa95e2cf65af5a7b95a4f989"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:ce85b06a10fc65e6143518b96d3dca27b081a740bae261c2fb20375801a9d56d"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:965889d9f0e2a75edd81a07592d0ced54daa5b0785f57dc429c378edbcffe779"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:751a556205d8245ff94aeef23546a1113b1dd4f6e4d102ded66c39b99c2ce6c8"},
|
||||
{file = "websockets-8.1-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:3ef56fcc7b1ff90de46ccd5a687bbd13a3180132268c4254fc0fa44ecf4fc422"},
|
||||
{file = "websockets-8.1-cp37-cp37m-win32.whl", hash = "sha256:7ff46d441db78241f4c6c27b3868c9ae71473fe03341340d2dfdbe8d79310acc"},
|
||||
{file = "websockets-8.1-cp37-cp37m-win_amd64.whl", hash = "sha256:20891f0dddade307ffddf593c733a3fdb6b83e6f9eef85908113e628fa5a8308"},
|
||||
{file = "websockets-8.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c1ec8db4fac31850286b7cd3b9c0e1b944204668b8eb721674916d4e28744092"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:5c01fd846263a75bc8a2b9542606927cfad57e7282965d96b93c387622487485"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9bef37ee224e104a413f0780e29adb3e514a5b698aabe0d969a6ba426b8435d1"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:d705f8aeecdf3262379644e4b55107a3b55860eb812b673b28d0fbc347a60c55"},
|
||||
{file = "websockets-8.1-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:c8a116feafdb1f84607cb3b14aa1418424ae71fee131642fc568d21423b51824"},
|
||||
{file = "websockets-8.1-cp38-cp38-win32.whl", hash = "sha256:e898a0863421650f0bebac8ba40840fc02258ef4714cb7e1fd76b6a6354bda36"},
|
||||
{file = "websockets-8.1-cp38-cp38-win_amd64.whl", hash = "sha256:f8a7bff6e8664afc4e6c28b983845c5bc14965030e3fb98789734d416af77c4b"},
|
||||
{file = "websockets-8.1.tar.gz", hash = "sha256:5c65d2da8c6bce0fca2528f69f44b2f977e06954c8512a952222cea50dad430f"},
|
||||
]
|
||||
win32-setctime = [
|
||||
{file = "win32_setctime-1.0.3-py3-none-any.whl", hash = "sha256:dc925662de0a6eb987f0b01f599c01a8236cb8c62831c22d9cada09ad958243e"},
|
||||
{file = "win32_setctime-1.0.3.tar.gz", hash = "sha256:4e88556c32fdf47f64165a2180ba4552f8bb32c1103a2fafd05723a0bd42bd4b"},
|
||||
]
|
38
packages/nonebot-adapter-cqhttp/pyproject.toml
Normal file
38
packages/nonebot-adapter-cqhttp/pyproject.toml
Normal file
@ -0,0 +1,38 @@
|
||||
[tool.poetry]
|
||||
name = "nonebot-adapter-cqhttp"
|
||||
version = "2.0.0a10"
|
||||
description = "OneBot(CQHTTP) adapter for nonebot2"
|
||||
authors = ["yanyongyu <yanyongyu_1@126.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
homepage = "https://v2.nonebot.dev/"
|
||||
repository = "https://github.com/nonebot/nonebot2"
|
||||
documentation = "https://v2.nonebot.dev/"
|
||||
keywords = ["bot", "qq", "qqbot", "coolq", "cqhttp"]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Framework :: Robot Framework",
|
||||
"Framework :: Robot Framework :: Library",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3"
|
||||
]
|
||||
packages = [
|
||||
{ include = "nonebot" }
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.7.3"
|
||||
nonebot2 = "^2.0.0-alpha.10"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
nonebot2 = { path = "../../", develop = true }
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "aliyun"
|
||||
url = "https://mirrors.aliyun.com/pypi/simple/"
|
||||
default = true
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Reference in New Issue
Block a user