Bots such as moobot are connected to the chat through a pseudo-IRC called TMI (Twitch Message Interface).
Once connected to the TMI you can access a bunch of chat data, such as users, who’s +o (mods, broadcaster, staff and admins) and chat lines.
Extra data is sent when you connect and send the “JTVCLIENT” command (“TWITCHCLIENT 1” or “TWITCHCLIENT 2” might also work). (returned is USERCOLOR, SPECIALUSER and EMOTESET) It’s not entirely reliable but it works somewhat.