from __future__ import annotations

from pydantic import BaseModel, Field


class SlackEvent(BaseModel):
    type: str
    user: str = ""
    text: str = ""
    channel: str = ""
    ts: str = ""
    event_ts: str = ""
    bot_id: str = ""


class SlackWebhookPayload(BaseModel):
    type: str
    """'url_verification' or 'event_callback'"""

    token: str = ""
    challenge: str = ""

    team_id: str = ""
    api_app_id: str = ""
    event: SlackEvent | None = None
    event_id: str = ""
    event_time: int = 0

    @property
    def is_bot_message(self) -> bool:
        return self.event is not None and bool(self.event.bot_id)
