Stream Live Alerts

discord

#1

[Moved to Feature Requests by IllusionaryOne]

I realise this could just a much belong in the feature requests section, but I’m more curious as to the technical restrictions.

So yeah: What are the technical delays/restrictions on being able to post golive announcements in Discord for other streamers?

I’m trying to keep the number of bots in my server to a minimum (1). I could add mee6, but I’d be adding it solely for go live announcements, and if there is a realistic chance of PB doing this, I’d rather wait.


#2

I cannot think of any, per se. I mean, some sort of looping mechanism against the Twitch API would have to be created to check those streams – and stay within Twitch’s API limits. That is where the trick lies, I think. I mean, lots of bots just throw caution to the wind and just hammer the hell out of the Twitch API (even we do to a point - but you may have noticed we cache data from Twitch and reduced our calls a bit). That said, I would probably check streams every 30-60 seconds to see if they have gone live, but not more often.

My usual boilerplate statement aside about APIs and limits :slight_smile:

The /streams/ endpoint allows for a multiple list of channels to be checked for online status. However, remember that you must have their numeric ID now, and not the channel (user) name, so you would you want to cache the IDs of the folks that you want to lookup (PhantomBot does this) with the API call we provide to Twitch from our library — however you may consider a new call to check multiple users all at once.

Example:
https://api.twitch.tv/kraken/users?login=illusionaryone,cereth
{"_total":2,“users”:[{“display_name”:“IllusionaryOne”,"_id":“77632323”,“name”:“illusionaryone”,“type”:“user”,“bio”:“Name is IllusionaryOne. I’m thirty-something. Gamer. Software engineer. Anime consumer. Variety streamer.”,“created_at”:“2014-12-21T06:40:53.245504Z”,“updated_at”:“2017-07-06T05:00:23.058572Z”,“logo”:“https://static-cdn.jtvnw.net/jtv_user_pictures/illusionaryone-profile_image-f95071ec3378b35a-300x300.png"},{“display_name”:“Cereth”,"_id":"21292708”,“name”:“cereth”,“type”:“user”,“bio”:“Final Fantasy speedrunner [5, 6, 7, 9, 10, 13-2 and Crystal Chronicles]”,“created_at”:“2011-03-22T12:20:34.110453Z”,“updated_at”:“2017-07-09T16:35:23.637162Z”,“logo”:“https://static-cdn.jtvnw.net/jtv_user_pictures/cereth-profile_image-7a7956cd05f42991-300x300.png”}]}

https://api.twitch.tv/kraken/streams?channel=77632323,21292708
{"_total":1,“streams”:[{"_id":25708911472,“game”:“Final Fantasy V”,“broadcast_platform”:“other”,“community_id”:“848d95be-90b3-44a5-b143-6e373754c382”,“community_ids”:[“848d95be-90b3-44a5-b143-6e373754c382”],“viewers”:187,“video_height”:720,“average_fps”:60.0100857287,“delay”:0,“created_at”:“2017-07-09T15:01:48Z”,“is_playlist”:false,“stream_type”:“live”,“preview”:{“small”:“https://static-cdn.jtvnw.net/previews-ttv/live_user_cereth-80x45.jpg",“medium”:“https://static-cdn.jtvnw.net/previews-ttv/live_user_cereth-320x180.jpg”,“large”:“https://static-cdn.jtvnw.net/previews-ttv/live_user_cereth-640x360.jpg”,“template”:“https://static-cdn.jtvnw.net/previews-ttv/live_user_cereth-{width}x{height}.jpg”},“channel”:{“mature”:false,“status”:"!4JF | Pure Chaos 4 Job Fiesta! | SMN/NIN/BER/THF (SNES)”,“broadcaster_language”:“en”,“display_name”:“Cereth”,“game”:“Final Fantasy V”,“language”:“en”,"_id":21292708,“name”:“cereth”,“created_at”:“2011-03-22T12:20:34.110453Z”,“updated_at”:“2017-07-09T16:35:23.637162Z”,“partner”:true,“logo”:“https://static-cdn.jtvnw.net/jtv_user_pictures/cereth-profile_image-7a7956cd05f42991-300x300.png",“video_banner”:“https://static-cdn.jtvnw.net/jtv_user_pictures/cereth-channel_offline_image-856c928b10ac6203-1920x1080.png”,“profile_banner”:“https://static-cdn.jtvnw.net/jtv_user_pictures/cereth-profile_banner-c46cfb408f8488b6-480.png”,“profile_banner_background_color”:"",“url”:“https://www.twitch.tv/cereth”,“views”:4952415,“followers”:51549,“broadcaster_type”:"",“description”:"Final Fantasy speedrunner [5, 6, 7, 9, 10, 13-2 and Crystal Chronicles]”}}]}

Note that the endpoint only returns live channels by default, hence why only one record came back (I am not online).

Hope that helps. Yes, it is possible, but, need to work within the constraints of how often Twitch wants us hitting the API and using caching of data effectively to reduce the number of hits.

Cheers


#3

OK cool. So it is possible, just not yet implemented. :smiley:

Now’s the bit where I ask if it can be moved to Feature Requests? Just because I said I wouldn’t. Also new forums and it’s not already there.


#4

So, since I managed to sneak this into feature requests, I’ve been thinking about how/what I’d like to see. Obviously this may not be possible, or I might just need to duplicate a module once it’s done or something, but I’ll just dump the words here and see what comes of it.

Aside from the obvious things of being able to create a list to get called out, I’d quite like to have the announcement be separately customisable between the owner/main broadcaster and other people.

If at all possible, based on my ideas and what I have in mind, I’d like it to have two different groups, so that I could set one announcement type for some streamers, and a different announcement for the others. This might end up involving me having to duplicate the module, but that’s fine.

Ideally, I think the best way to do this would be to have customisable announcements for each channel targeted, though I’ve no idea if this would be practical. Based on what I understood of the earlier technical post, it would be a separate check for each channel, which I think means you could have a separate response for each as well, but I defer to those who actually understand coding.


#5

Currently working on this, the code is mostly done and on github, the user will probably have to specify the channel id though, since it will save us a few API calls.


#6

Cool. I don’t suppose we could get instructions on how to do this? Or a command perhaps? !getid [channelname] I don’t know. :smiley:

But yeah, looking forward to this a lot.


#7

There are sites for this, like https://www.twitchtools.com/channel/lirik you just look under account unique id.


#8

OK cool :smiley:


#9

I’ll see how I code the module, maybe I’ll make it auto grab it and cache it in the database.


#10

I’m happy to grab the ID if needed myself. Just thinking of those who won’t want to do that. :smiley:


#11

So, I’ve been thinking about this for a while, and rather than start a new topic, I thought I’d update this one. This is from an end user point of view, not a backend angle, because I can’t technical at all.

Given that we already have the account link function, I would ideally see it have something like !account live on/off randomstreamername, so that we can turn on notifications for users.

Alternatively, it could be self-activated, so it would look more like !account live on/off, and it would activate your own shoutout.

This could also possibly be done with both of these functions. Hoping this makes sense.


#12

Sounds reasonable until Helix becomes the default. The streams endpoint is rate limited. You will get (by default) 30 queries in a minute - that includes the need to query your own streams endpoint to see if you are on/offline. That amount, in theory, may be allowed to be 120 queries, but that depends upon the type of query being made. So, in theory, to continue to support your own queries, and provide for others, you could pick, let us say, 14-30 people so you can query enough for yourself as well – assuming you still want Helix to pull data for other relevant parts of your stream – followers, subscribers, stream up/down, followage, clips, … you get the idea. Also, we would have to query to get the ID from their username (unless it is already cached) - there are potentially 2 queries per user at least once.

Here is a query in Helix to determine if I am on/offline…

< Ratelimit-Limit: 30
< Ratelimit-Remaining: 29
< Ratelimit-Reset: 1515130185
< Twitch-Trace-Id: 365a078733296702776cef72ba764481
< X-Ctxlog-Logid: 1-5a4f0d0e-7dce31a5439119f114eae639
< Front-End-Https: on
< Timing-Allow-Origin: https://www.twitch.tv
< Date: Fri, 05 Jan 2018 05:28:46 GMT
< Content-Length: 27
< Connection: keep-alive
< Set-Cookie: AWSALB=jsBLQ91SMRk+s8SVU9Yn9uJXOqk7nnYng01ZJ+BT++5wfsQD3SfQzQVEtRPTYr68e4c0j+ndGKYKjEpSvqdwFiYQJ8WZqrRG6qIxpuWxkh+xv4C481PAoZYrveGu; Expires=Fri, 12 Jan 2018 05:28:46 GMT; Path=/
<

  • Connection #0 to host api.twitch.tv left intact
    {“data”:[],“pagination”:{}}

Note the rate limit? 29 remaining? Helix will be much more interesting than what we are used to with the v5 API.

We are going to look at migrating to Helix probably middle of the year – we want to give Twitch plenty of time to get the APIs from v5 ported over that we need and give them time to shake things out. We also need to architect in paying attention to the rate limit and time that it is refreshed to either queue up or dispose of queries to Twitch. Once we move, get ready for much tighter rate limits, unfortunately. Then, at the end of the year, v3 and v5 are going away. So, even if we try to cling to them, we have a date already on the tombstone from Twitch.


#13

Sounds good. I don’t think there’s more than 10 people I’d want to add, if that, so that would be fine.

Shame about the rate limits, I guess, but if it doesn’t catch fire on a regular basis, then a fair tradeoff. :stuck_out_tongue:


#14

The API does allow you to do multiple queries, up to 100 in one call, but that really isn’t well documented anywhere except for helix if I remember right. I’m sure hoping that helix will have better features and endpoints than v3 and v5, but as of right now it’s not too promising. :stuck_out_tongue:


#15

This is something I’d love to have as well. If I could oust the unreliable Now Live bot, that would be great. I have a handful of friends I’d like to announce in my Discord when they go live so this would be perfect.

Is there an ETA for this? Or maybe a WIP module we could check out?

Cheers!