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