Hey there, with the update of localized display names for korean, chinese and japanese, the display-names are no longer useful for identifying users. Before, in 99.99% of all cases you could just lowercase the display-name and get the nick, with which you can query the kraken-api for further details.
Now that the display-names differ much more often, this has become a big problem for detecting subscriptions. Initial subscriptions, unlike resubscriptions, don’t have a dedicated IRC event. Therefore the way to go until now is to parse the twitchnotify message. Unfortunately that message is useless for people with localized names:
:twitchnotify!twitchnotify@twitchnotify.tmi.twitch.tv PRIVMSG #twitchplayspokemon :僕はキメ顔でそう言った just subscribed!
Is there another reliable, fast way of detecting when someone subscribes to a channel?
I am aware that you could query the API endpoint at /channels/:channel/subscriptions each time someone subscribes, but that requires the user wanting to track the subscribers to have permission for the channel_subscriptions scope, which might not be the case.
Asking the team about this for you. Some APIs work with the extended character sets (e.g. /search/channels), but I see that some don’t. I’ll let you know when I hear from the team!
I don’t mind if they keep the priv message, if they include the user id of the subscriber as tags. Ideally tag for roomname + user like other locations.
Any word on this?
It’s pretty much impossible to know who is actually subscribing now if they have a “special” display name. Even with the hacky method of using search on each one there can be duplicate display names afaik.
Also, the new subscription message “USER just subscribed with Twitch Prime!” wasn’t caught by our regex and I had to manually insert the unrecognized subscriptions. We really need a proper way of handling those. Preferably the same way resubscriptions are handled.
// if bit 2 is to then we are in host mode
if (messageex[2] != 'to' && messageex[3] != 'to' && messageex[1] != 'viewers' && messageex[1] != 'viewer') {
Don’t use a regex.
Mine needed no changes since I take the string that TwitchNotify says and splits it around spaces.
var who = messageex[0];
Granted yes we need something better for initial subs. But a regex is unneeded here I feel.
The thing is I don’t want to accidentially match new messages in the future that might sound similar, something like “Xyz just subscribed to [Hosting channel]”. Your example is especially error prone to newly added twitchnotify messages.
I’d rather retroactively manually increase a subscription in the database than take it away.
This is the current code, using regex is perfectly fine and more idiomatic:
match = re.match(r"^(.*?) just subscribed( with Twitch Prime)?!\s*$", message)
if match:
return {"name": match.group(1), "months_in_a_row": 1}
So far it’s been rock solid. I had to do zero changes in order to deal with prime.
All twitchnotifys are new subscribers, with exclusion of the hosting specifics. So no need to parse for the count.
So my notification platform is solid. For anything use the subscribers API sounds like a better option for you for your database implementation, perhaps.