Files
PyMeshCoreGUI/src/meshcore_gui/models/message.py
T
Stefan de Konink 18e21ffcdb Initial commit
PyMeshCore GUI is an open-source desktop application for interacting with the MeshCore network.
It focuses on **chatting, prototyping, and development** on top of MeshCore, with an emphasis on
desktop workflows and developer accessibility.

The project is built using PySide6 (Qt for Python) and meshcore-py.
2026-01-04 20:54:12 +01:00

23 lines
603 B
Python

from datetime import datetime
from typing import Any
class Message:
def __init__(self, payload: dict[str, Any]):
self.payload = payload
@property
def timestamp(self) -> datetime | None:
ts = self.payload.get("sender_timestamp")
return datetime.fromtimestamp(ts) if ts else None
@property
def text(self) -> str:
return self.payload.get("text", "")
def formatted(self) -> str:
if self.timestamp:
time_str = self.timestamp.strftime("%Y-%m-%d %H:%M:%S")
return f"[{time_str}] {self.text}"
return self.text