The post Oded linked to seems to sum up what I think is the best thing we can do.
What's the official SE response to serious mentions of suicide in posts?
I have seen similar issues myself on a Stack site, and while not outright admitting "suicide" or other concerns, it is sometimes worrying to see other "people" (not "users") having what seems to be, or could be, some serious troubles.
The difficult thing about this activity being "online" is it's hard to read people properly.
They might just be trolling, or mentally stable but have a personality trait which makes them over exuberant or perhaps just don't have a friendly/positive writing style (etc).
It's really hard to know with text, and no facial expressions or bodily movement etc.
You do have to read carefully, however.
We all enjoy helping people with code and other questions within the scope of the sites, but to be able to do that we have to be knowledgeable.
For example a user new to PHP could not correctly advise on OOP factory pattern - their advice will be missing some important information or even just lacking in important considerations.
They may not know that, however, and go on to tell someone how to approach factory pattern, and someone ends up with a poorly arranged application as a result.
And the same is with all professions, but with mental health one has to be much more careful because it's not just someone's PHP script which doesn't work. The nature of mental problems means the potential outcome which could occur if handled incorrectly could be serious.
So with something like a potential mental health situation, unless trained and experienced in that area of expertise, we are simply not equipped to be trying to advise, so have to be very careful with what we say.
Maybe saying "You need to speak to XYZ group and get some support" is ill received and could have a negative outcome.
Of course, that's all we can do, but my point is keep is simple and don't so much "try to help" other than some basic advice and try to get them to consider speaking to someone else.
I have some experience with mental health issues from a family friend, and while I'm in no way very knowledgeable, I can say from a slightly experienced stand point, that while the words you are giving out seem kind and you might be giving a glimmer of hope or light to someone, might actually be detrimental and cause harm.
I know that might sound wrong, but without complete knowledge we can fall into something like the Dunning–Kruger effect, where we believe we're giving out good advice, but in fact there is something important that we do not know we don't know.
Some people with mental health issues can be in denial, as many of us are with most negative traits. And this means trying to persuade them to "seek help/advice" makes them not only deny they need it, but frustrates or even depresses them further from a conflict in their mind.
One really does have to tread carefully.
But again, we have the choice of ignoring it and leaving it, or trying carefully to give them some kind advice to go talk to someone - and I think the latter is probably best as long as it's simple and not given with any of our own "personal advice" on the matter.
It's also nice to see you care, and even post a question about it.