A retired police officer snared by “paedophile hunters” after sending depraved messages to a teenage girl has been spared jail.