Yes, exactly, the jokes were in the moment, and an hour later it was all gloomy again.
The short story is that I basically filled in countless CBT sheets, spotting distortions and correcting my thoughts. And at some point it started to sink in.
As an example, one of the distortions I noticed in my thoughts was "should-ing" myself in the foot: "I should be X, they should be Y and world should be Z". And because I'm not X, they are not Y and world is not Z, it's all hopeless". A more realistic though would be something like: "It would be cool if I were X, they were Y and the world would be Z, but right now it's not like that and frankly, so what? The sun is still shining, birds are still flying, so it cannot be all bad, can it?". This might be a trivial example, but if you pile up dozen patterns like that then it starts to make a difference.
The long story is that I didn't know what to do, but I somehow managed to find the "Feeling good" podcast by a big CBT name dr David Burns, started to listen to it, then a friend bought me a book "Feeling great" by the same author (I literally couldn't force myself to buy it, I think because I was afraid that if it doesn't help me then it means I'm a hopeless case, or something like that...) and then I started filling in all those sheets. Sometime later (like a few weeks, maybe 2-3 months), I noticed I feel better, and it was an upwards trajectory since then. I guess at some point I "platoed", but I feel pretty good these days so I don't mind :)
At some point I was also taking pills, but I didn't feel any difference. Whereas filling in those sheets gradually made me feel better and better.
There was also a related anxiety, which I managed to greatly diminish through exposure (it's still there to some extent, but these day I can just acknowledge it and move on). I think the anxiety exposure also helped for depression, as when I learned that most people are really nice, I started to think that maybe things are not that bad and hopeless either?
(Sorry if the whole post is a bit chaotic, it's late here and I admit I didn't bother to edit it too much.. But I hope it's still at least somewhat useful.)