I am using tmi.js and i need it so that every time a subscriber joins channel i greet them
And what exactly are you having problems with?
You could poll the undocumented chatters endpoint tmi.twitch.tv/group/user/<ChannelName>/chatters
to look for new users, when there are new users in the channel check if they are subscribed using the https://api.twitch.tv/kraken/channels/<channel ID>/subscriptions/<user ID>
endpoint (https://dev.twitch.tv/docs/v5/reference/channels#check-channel-subscription-by-user) and then if they are send the greeting.
Personally though I wouldnât recommend using a feature like this for many reasons, such as some users just like to lurk in a channel and not be announced when they join, the bot might spam a lot if a lot of subs join at once so you would need to limit/queue the greetings so your bot doesnât exceed the limit and get a temp ban, and if you have subs rejoining frequently that will potentially be a lot of API requests unless you also implement caching on your end.
Thank you. Iâll try it and close this if it will work
Dist is correct. That is the best option⊠But as he also said, a lot of viewers donât want announced when they join. I tried a similar system before and it was complained about constantly. While it is a fun idea possible make it toggleable per sub.
I got it to work, but now it returns giberish (probably gzip encoded) and i donât know what to do!!!
Does the channel your testing this with have a subscription program (ie, an affiliate or partner)? When I tested requesting the subscriptions of a channel without a subscription program I noticed an encoded response (which really can just be ignored due to the status code).
Same thing happens if you do not have a proper OAuth either, doesnât it? I swear when I messed up a copy/paste into curl before that I got back gibberish. I wonder if this person doesnât a registered OAuth for the channel with proper permissions? Or isnât passing the proper Authorization header, something like that perhaps?
EDIT: Yes, definitely, checking my own subscribers:
[morpheus] /opt/iobot2
illusion% curl -H âAccept: application/vnd.twitchtv.v5+jsonâ -H âClient-ID: asdfâ -H âAuthorization: OAuth wrong_keyâ -X GET https://api.twitch.tv/kraken/channels/77632323/subscriptions
Q??Y
?A
?@
Đ«???t?x?^ vRâPH??(???>Ț53?g?G>?5u?? ???r???U?Ôł,]i?? ??X8Y??-?5?" ??5???R<=?f
[morpheus] /opt/iobot2
illusion% curl -H âAccept: application/vnd.twitchtv.v5+jsonâ -H âClient-ID: asdfâ -H âAuthorization: OAuth right_keyâ -X GET https://api.twitch.tv/kraken/channels/77632323/subscriptions
{"âŠubscriptions":[{âcreated_atâ:â2017-08-23T05:11:52Zâ,"_id":"6338da7fc4a4d
@Rusty-b0lt do you have an OAuth with the channel_check_subscription scope for the channel as outlined in the Twitch docs you were referred to?
maybe i have an oauth without the flag that i need, i use this ihttps://twitchapps.com/tmi, it works, âwhich really can just be ignored due to the status codeâ - what is status code and how do i get it (the channel doesnât have a subscribtion program)
I donât use tmi.js for API stuff myself, but it it passes the response as well as the body back in the callback, then you can look at res.statusCode
.which will give you the status code of the request.
If the OAuth doesnât have the correct scope for the channel and endpoint youâre requesting youâll get a 403
back, indicating The current authorization is not valid for this context
. If itâs a 422
then for the subscription endpoint thatâll mean the channel doesnât have a subscription program (and so you canât check for the subscribers list or a specific users subscription because there is no subscription program to check).
If everything worked you would have gotten a 200
status code and then gone on to parse the body.
Thank you i got an 422, this is closed
I suggest against using tmi.js
's .api
stuff. Use request
directly in some form on Node. (I think this is a Node project anyways.)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.