WechatOnCloud/bridge/woc_bridge/models/message.py
Kris c45282f094 feat: 新增好友自动通过、UI自动化能力与多分辨率适配
- 新增登录状态守卫后台任务
- 新增好友申请自动通过规则引擎
- 新增多分辨率UI配置与模板资源
- 新增消息拉取复合游标支持
- 优化发送队列与UI自动化逻辑
- 新增批量发送日志与错误处理
- 优化Docker镜像构建与ptrace初始化
- 新增联系人名称缓存预热
2026-07-17 18:10:31 +08:00

59 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""消息域模型:单条消息 / 消息拉取响应。"""
from __future__ import annotations
from pydantic import BaseModel, Field
# ---------------------------------------------------------------------------
# 消息接口GET /api/messages/since
# ---------------------------------------------------------------------------
class Message(BaseModel):
"""单条微信消息。"""
msg_id: str = Field(description="消息 ID")
talker: str = Field(description="会话对方 wxid群消息为 chatroom id")
sender: str = Field(default="", description="实际发送者 wxid群消息中为成员 wxid")
is_sender: bool = Field(default=False, description="是否为本机发送")
type: int = Field(description="微信原始消息类型")
render_type: str = Field(description="渲染类型text/image/voice/video/file/system")
content: str = Field(default="", description="消息内容文本")
create_time: int = Field(description="消息时间戳Unix 秒)")
session_type: str = Field(description="会话类型p2p / group")
class MessagesResponse(BaseModel):
"""消息拉取响应。"""
messages: list[Message] = Field(default_factory=list)
next_cursor: int = Field(description="下次拉取应使用的 cursor")
next_cursor_local_id: int = Field(
default=0, description="下次拉取应使用的 local_id 游标(同秒消息 tie-breaker"
)
has_more: bool = Field(default=False, description="是否可能还有更多消息")
# ---------------------------------------------------------------------------
# 按会话拉取GET /api/messages/by_session
# ---------------------------------------------------------------------------
class MessagesBySessionResponse(BaseModel):
"""按会话拉取历史消息响应。"""
messages: list[Message] = Field(default_factory=list)
next_cursor: int = Field(description="下次拉取应使用的 cursor")
next_cursor_local_id: int = Field(
default=0, description="下次拉取应使用的 local_id 游标(同秒消息 tie-breaker"
)
has_more: bool = Field(default=False, description="是否可能还有更多消息")
talker: str = Field(description="本次查询的会话对方 wxid")
# ---------------------------------------------------------------------------
# 消息搜索GET /api/messages/search
# ---------------------------------------------------------------------------
class MessageSearchResponse(BaseModel):
"""消息搜索响应。"""
messages: list[Message] = Field(default_factory=list)
total: int = Field(default=0, description="命中总数(可能大于返回条数)")