It assigns a sentiment score based on a large bag of words. I'm making improvements to it each day, and it's slowly getting better. Terrible at picking up sarcasm though, but I think most sentiment analysis tools are.
The Twitter API lets you search by mood, I would assume it's just passing those along.
AFAIK that is an emoticon based thing, not real sentiment analysis.