emiliobool/node-red-contrib-twitch-chat

Will there be an update?

Opened this issue · 25 comments

Was curious if you was going to update this with the new Point system twitch has added. also its been working amazing so far <3

Hey @JuniorGamingTime so the upstream library being used is tmi.js I'm not sure if they have updated it yet, but I would have to update it on my side to use any new features.

I noticed you opened/closed an issue the other day regarding the doc links being broken, and it seems they never fixed those , so I'm not sure if the library is still actively being worked on or not, since it has been semi abandoned a few times in the past.

Anyway, I just checked and it seems this node is on tmi.js 1.4.2 and they have already released 1.5.0, so I'll check what has changed and update accordingly.

I don't think they have added anything for the new points thing but something you can do with the current version (and future versions) is to use the "Raw_message" node, that should let you see the raw messages as they are received, but, you will need to inspect some messages in order to figure out what to listen to.

Yes I tried that but it looks the same as a normal message.
And this is the docs I've been using.
https://github.com/tmijs/docs/blob/gh-pages/_posts/v1.4.2/2019-03-03-Events.md#action

And one too say again thanks for your hardwork, my chat loves the light show that happens when people follow, sub and all those things. And also do to the Chat node they can control lights in my from chat. SORRY DIDNT MEAN TO CLOSE

I updated tmi.js to version 1.5.0. It seems the docs haven't been updated to newer versions but I still switched the links to the github links, the only 2 new nodes I found were 2 new events "primepaidupgrade" and "automod", not sure if I missed anything else new.

I haven't updated my node red instance but it is already on npm and I think it should work fine but I haven't tried it.

Also if what you are looking for is a way to detect when someone has redeemed something the chat will miss most of them, (except for the highlight ones), the better way of doing it is using the pubsub api.

I'm not sure how comfortable you feel about programming but you could do it within node red, all you have to do is connect via websockets to the pubsub server (more info: https://dev.twitch.tv/docs/pubsub) and you need to use the topic "channel-points-channel-v1.xxxxx" where you would change the xxxx to your channel id, and you also need to provide your oauth token.

I thought this was a private API but I just noticed they have updated their docs so it should be safe to use it.

Also there is an undocumented topic if you want to try it where you can see when the a redemption is accepted/rejected "community-points-broadcaster-v1.xxxx" <-- but I don't know if you need a special scope for this one but you do need "channel:read:redemptions" for the other one, so it probably works the same.

Wow thanks so much, I'll try this out today hopefully. I'm extremely horrible at coding and stuff like that but something I'm getting into that's why I use nodered to connect alot of random stuff together. I'll keep you updated of anything else and test future stuff if you'd like.
I run my Nodered from inside Home assistant inside my unraid server. So I can make a whole new docker for anything "experimental"

Hmm I looked over the PubSub in twitch dev and it's EXTREMELY CONFUSING. If im reading correctly I might need to make a app on twitch apparantly? Just really confusing. And yeah programming is my weakness that why I wanna do it more. Im bearly comfortable with the arduino IDE

yeah im really stuck don't really understand how to even get my Channel id

the day I mentioned it I tried it on node-red, but there is one issue, so the way it works imagine the websocket api is just like a chat, you send message and twitch replies with its own messages. So in order for twitch to know you want to get messages for certain events you send them a message with the topic you want, your channel id and api key. The issue with the node-red implementation is that you don't know when you have connected or reconnected, so you have to send a message manually after you connect, and if you get disconnected and reconnect you would need to subscribe again, but since you would be doing it manually it means you will have a connection with no subscriptions so twitch won't be sending you anything when that happens.

To solve that I was thinking on making a custom node since I'm interested on doing this as well, but I'm kind of busy with other things so I don't think I will work on it anytime soon.

If you want to do it even if it isn't reliable all you have to do is import this into your node red:

[
    {
        "id": "6ec442e7.d5a06c",
        "type": "websocket out",
        "z": "8e1c8e64.d6ed5",
        "name": "",
        "server": "",
        "client": "486da522.b31cbc",
        "x": 530,
        "y": 120,
        "wires": []
    },
    {
        "id": "2f7f9ba5.1c9b34",
        "type": "inject",
        "z": "8e1c8e64.d6ed5",
        "name": "",
        "topic": "",
        "payload": "{\"type\":\"LISTEN\",\"data\":{\"topics\":[\"community-points-broadcaster-v1.xxx\"],\"auth_token\":\"yyy\"}}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "x": 170,
        "y": 120,
        "wires": [
            [
                "6ec442e7.d5a06c"
            ]
        ]
    },
    {
        "id": "486da522.b31cbc",
        "type": "websocket-client",
        "z": "",
        "path": "wss://pubsub-edge.twitch.tv/v1",
        "tls": "",
        "wholemsg": "false"
    }
]

and this:

[
    {
        "id": "68e15d00.b3e4e4",
        "type": "websocket in",
        "z": "8e1c8e64.d6ed5",
        "name": "",
        "server": "",
        "client": "486da522.b31cbc",
        "x": 200,
        "y": 240,
        "wires": [
            [
                "e60bf3da.12dff"
            ]
        ]
    },
    {
        "id": "e60bf3da.12dff",
        "type": "debug",
        "z": "8e1c8e64.d6ed5",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 510,
        "y": 240,
        "wires": []
    },
    {
        "id": "486da522.b31cbc",
        "type": "websocket-client",
        "z": "",
        "path": "wss://pubsub-edge.twitch.tv/v1",
        "tls": "",
        "wholemsg": "false"
    }
]

then on the inject node edit the json to add your channel id (xxx) and your oauth token (yyy)
after connection just click inject to send the message and you will start getting points events

to get the channel id there are many ways but here is an easy one, search for your channel on twitchemotes.com and your id will be in the url.

to get the oauth token there are many ways, but probably the easiest one is to use:

https://twitchtokengenerator.com/

I have used them but I don't know them and I don't know if you can trust them. My suggestion just to be safe in case your token leaks in any way is to just give the access you need, so in this case you need the scope "channel:read:redemptions" but you can add other ones if you know you will be using them, you can see what other scopes you might need in this link https://dev.twitch.tv/docs/pubsub

And that's it, you just need to import the code I gave you, replace your channel id and token and after you click inject you should start seeing any new redemptions in the debug tab.

Cool I'll test that later today, and I think I might have a way to connect automatically and to send a ping command to stay connected. I have a Home assistant node looking at my channel so things my chat can control only work when I'm live (also changes my lights to "streaming mode" and a nice 3D printed live button ok my door) I can make that just send a connect command and so on. I'll keep you posted and try to help in anyway I can

all i get in the debug window is
{"type":"RESPONSE","error":"ERR_BADAUTH","nonce":""}

ive tried both the access and refresh tokens. ill see if there a different way to get the authentication code and report back

I just checked it doesn't need the oauth part, it is just the token, but I also noticed something I gave you wrong, in the inject node I gave you "community-points-broadcaster-v1"
but it should be:
"channel-points-channel-v1"

the other one is a private topic that only works with your private token (the one you can get from the developer tools on your browser)

hopefully that's the only issue

Ok I'll test it out in a few and see how it works.

Hmm seems like i still get the same error this is whats in the inject node

{
    "type": "LISTEN",
    "data": {
        "topics": [
            "channel-points-channel-v1"
        ],
        "auth_token": "(AUTH FROM WEBSITE)"
    }
}

Yeah i just got added that and i got this

{"type":"RESPONSE","error":"","nonce":""}

Cool seems like it works but its a wall of text. also i would need to inject the code every like 5min to keep a connection open right?

ok i could setup a trigger node to connect to the sub, but also start a "ping" every 4mins and see if that works. (i have a HassIO node that sees when im live and offline so i can hook it to that)
is there a way to maybe organize the output so its not a MASSIVE paragraph? i wanna make a filtering system that looks for a few things before it changes stuff

The node only has a drop down off:

  • Convert between JSON String & Object
  • Always convert to JSON String
  • Always convert to JavaScript Object

They all seem to do the same it only separates the Topic and Message.
but atleast its getting somewhere

Seems like constantly sending the message via the Inject node repeating every 4min seems to work. i just need to make it a trigger and use a "delay" or "repeat" node

Cool so been testing for a while now to make sure its all working and it is.
i can send the flow if you'd like?
but im having issues finding the "Require Viewer to Enter Text" Text the output just doesn't seem to show it. but using the Redemption id and passing the signal through a switch node seems to be working with no issues.