Pardon the stream thumbnail: I was broadcasting from my phone just to test and had it laying down on the camera.

One major feature of CouchBot that the Wombattery Community server is missing is the “go live” announcement feature for Twitch, Mixer, and YouTube.

API and I have a spotty history. For some reason, I have never been able to get my mind around OAuth; I understand the mechanics behind it, but implementing it has always been a real pain in my ass. But this time it seems that I’ve found the secret thread in the Twitch API that has allowed me to ping their servers and get an update on a Twitch channel’s live/not live status.

Currently, WomBot allows a user to specify her Twitch channel using the command

$profile set Twitch [TWITCH_USER_NAME]

When this happens, we ping the API endpoint which translates usernames into ID values. We have to do this because Twitch’s status is only returned by ID. Once we have this ID we store it with the user’s profile.

Every so often (currently set to 60 seconds, although I’m not sure what Twitch’s guidelines are for “minimum ping interval”) the bot collects only the profiles who have a Twitch ID (not the Twitch Username), and checks their channel status. We also have a flag that indicates if the user is online (true) or offline (false). If the flag is false and if we get JSON back from the API, the user is “online”. We update the flag to “true” and create and post the embed to the channel specified by the bot admin for receiving go-live messages. However, if the user’s flag is already set to “true” then we do not update the flag, nor do we post the embed. If the JSON from the API is “null” during our periodic checks, then the user is either offline or is no longer online, so we do update the flag to “false” if it is currently “true”. Whew! All of this is intended to only post the live notification once, and to reset that blocker once we determine that the user is no longer broadcasting.

Ultimately there will be some additional roadblocks linked to the XP/level system, where a user will have to reach a specific level in order to be included in the go-live check; they can still define their Twitch username, but we won’t check their online status until they have been around the server for a while, and have accrued enough XP through participation to ensure that we don’t have “dead-weight” members who only show up to pimp their stream without participating in the community. But first I have to set up Mixer and YouTube notifications and get the whole “streamer ecosystem” working with as few issues as possible before I wrap it in additional security.


Owner and author.

Leave a Reply

Your email address will not be published. Required fields are marked *