How to test Follow Alerts

How does one test follow alerts programmatically without making multiple twitch accounts and following the channel that is being tracked?

I am trying to test this in Unity with the Helix API.

You can simulate the data within your program. Whether that’s inserting a test account with whatever necessary data (current timestamp or random name/id) before the original list or just calling the alert code with fake data.

Let’s say you have some way to get and return data.

function getAPI(endpoint, qs) {
    return new Promise(/* ... */);
}

function getLastFollows(to_id) {
    return getAPI('users/follows', { to_id });
}

You could create a separate temporary function or just add on to the original. You could even rename the original function slightly and reuse that name for the temp function.

function getLastFollowsFAKE(to_id) {
    return getLastFollows(to_id)
    .then(json => {
        // Generate a random ID or a specific one that's not already following.
        let from_id = Math.floor(Math.random() * 1e7 + 1e6).toString();
        let followed_at = new Date().toISOString();
        json.data.push({ from_id, to_id, followed_at });
        return json;
    });
}

However your system is set up to detect new follows, you will need to get the original data and then use the spoof function for a random user to trigger the alert.

Initialize real data

let channelID = '';
let seenList = [];
function init() {
    getLastFollows(channelID)
        .then(json => seenList = json.data.map(n => n.from_id))
        .catch(handleError);
}

Get fake data when it’s time to check.

function update() {
    getLastFollowsFAKE()
        .then(json => {
            let newFollows = json.data.filter(n => seenList.includes(n.from_id));
            if(newFollows.length) {
                newFollows.forEach(n => queueFollowAlert(n.from_id));
            }
        })
        .catch(handleError);
}
1 Like

Pull lirik’s channel whilst Lirik is live…

Pull ANY large channel whilst the channel is live…

1 Like

Thanks guys, two good answers to the problem!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.