nonebot2/nonebot/adapters/mirai/event/message.py
2021-01-29 21:19:13 +08:00

40 lines
847 B
Python

from typing import TYPE_CHECKING
from pydantic import Field
from .base import Event, SenderInfo, PrivateSenderInfo
from ..message import MessageChain
from nonebot.typing import overrides
class MessageEvent(Event):
message_chain: MessageChain = Field(alias='messageChain')
sender: SenderInfo
@overrides(Event)
def get_message(self) -> MessageChain:
return self.message_chain
@overrides(Event)
def get_plaintext(self) -> str:
return self.message_chain.__str__()
@overrides(Event)
def get_user_id(self) -> str:
return str(self.sender.id)
@overrides(Event)
def get_session_id(self) -> str:
return self.get_user_id()
class GroupMessage(MessageEvent):
pass
class FriendMessage(MessageEvent):
sender: PrivateSenderInfo
class TempMessage(MessageEvent):
pass