You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
558 B
23 lines
558 B
"""消息事件定义"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
from ..models.message import Message
|
|
|
|
|
|
@dataclass
|
|
class MessageEvent:
|
|
"""一条新消息事件,供外部回调消费"""
|
|
|
|
message: Message
|
|
event_time: float = field(default_factory=time.time)
|
|
source: str = "ui_automation"
|
|
|
|
def __str__(self) -> str:
|
|
m = self.message
|
|
prefix = "[自己]" if m.is_self else f"[{m.sender}]"
|
|
return f"{m.conversation} {prefix}: {m.content[:80]}"
|
|
|