mirror of
https://github.com/bliksemlabs/PyMeshCoreGUI.git
synced 2026-06-11 17:54:57 +02:00
18e21ffcdb
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.
23 lines
603 B
Python
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
|