from datetime import datetime from typing import Optional from pydantic import BaseModel, Field class HookCreate(BaseModel): message: str = Field(..., min_length=1, description="Message body supporting Markdown") chat_id: str = Field(..., min_length=1, description="Target chat ID or username") class HookRead(BaseModel): hook_id: str message: str chat_id: str created_at: datetime @property def action_path(self) -> str: return f"/action/{self.hook_id}" class HookResponse(HookRead): action_url: str class HookUpdateId(BaseModel): hook_id: str = Field( ..., min_length=3, max_length=64, pattern=r"^[A-Za-z0-9_-]+$", description="New hook identifier", ) class LoginStartRequest(BaseModel): phone_number: Optional[str] = None class LoginVerifyRequest(BaseModel): code: str phone_number: Optional[str] = None password: Optional[str] = None class MessageTriggerResponse(BaseModel): status: str hook_id: str chat_id: str class StatusResponse(BaseModel): authorized: bool user: Optional[str] session_active: bool phone_number: Optional[str] code_sent: bool = False