It was narrated that Abu Hurayrah (may Allah be pleased with him) said: I heard the Prophet (peace and blessings of Allah be upon him) say: “A person committed a sin and said: ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave.’ Then as much time passed as Allah willed, then he committed a sin and said, ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave.’ Then as much time passed as Allah willed, then he committed a sin and said, ‘My Lord, I have sinned; forgive me.’ His Lord said: ‘Is My slave acknowledging that he has a Lord Who forgives sins and punishes for them? I have forgiven My slave,’ – three times…” [al-Bukhari, Muslim].
Al-Nawawi (may Allah have mercy on him) included this hadeeth (narration) under the heading: “Acceptance of repentance from sins even if the sins and repentance happen repeatedly.”
Ibn Abi Dunya narrated with his isnaad that ‘Ali said: “The best of you is every tempted one who repents (i.e., every time he is tempted by this world, he repents).” It was said, “What if he sins again?” He said, “He should ask Allaah for forgiveness and repent.” It was said, “What if he sins again?” He said, “He should ask Allaah for forgiveness and repent.” It was said, “What if he sins again?” He said, “He should ask Allaah for forgiveness and repent.” It was said, “For how long?” He said, “Until the Shaytaan is defeated.”
It was said to al-Hasan: Shouldn’t one of us feel too shy to ask his Lord to forgive his sin, then do it again, then ask for forgiveness, then do it again? He said: The Shaytaan wishes that you would have this attitude, so do not tire of asking for forgiveness. And it was narrated that he said: I do not think this is anything other than the attitude of the believers, i.e., every time a believer sins, he repents.
Do not feel that you cannot seek forgiveness after sinning again. This is from the whispers of Shaytaan; he wants you to feel hopeless, and that Allah will not forgive you. Remember what Allah :swt: says in the Qur'an, Say: "O My servants who have transgressed against themselves! Despair not of the mercy of Allah, verily, Allah forgives all sins. Truly, He is Oft-Forgiving, Most Merciful." (53) "And turn in repentance (and in obedience with true faith) to your Lord and submit to Him before the torment comes upon you, (and) then you will not be helped.