Skip to content

_types

_types

Event data model for the cocapi event polling system.

EventType

Bases: Enum

All event types produced by the polling system.

WarState

Bases: Enum

War state machine states matching the CoC API.

Change dataclass

Change(field: str, old_value: Any, new_value: Any)

A single field-level change between two snapshots.

Event dataclass

Event(
    event_type: EventType,
    tag: str,
    timestamp: float = time(),
    old_data: dict[str, Any] | None = None,
    new_data: dict[str, Any] | None = None,
    changes: tuple[Change, ...] = (),
    metadata: dict[str, Any] = dict(),
)

An event produced by the polling system.

ATTRIBUTE DESCRIPTION
event_type

The type of event.

TYPE: EventType

tag

The clan or player tag this event relates to.

TYPE: str

timestamp

Unix timestamp when the event was created.

TYPE: float

old_data

Full previous snapshot (None on first poll).

TYPE: dict[str, Any] | None

new_data

Full current snapshot (None for MEMBER_LEFT).

TYPE: dict[str, Any] | None

changes

Tuple of field-level changes detected.

TYPE: tuple[Change, ...]

metadata

Extra context (member_tag, war_state_from, etc.).

TYPE: dict[str, Any]