The Church teaches that anyone conscious of a mortal sin must receive the sacrament of reconciliation before receiving Holy Communion. If you know you are going to be in a position where you may commit a mortal sin, you need to make a conscious effort to avoid those situations that tempt you. The strength to resist sin and break our disordered attachments comes from 1) frequent reception of the sacraments (e.g., confession, Eucharist) and 2) a disciplined prayer life.
The Catechism of the Catholic Church says:
As bodily nourishment restores lost strength, so the Eucharist strengthens our charity, which tends to be weakened in daily life; and this living charity wipes away venial sins. By giving himself to us Christ revives our love and enables us to break our disordered attachments to creatures and root ourselves in him. (CCC 1394)