2021-01-29 21:19:13 +08:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
|
|
from nonebot.typing import overrides
|
|
|
|
|
2021-01-30 06:10:04 +08:00
|
|
|
from ..message import MessageChain
|
|
|
|
from .base import Event, PrivateSenderInfo, SenderInfo
|
|
|
|
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
|
|
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):
|
2021-01-30 06:10:04 +08:00
|
|
|
pass
|