Example #1
0
    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)
Example #2
0
def test_prism():
    formatted = Formatted.from_html(html_prism)
    assert formatted.to_weechat() == weechat_prism
Example #3
0
def test_conversion():
    formatted = Formatted.from_input_line("*Hello*")
    formatted2 = Formatted.from_html(formatted.to_html())
    formatted.to_weechat() == formatted2.to_weechat()