Subscriber Alerts

How to get live subscriber alert, host alert, follower alert?

1 Like

I don’t get your question.

Subscribers you can poll chat for it.
Host you need to poke the undocumented host API for the information, or poll the broadcasts chat.
Followers you can poke the Twitch API here: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#get-channelschannelfollows

Hi Barry,

Basically I want to get alert notification each time any user follows/subscribes particular streamer at twitch.tv.

I think I described all the sources for the data in my previous post.

This is the developers forum for building things. If you are not planning on building it yourself, you’ll need to find someone to build it for you, or use something prepackaged like TwitchAlerts or similar.

Hi Barry,
Hope this is the right place to ask about this, but essentially I’m creating a subscriber alert for a partnered caster. Regarding that GitHub link you posted, how will I go about implementing this into Adobe Edge Animate (which I’m using for the alert because it has a coding environment as well as the HTML animation.)?
I’ll obviously have to speak to him about testing the alert as I’m not a partnered caster myself, so testing it is slightly harder.

Thanks in advance,
Mike

No idea. I know nothing about Adobe Edge Animate

Ah, thanks anyway. I’ve developed a twitch bot (MadGamerBot, you may recognise the name from a different forum post) in Javascript (NodeJS), so I imagine it shouldn’t be too much harder. If so, would you recommend the Adobe forums instead, where people are familiar in that field?

Cheers

This tutorial explains how to use Ajax in Adobe Edge:

Instead of using the local file ajax.php, you need to use the url provided by @BarryCarlyon. Check out this thread for a code example:

1 Like

Thanks for the link, I appreciate it. Just one thing, how can I tailor this to create a subscriber alert to go off when someone actually subscribes? That link appears to only give the last subscribers.

Thanks in advance,
Mike

check the endpoint for “last subscribers” and cache/save the id.
check again in a few intervals.
if the “last subscribers” id has changed show alert and cache/save the new id.

hopefully that makes sense.

Thanks for the help, I was thinking of using that sort of function for it, it’s the same sort of thing I used for donation alerts where a chat bot would announce in chat when there’s a new donation.

Thanks again :smile:

[Edit]
For the list of subscribed users, it requires an OAuth. Does that need to be the channel owner, or can it be my OAuth too? (The subscriber alert is for someone else)

Channel owener

you can also scrape the chat for messages from “twitchnotify”.

[message in madmikegamerxl1's channel]
twitchnotify: nate just subscribed!
twitchnotify: nate subscribed for 13 months in a row!
twitchnotify: 13 viewers resubscribed while you were away!

[message in channels hosting madmikegamerxl1's channel]
twitchnotify: nate just subscribed to madmikegamerxl1!
twitchnotify: nate subscribed to madmikegamerxl1 for 13 months in a row!

Edit: added some info from my logs.

Oh great. Thanks @george
And thanks nate , looks like that’s the only way. Isn’t there a way to connect to chat without needing my bot’s username or OAuth? I’m sure I read something like “justinfan” or something along those lines. Does this still work?

If i remember correctly, you can connect to the irc chat using NICK justinfan(random number)' and random string as the PASS.

ex.

NICK justinfan1337
PASS kappa

Ah thank you. I’ll try that this afternoon when I finish at college :smiley:

Adobe edge seems to only natively support javascript, so you could use the chat’s websocket servers which you can find here:

http://api.twitch.tv/api/channels/{channel here}/chat_properties

Normal TMI (“IRC”) protocols apply.

Thanks for the help! I managed to get it working with websockets and the “justinfan” nick.

Just one thing, I’m having problems with it checking the message. I have it set up with a substring to get the message that was typed, and logs that in the console. That works. However, I have an “if” statement checking if the message is equal to a certain value, and if it is, log a different message in the console. In my case, I had it set to something random, which was “1234”. Here’s my Javascript code (or the chunk of it related to the message).

else {
    var message = event.data.substr(event.data.indexOf('#madmikegamerxl1 :') + 18);
    if (message.toString() == "1234") {    // I've also tried without the "toString()" 
        console.log("Someone just subscribed!");
        AdobeEdge.getComposition("subAnim").getStage().play("subalert");
        AdobeEdge.getComposition("subAnim").getStage().play("Stage");
    }
    console.log("Message received in chat 'madmikegamerxl1' : \r\n" + message);
    
}

(the Adobe Edge bit doesn’t matter right now, it’s just the fact it’s not logging the “Someone just subscribed!”)
Here’s the log of what’s happening in chrome:

:madmikegamerxl1!madmikegamerxl1@madmikegamerxl1.tmi.twitch.tv PRIVMSG #madmikegamerxl1 :1234
Message received in chat 'madmikegamerxl1' : 
1234

Any ideas guys?
Thanks again for all the help.

The last character of any IRC message is a line break, or the equivalent of \r\n. Easier than to always compare to that character would be to simply strip the last character and compare to the remainder.

I understand that this is a work in progress, but I suggest you build a more robust tokenizer. You could use splitting, as in Twisted or simple iteration. The tmi protocol is detailed in IRC.md. If you prefer a brebuilt library there are many for IRC and tmi.js for Twitch specifically.

Thanks very much!
I actually use tmi.js for my actual Twitch bot (work in progress also). I just wanted to avoid including NodeJS along with the file for a sub alert.

However, if I used tmi.js, it has listeners for subscribers and subbiversaries built in, right? That’d be a much simpler way to write it.
When I go to send this to the partnered streamer I’m making it for, which files relating to Node should I include?