Send me a message when a viewer joins the channel

Is there a way to automatically notify me when a user joins a channel? I notice that the current events I can access is the message event. My understanding is there is no way I can implement this.

sample code being.

const notifier = require('node-notifier')

function onMessageHandler (target, context, msg, self) {
  if (self) { return; } // Ignore messages from the bot

  if (userJoinsChannel) {
  	  title: context['username'],
  	  message: commandName

There’s no accurate way to know when a user joins a channel. For small channels the join messages will be buffered so a person could be in chat for several minutes before they show as there, and for large channels (>1k users in chat) Twitch Chat stops sending join messages entirely.

There are undocumented endpoints to get the list of users in chat, but that is cached and so wont be very accurate either.

Also, depending on the purpose of your app you should be careful about what sort of user tracking you’re doing unless the user has opted-in to you tracking them.

thanks for the reply. the list of users is public data so i think thats fair game over there. I was going to use it to mess with my friends when they try to be sneaky and lurk in the channel.

Just because data is publicly accessible doesn’t mean you have any right to do with it as you please. It’s possible for a username to be classed as an ‘Online Identifier’, and so under the GDPR how you handle such data has to comply with those laws.

Also, Twitch itself has legal agreements including the Developer Agreement which lays out certain requirements when using the Twitch API. Of particular note (but not the only relevant setion) is XI.B Privacy Obligations.

ya. i will be more mindful with my code then.

I was only doing this cause Slack has an event whenever your friend starts typing in the DM to you so i created a bot to make the first move. I was trying to replicate something like that on Twitch, thats it.

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