@staticmethod<EOL><INDENT>def from_data(room, conn, data):<DEDENT>
files = list()<EOL>rooms = dict()<EOL>msg = str()<EOL>for part in data["<STR_LIT:message>"]:<EOL><INDENT>ptype = part["<STR_LIT:type>"]<EOL>if ptype == "<STR_LIT:text>":<EOL><INDENT>val = part["<STR_LIT:value>"]<EOL>msg += val<EOL><DEDENT>elif ptype == "<STR_LIT>":<EOL><INDENT>msg += "<STR_LIT:\n>"<EOL><DEDENT>elif ptype == "<STR_LIT:file>":<EOL><INDENT>fileid = part["<STR_LIT:id>"]<EOL>fileobj = room.filedict.get(fileid)<EOL>if fileobj:<EOL><INDENT>files += (fileobj,)<EOL><DEDENT>fileid = f"<STR_LIT>"<EOL>msg += fileid<EOL><DEDENT>elif ptype == "<STR_LIT>":<EOL><INDENT>roomid = part["<STR_LIT:id>"]<EOL>rooms[roomid] = part["<STR_LIT:name>"]<EOL>roomid = f"<STR_LIT>"<EOL>msg += roomid<EOL><DEDENT>elif ptype == "<STR_LIT:url>":<EOL><INDENT>msg += part["<STR_LIT:text>"]<EOL><DEDENT>elif ptype == "<STR_LIT>":<EOL><INDENT>msg += html_to_text(part["<STR_LIT:value>"])<EOL><DEDENT>else:<EOL><INDENT>import warnings<EOL>warnings.warn(f"<STR_LIT>", Warning)<EOL><DEDENT><DEDENT>nick = data.get("<STR_LIT>") or data.get("<STR_LIT:user>")<EOL>options = data.get("<STR_LIT>", dict())<EOL>data = data.get("<STR_LIT:data>", dict())<EOL>message = ChatMessage(<EOL>room,<EOL>conn,<EOL>nick,<EOL>msg,<EOL>roles=Roles.from_options(options),<EOL>options=options,<EOL>data=data,<EOL>files=files,<EOL>rooms=rooms,<EOL>)<EOL>return message<EOL>
Construct a ChatMessage instance from raw protocol data