A general class of spreading processes with non-Markovian dynamics