Almost relapsed for the stupidest reason

It's my day 355 nicotine-free, and most of the time I've been handling it well. After the initial cravings stopped, I wanted a cigarette just two times: when I was doing an annual tax report, and when my significant other was throwing a tantrum over, well, everything. He later left me, and I didn't want a cig. And all the reality of living in a war-torn country didn't make me wanna smoke either. And yet, I almost consumed nicotine a few days ago. Still didn't want it, but my friends were passing a joint (half tobacco) at a party, and I thought well fuck it, I feel too lonely to not take it. I didn't even want weed that much, I was just feeling isolated. I was ready to reset my tracker, losing all the progress, and to fight the little nicotine demon in my head, and so on. Thankfully, my bestie talked me out of it, so, yep, today is day 355. But hell, I just feel like an idiot. Here I was, thinking I was smart, or strong-willed, or whatever, and still I almost relapsed. Ugh.