2021-04-17 06:45:51 +02:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
2021-05-09 12:16:00 +02:00
|
|
|
class User:
|
2021-04-20 14:49:49 +02:00
|
|
|
avatar_url: str = ""
|
2021-05-09 12:16:00 +02:00
|
|
|
display_name: str = ""
|
2021-04-17 06:45:51 +02:00
|
|
|
|
|
|
|
|
2021-05-09 12:16:00 +02:00
|
|
|
class Event:
|
2021-04-17 06:45:51 +02:00
|
|
|
def __init__(self, event: dict):
|
2021-05-09 12:16:00 +02:00
|
|
|
content = event.get("content", {})
|
2021-04-17 06:45:51 +02:00
|
|
|
|
2021-04-20 14:49:49 +02:00
|
|
|
self.attachment = content.get("url")
|
2021-04-26 10:05:01 +02:00
|
|
|
self.body = content.get("body", "").strip()
|
2021-05-09 12:16:00 +02:00
|
|
|
self.formatted_body = content.get("formatted_body", "")
|
|
|
|
self.id = event["event_id"]
|
2021-04-17 06:45:51 +02:00
|
|
|
self.is_direct = content.get("is_direct", False)
|
2021-05-09 12:16:00 +02:00
|
|
|
self.redacts = event.get("redacts", "")
|
2021-04-17 06:45:51 +02:00
|
|
|
self.room_id = event["room_id"]
|
|
|
|
self.sender = event["sender"]
|
|
|
|
self.state_key = event.get("state_key", "")
|
|
|
|
|
|
|
|
rel = content.get("m.relates_to", {})
|
|
|
|
|
|
|
|
self.relates_to = rel.get("event_id")
|
|
|
|
self.reltype = rel.get("rel_type")
|
|
|
|
self.new_body = content.get("m.new_content", {}).get("body", "")
|