aioappsrv/appservice/matrix.py

29 lines
849 B
Python
Raw Permalink Normal View History

2021-04-17 06:45:51 +02:00
from dataclasses import dataclass
@dataclass
class User:
avatar_url: str = ""
display_name: str = ""
2021-04-17 06:45:51 +02:00
class Event:
2021-04-17 06:45:51 +02:00
def __init__(self, event: dict):
content = event.get("content", {})
2021-04-17 06:45:51 +02:00
self.attachment = content.get("url")
2021-04-26 10:05:01 +02:00
self.body = content.get("body", "").strip()
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)
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", "")