"How do we know if thoughts come to us from God, or from the devil? What should we do if thoughts of our failings and sins are presented to us? The Fathers give a simple rule: if the thought of a past failing discourages us to the point of depression, draining all our energy and zeal, tempting us to quit every struggle for virtue, or to remain complacent, it is from the devil. If, however, the sorrow such a thought brings gives us a desire to change, energy to repent, fast, pray, forgive, etc., it is from God. St Paul himself talks about these two sorrows: one which is worldly, and brings death; one which is godly, and brings zeal and energy to change (2 Cor 7:10)."
- Hieromonk Calinic (Berger)
Reference: http://www.pravmir.com/guarding-the-thoughts-guarding-the-heart/