def from_dict(cls, event): event_id = sanitize_id(event["event_id"]) sender = sanitize_id(event["sender"]) timestamp = sanitize_ts(event["origin_server_ts"]) mxc_url = sanitize_text(event['content']['url']) description = sanitize_text(event["content"]["body"]) return cls(event_id, sender, timestamp, mxc_url, description)
def from_dict(cls, event): event_id = sanitize_id(event["event_id"]) sender = sanitize_id(event["sender"]) timestamp = sanitize_ts(event["origin_server_ts"]) message = sanitize_text(event["content"]["body"]) message_type = sanitize_text(event["content"]["msgtype"]) return cls(event_id, sender, timestamp, message, message_type)
def from_dict(cls, event_dict): event_id = sanitize_id(event_dict["event_id"]) sender = sanitize_id(event_dict["sender"]) timestamp = sanitize_ts(event_dict["origin_server_ts"]) topic = sanitize_text(event_dict["content"]["topic"]) return cls(event_id, sender, timestamp, topic)
def from_dict(cls, event): event_id = sanitize_id(event["event_id"]) sender = sanitize_id(event["sender"]) timestamp = sanitize_ts(event["origin_server_ts"]) msg = "" formatted_msg = None msg = sanitize_text(event['content']['body']) if ('format' in event['content'] and 'formatted_body' in event['content']): if event['content']['format'] == "org.matrix.custom.html": formatted_msg = Formatted.from_html( sanitize_text(event['content']['formatted_body'])) return cls(event_id, sender, timestamp, msg, formatted_msg)
def from_dict(cls, server, error_prefix, fatal, parsed_dict): try: message = "{prefix}: {error}".format( prefix=error_prefix, error=sanitize_text(parsed_dict["error"])) return cls(server, message, fatal=fatal) except KeyError: return cls( server, ("{prefix}: Invalid JSON response " "from server.").format(prefix=error_prefix), fatal=fatal)
def from_dict(cls, event_dict): event_id = sanitize_id(event_dict["event_id"]) sender = sanitize_id(event_dict["sender"]) timestamp = sanitize_ts(event_dict["origin_server_ts"]) redaction_id = sanitize_id(event_dict["redacts"]) reason = (sanitize_text(event_dict["content"]["reason"]) if "reason" in event_dict["content"] else None) return cls(event_id, sender, timestamp, redaction_id, reason)
def from_dict(cls, event_dict): event_id = sanitize_id(event_dict["event_id"]) sender = sanitize_id(event_dict["sender"]) timestamp = sanitize_ts(event_dict["origin_server_ts"]) display_name = None if event_dict["content"]: if "display_name" in event_dict["content"]: display_name = sanitize_text( event_dict["content"]["displayname"]) return cls(event_id, sender, timestamp, display_name)
def from_dict(cls, event): event_id = sanitize_id(event["event_id"]) sender = sanitize_id(event["sender"]) timestamp = sanitize_ts(event["origin_server_ts"]) censor = sanitize_id(event['unsigned']['redacted_because']['sender']) reason = None if 'reason' in event['unsigned']['redacted_because']['content']: reason = sanitize_text( event['unsigned']['redacted_because']['content']['reason']) return cls(event_id, sender, timestamp, censor, reason)