You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/swarms/structs/message.py

35 lines
745 B

import datetime
from typing import Dict, Optional
class Message:
"""
Represents a message with timestamp and optional metadata.
Usage
--------------
mes = Message(
sender = "Kye",
content = "message"
)
print(mes)
"""
def __init__(
self,
sender: str,
content: str,
metadata: Optional[Dict[str, str]] = None,
):
self.timestamp: datetime.datetime = datetime.datetime.now()
self.sender: str = sender
self.content: str = content
self.metadata: Dict[str, str] = metadata or {}
def __repr__(self) -> str:
"""
__repr__ means...
"""
return f"{self.timestamp} - {self.sender}: {self.content}"