Once you have encountered a spiritual battle and you were successful in averting any sinful act, give thanks to the Lord. But, do not be over joyful as this can lead to you to complacency and even lead you to a greater sin of vainglory. Assume that there may be an ambush laying around the next corner. Do not share this victory with anyone. Remain humble and ready for another battle.
If you were not successful and succumbed to the temptations presented, humble yourself. Fall into repentance immediately. Accept that God knows that you will not aways be successful and is always merciful if you remain humble and repentant.
Saint Theophan says,
"Our Lord is like a mother who leads her child by the hand and does not abandon him..."
Repeated failures should spurn you to engage in greater ascetic labors. Look for new strategies, new ways to avoid such situations. The worst thing is to become stopped by any form of depression over your failure.
Remember everyone has a different task––will face different spiritual battles of differing degrees. We all have a central tendency for sin but it is different for each of us. Saint Theophan assures us,
"One only needs to have the zealous desire to conquer himself."