mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-19 09:38:21 +08:00
📝 💡 fix some typo and style in mirai adapter
This commit is contained in:
parent
6a273a8eea
commit
d2a62ebd3d
@ -13,7 +13,7 @@ Mirai-API-HTTP 协议适配
|
||||
.. _mirai-api-http 文档:
|
||||
https://github.com/project-mirai/mirai-api-http/tree/master/docs
|
||||
|
||||
.. _Issue页面
|
||||
.. _Issue页面:
|
||||
https://github.com/nonebot/nonebot2/issues
|
||||
|
||||
"""
|
||||
|
@ -218,7 +218,10 @@ class MiraiBot(BaseBot):
|
||||
@overrides(BaseBot)
|
||||
async def call_api(self, api: str, **data) -> NoReturn:
|
||||
"""
|
||||
\:\:\: danger
|
||||
由于Mirai的HTTP API特殊性, 该API暂时无法实现
|
||||
\:\:\:
|
||||
|
||||
\:\:\: tip
|
||||
你可以使用 ``MiraiBot.api`` 中提供的调用方法来代替
|
||||
\:\:\:
|
||||
@ -239,13 +242,13 @@ class MiraiBot(BaseBot):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
根据 ``event`` 向触发事件的主题发送信息
|
||||
根据 ``event`` 向触发事件的主体发送信息
|
||||
|
||||
:参数:
|
||||
|
||||
* ``event: Event``: Event对象
|
||||
* ``message: Union[MessageChain, MessageSegment, str]``: 要发送的消息
|
||||
* ``at_sender: bool``: 是否 @ 事件主题
|
||||
* ``at_sender: bool``: 是否 @ 事件主体
|
||||
"""
|
||||
if isinstance(message, MessageSegment):
|
||||
message = MessageChain(message)
|
||||
|
@ -15,7 +15,6 @@ from nonebot.log import logger
|
||||
from nonebot.typing import overrides
|
||||
|
||||
from .bot import MiraiBot, SessionManager
|
||||
from .config import Config as MiraiConfig
|
||||
|
||||
WebsocketHandlerFunction = Callable[[Dict[str, Any]], Coroutine[Any, Any, None]]
|
||||
WebsocketHandler_T = TypeVar('WebsocketHandler_T',
|
||||
|
@ -1,11 +1,12 @@
|
||||
"""
|
||||
\:\:\:warning 警告
|
||||
\:\:\: warning
|
||||
事件中为了使代码更加整洁, 我们采用了与PEP8相符的命名规则取代Mirai原有的驼峰命名
|
||||
|
||||
部分字段可能与文档在符号上不一致
|
||||
\:\:\:
|
||||
"""
|
||||
from .base import Event, GroupChatInfo, GroupInfo, UserPermission, PrivateChatInfo
|
||||
from .base import (Event, GroupChatInfo, GroupInfo, PrivateChatInfo,
|
||||
UserPermission)
|
||||
from .message import *
|
||||
from .notice import *
|
||||
from .request import *
|
@ -13,11 +13,13 @@ from nonebot.typing import overrides
|
||||
|
||||
class UserPermission(str, Enum):
|
||||
"""
|
||||
:说明:
|
||||
|
||||
用户权限枚举类
|
||||
|
||||
- ``OWNER``: 群主
|
||||
- ``ADMINISTRATOR``: 群管理
|
||||
- ``MEMBER``: 普通群成员
|
||||
* ``OWNER``: 群主
|
||||
* ``ADMINISTRATOR``: 群管理
|
||||
* ``MEMBER``: 普通群成员
|
||||
"""
|
||||
OWNER = 'OWNER'
|
||||
ADMINISTRATOR = 'ADMINISTRATOR'
|
||||
|
@ -52,8 +52,10 @@ class NewFriendRequestEvent(RequestEvent):
|
||||
|
||||
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
||||
* ``operate: Literal[1, 2]``: 响应的操作类型
|
||||
- ``1``: 拒绝添加好友
|
||||
- ``2``: 拒绝添加好友并添加黑名单,不再接收该用户的好友申请
|
||||
|
||||
* ``1``: 拒绝添加好友
|
||||
* ``2``: 拒绝添加好友并添加黑名单,不再接收该用户的好友申请
|
||||
|
||||
* ``message: str``: 回复的信息
|
||||
"""
|
||||
assert operate > 0
|
||||
@ -104,10 +106,12 @@ class MemberJoinRequestEvent(RequestEvent):
|
||||
|
||||
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
||||
* ``operate: Literal[1, 2, 3, 4]``: 响应的操作类型
|
||||
- ``1``: 拒绝入群
|
||||
- ``2``: 忽略请求
|
||||
- ``3``: 拒绝入群并添加黑名单,不再接收该用户的入群申请
|
||||
- ``4``: 忽略入群并添加黑名单,不再接收该用户的入群申请
|
||||
|
||||
* ``1``: 拒绝入群
|
||||
* ``2``: 忽略请求
|
||||
* ``3``: 拒绝入群并添加黑名单,不再接收该用户的入群申请
|
||||
* ``4``: 忽略入群并添加黑名单,不再接收该用户的入群申请
|
||||
|
||||
* ``message: str``: 回复的信息
|
||||
"""
|
||||
assert operate > 0
|
||||
|
@ -44,6 +44,7 @@ def catch_network_error(function: _AsyncCallable) -> _AsyncCallable:
|
||||
:说明:
|
||||
|
||||
捕捉函数抛出的httpx网络异常并释放 ``NetworkError`` 异常
|
||||
|
||||
处理返回数据, 在code不为0时释放 ``ActionFailed`` 异常
|
||||
|
||||
\:\:\: warning
|
||||
@ -72,6 +73,7 @@ def argument_validation(function: _AnyCallable) -> _AnyCallable:
|
||||
:说明:
|
||||
|
||||
通过函数签名中的类型注解来对传入参数进行运行时校验
|
||||
|
||||
会在参数出错时释放 ``InvalidArgument`` 异常
|
||||
"""
|
||||
function = validate_arguments(config={
|
||||
|
Loading…
Reference in New Issue
Block a user