Generalised twisted partition functions