In particular, one element of the hacker mindset is not wasting any time saying, "But it doesn't make sense!" It was very useful to me to accept that my body and brain was a meat-robot built by genes so they could get around in a hostile environment. My moods were just part of a poorly-balanced control system.
I didn't have to have a narrative reason for feeling sad. It could just be, say, part of a system for keeping me indoors when the weather was bad. If refined sugar threw off my mood regulation, well no surprise. It wasn't part of my evolved diet. The only reason I was eating a lot of it was foods engineered to maximize purchase frequency while minimizing cost. If other people were hacking me, I certainly could hack back.
Once I gave up the expectation of narrative sense, it became just another experiment-driven systems-tuning exercise. And hackers are good at that.
I cut out refined sugar from my diet and started taking turmeric in the form of golden paste (as a natural cure for tendinitis) a couple f months back. I noticed an improvement in my mood and outlook as a pleasant side effect.
You need the strength and courage to seek therapy and then stick to it. Sometimes therapy takes years and the result is not guaranteed. And when you're in the worst possible place mentally, trying to go to therapist and then trying to open up to him is incredibly tough. And then you have to keep doing it again and again and again.