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)
}
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
}
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