aioappsrv/appservice/matrix.py

28 lines
788 B
Python
Raw Normal View History

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