Blasman commented on a Page, JSON for MIRC  -  Nov 21, 2015

I really like this script and it has been very useful for my bot that I use on Twitch. However, I seem to be having an issue. The problem is that about 1% of the time, the name returned will either be blank or it will be the name of someone who previously had their name retrieved from the JSON. I use this code for getting the proper display name from Twitch, as IRC has everybody's name in lower case and this script is the only way that I know of of how to get the proper case sensitive display name. Is there something that I could change to get it to work 100% of the time, or is this just a Twitch issue, or something else? I use $twitch_name(name_to_retrieve) to get the proper name. Thanks.

alias twitch_name {
JSONOpen -ud twitch_name https://api.twitch.tv/kraken/channels/ $+ $1
return $json(twitch_name, display_name)
}

SReject  -  Nov 21, 2015

this is, most likely, a twitch issue. Though you could most likely try to manually close the json handler at the end of your twitch_name alias.

Though you can get a user's display name, if you receive message tags, (CAP REQ :twitch.tv/tags) via $msgtags(display-name).key at the time of them sending a message

Blasman  -  Nov 21, 2015

Thank you for the quick reply! I did not know about the $msgtags thing, and that seems to be working at the moment. I'll try getting the names that way for now. :)

Blasman  -  Nov 29, 2015

Well, almost immediately after posting my last message, I learned fast the limitations of trying to use the $msgtags. It's a bad idea and only works in specific situations. I did however figure out a basic "workaround" for getting my twitch_name alias to work. I tested this by using "$twitch_name(name1) $twitch_name(name2) $twitch_name(name3) " on the same line with and without the workaround. Without the workaround, it would always display the name for "name1" for each name. With the workaround, it displays everybody's name.
alias twitch_name {
if %tn = 1000 { %tn = 0 }
inc %tn
JSONOpen -ud twitch_name $+ %tn https://api.twitch.tv/kraken/channels/ $+ $1
return $json(twitch_name $+ %tn $+ , display_name)
JSONClose twitch_name $+ %tn
}

ProIcons  -  Dec 01, 2015

if (%tn == 1000) %tn = 0

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.