I reviled Islam on many occasions, Allah forbid, but when I repent he (the devil) says to me: you were angry and you did not do that deliberately. Then I doubt myself: Was I angry or not? Was it deliberate or not? What should I do?
Reviling Islam is kufr (disbelief) and apostasy from Islam, according to scholarly consensus. The one who does it has to repent to Allah sincerely, by regretting what he has done and resolving not to go back to it. If he repents, Allah will accept his repentance. Allah, may He be exalted, says (interpretation of the meaning):
“Say: O ‘Ibadi (My slaves) who have transgressed against themselves (by committing evil deeds and sins)! Despair not of the mercy of Allah, verily, Allah forgives all sins. Truly, He is Oft‑Forgiving, Most Merciful.”
It was narrated from Abu Moosa (may Allah be pleased with him) that the Prophet (peace and blessings of Allah be upon him) said: “Allah holds out His hand at night to accept the repentance of those who have sinned during the day, and He holds out his hand by day to accept the repentance of those who have sinned at night – until the sun rises from its place of setting.” [Muslim]
You have to repent and do a lot of righteous deeds. With regard to thinking about whether this was done in a state of anger or not, this comes under the heading of waswasah (whispers from the shaytan), who wants to divert you from repentance or weaken your fear of Allah and your efforts to do righteous deeds. If you understand the abhorrent nature and seriousness of what you did, this impels you to strive to do good and to instil in your heart humility before Allah; it makes you pin your hopes on His grace, kindness and pardon. But if your nafs (self/ego) makes falsehood attractive to you and detracts from the seriousness of the crime by claiming that it happened in a moment of anger, then this will weaken your resolve and distract you from turning to Allah.
It should be noted that anger is not an excuse in all cases; rather the anger that may excuse a person is anger in which he loses his ability of discernment to the extent that he does not know what he is saying. If this happened once, it does not happen repeatedly. Many of those who have the problem of reviling Islam could never revile their fathers or someone they hold in high esteem or the father of an opponent in an argument and the like, no matter how angry they become, but they do revile the religion because their hearts are devoid of faith and they are lacking in respect towards Allah, His Messenger (peace and blessings of Allah be upon him) and His religion. We ask Allah to keep us safe and sound. If there was any faith in his heart it would prevent him from reviling religion.
So ignore this waswas (whisper). You have committed a grave sin, but you have a Lord Who is Most Merciful, Most Generous, Who accepts the repentance of the one who repents, forgives sins, and replaces evil deeds with good deeds. So prepare to strive hard, fill your heart with veneration and respect towards Allah, may He be exalted, and His religion, read a lot of the Quran and do a lot of righteous deeds.
We ask Allah to accept your repentance and forgive your sins.
And Allah knows best.