mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 04:26:24 +08:00
💬 💡 rename MiraiBot to Bot, fix a comment style
This commit is contained in:
parent
6c0b20e5b7
commit
5a63827f22
@ -18,7 +18,7 @@ Mirai-API-HTTP 协议适配
|
||||
|
||||
"""
|
||||
|
||||
from .bot import MiraiBot
|
||||
from .bot_ws import MiraiWebsocketBot
|
||||
from .bot import Bot
|
||||
from .bot_ws import WebsocketBot
|
||||
from .event import *
|
||||
from .message import MessageChain, MessageSegment
|
||||
|
@ -142,7 +142,7 @@ class SessionManager:
|
||||
return cls(key, client)
|
||||
|
||||
|
||||
class MiraiBot(BaseBot):
|
||||
class Bot(BaseBot):
|
||||
"""
|
||||
mirai-api-http 协议 Bot 适配。
|
||||
|
||||
|
@ -14,7 +14,7 @@ from nonebot.exception import RequestDenied
|
||||
from nonebot.log import logger
|
||||
from nonebot.typing import overrides
|
||||
|
||||
from .bot import MiraiBot, SessionManager
|
||||
from .bot import SessionManager, Bot
|
||||
|
||||
WebsocketHandlerFunction = Callable[[Dict[str, Any]], Coroutine[Any, Any, None]]
|
||||
WebsocketHandler_T = TypeVar('WebsocketHandler_T',
|
||||
@ -71,7 +71,8 @@ class WebSocket(BaseWebSocket):
|
||||
logger.exception(f'Websocket client listened {self.websocket} '
|
||||
f'failed to decode data: {e}')
|
||||
continue
|
||||
asyncio.gather(*map(lambda f: f(data), self.event_handlers),
|
||||
asyncio.gather(
|
||||
*map(lambda f: f(data), self.event_handlers), #type: ignore
|
||||
return_exceptions=True)
|
||||
|
||||
@overrides(BaseWebSocket)
|
||||
@ -87,18 +88,18 @@ class WebSocket(BaseWebSocket):
|
||||
return callable
|
||||
|
||||
|
||||
class MiraiWebsocketBot(MiraiBot):
|
||||
class WebsocketBot(Bot):
|
||||
"""
|
||||
mirai-api-http 正向 Websocket 协议 Bot 适配。
|
||||
"""
|
||||
|
||||
@overrides(MiraiBot)
|
||||
@overrides(Bot)
|
||||
def __init__(self, connection_type: str, self_id: str, *,
|
||||
websocket: WebSocket):
|
||||
super().__init__(connection_type, self_id, websocket=websocket)
|
||||
|
||||
@property
|
||||
@overrides(MiraiBot)
|
||||
@overrides(Bot)
|
||||
def type(self) -> str:
|
||||
return "mirai-ws"
|
||||
|
||||
@ -113,7 +114,7 @@ class MiraiWebsocketBot(MiraiBot):
|
||||
return api
|
||||
|
||||
@classmethod
|
||||
@overrides(MiraiBot)
|
||||
@overrides(Bot)
|
||||
async def check_permission(cls, driver: "Driver", connection_type: str,
|
||||
headers: dict, body: Optional[dict]) -> NoReturn:
|
||||
raise RequestDenied(
|
||||
@ -121,7 +122,7 @@ class MiraiWebsocketBot(MiraiBot):
|
||||
reason=f'Connection {connection_type} not implented')
|
||||
|
||||
@classmethod
|
||||
@overrides(MiraiBot)
|
||||
@overrides(Bot)
|
||||
def register(cls, driver: "Driver", config: "Config", qq: int):
|
||||
"""
|
||||
:说明:
|
||||
|
@ -10,3 +10,20 @@ from .base import (Event, GroupChatInfo, GroupInfo, PrivateChatInfo,
|
||||
from .message import *
|
||||
from .notice import *
|
||||
from .request import *
|
||||
|
||||
__all__ = [
|
||||
'Event', 'GroupChatInfo', 'GroupInfo', 'PrivateChatInfo', 'UserPermission',
|
||||
'MessageChain', 'MessageEvent', 'GroupMessage', 'FriendMessage',
|
||||
'TempMessage', 'NoticeEvent', 'MuteEvent', 'BotMuteEvent', 'BotUnmuteEvent',
|
||||
'MemberMuteEvent', 'MemberUnmuteEvent', 'BotJoinGroupEvent',
|
||||
'BotLeaveEventActive', 'BotLeaveEventKick', 'MemberJoinEvent',
|
||||
'MemberLeaveEventKick', 'MemberLeaveEventQuit', 'FriendRecallEvent',
|
||||
'GroupRecallEvent', 'GroupStateChangeEvent', 'GroupNameChangeEvent',
|
||||
'GroupEntranceAnnouncementChangeEvent', 'GroupMuteAllEvent',
|
||||
'GroupAllowAnonymousChatEvent', 'GroupAllowConfessTalkEvent',
|
||||
'GroupAllowMemberInviteEvent', 'MemberStateChangeEvent',
|
||||
'MemberCardChangeEvent', 'MemberSpecialTitleChangeEvent',
|
||||
'BotGroupPermissionChangeEvent', 'MemberPermissionChangeEvent',
|
||||
'RequestEvent', 'NewFriendRequestEvent', 'MemberJoinRequestEvent',
|
||||
'BotInvitedJoinGroupRequestEvent'
|
||||
]
|
||||
|
@ -6,7 +6,7 @@ from typing_extensions import Literal
|
||||
from .base import Event
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..bot import MiraiBot as Bot
|
||||
from ..bot import Bot
|
||||
|
||||
|
||||
class RequestEvent(Event):
|
||||
|
@ -257,12 +257,14 @@ class MessageSegment(BaseMessageSegment):
|
||||
:参数:
|
||||
|
||||
* ``name: str``: 戳一戳的类型
|
||||
- "Poke": 戳一戳
|
||||
- "ShowLove": 比心
|
||||
- "Like": 点赞
|
||||
- "Heartbroken": 心碎
|
||||
- "SixSixSix": 666
|
||||
- "FangDaZhao": 放大招
|
||||
|
||||
* ``Poke``: 戳一戳
|
||||
* ``ShowLove``: 比心
|
||||
* ``Like``: 点赞
|
||||
* ``Heartbroken``: 心碎
|
||||
* ``SixSixSix``: 666
|
||||
* ``FangDaZhao``: 放大招
|
||||
|
||||
"""
|
||||
return cls(type=MessageType.POKE, name=name)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user