Made a tool to search through Twitch chats

oh sorry, you’re right. I am confusing this thread with the VideoScan one, my bad!

1 Like

I’m currently getting this error when using the tool on twitch channels:

thread ‘’ panicked at ‘called Result::unwrap() on an Err value: “Missing edges”’, src\main.rs:192:47
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I’ve seen something similar pop up from time to time, but it usually managed to download the chat if I added the command a few more times. Doesn’t seem to work this time.

Looking through this right now.
The response I’m getting is:

  {
    "data": {
      "user": {
        "__typename": "User",
        "clips": null,
        "id": "38718052"
      }
    },
    "errors": [
      {
        "message": "failed integrity check",
        "path": [
          "user",
          "clips"
        ]
      }
    ],
    "extensions": {
      "challenge": {
        "type": "integrity"
      },
      "durationMilliseconds": 22,
      "operationName": "ClipsCards__User",
      "requestID": "01GZMBKZXFJMY74FAMHJGHEMJN"
    }
  }
]
Missing edges

So chances are there’s something new that Twitch is checking for in the headers

Update: Twitch is now requiring a new Client-Integrity header, which is a hash of the client id, your IP address, as well as other unique identifiers. Sighs. This will probably take some work to figure out, so a fix probably won’t be out for a few days. At the moment, you are able to get around this by rebuilding the program and adding your own Client-Integrity header with a valid id (you can get this by visiting twitch and looking at your browser requests) and adding that to the gql function I’ve written.

5 Likes

Yeah, it’s down for me too

At the moment I’ve been struck with a busy schedule. Possible around Thursday I can begin to look into Twitch’s changes with more detail. It looks fairly large as a number of twitch’s graphql has been requiring the integrity token to even function (and I’ve had a tough time getting a token from the integrity endpoint that is valid)

8 Likes

He provided access to this tool free of charge, offered a workaround and said he’ll work on a general fix when he has time. You can use Q’s tool or another alternative in the meantime

6 Likes

After quite a bit of investigation, I’ve concluded that the best way to get around this is just to ask you (the user) for a valid device id and client. Before reading further, be sure that you know how to add environment variables to your system.

Relevant Guides:
Windows: https://www.howtogeek.com/787217/how-to-edit-environment-variables-on-windows-10-or-11/
Linux, MacOS, other Posix shells, etc: Use environment variables in Terminal on Mac - Apple Support
Make sure you have read these thoroughly before continuing

The environment variables we will be creating are:
CHAT_READER_CLIENT_INTEGRITY and CHAT_READER_DEVICE_ID
These will store the integrity token and device id, respectively. If for some incredibly strange reason these are already taken- rename your existing variables to something else or let me know so I can change them.

First, we’ll actually need to get the integrity token and device id. There are some things to note, though. Your client integrity token is IP specific- I cannot generate one for you and you will need to redo this process every time you would like to use the twitch functionality of chat_reader on a different IP address (note: your IP address may also change from time to time on its own, depending on your ISP).

How to get the integrity and device id?

  • In your preferred (somewhat modern) browser, launch a new private/incognito/guest window. Make sure that your are NOT already signed into twitch when you do this. The integrity token will not work with chat_reader if you do this when signed in.
  • Before you visit any page (you should still be in the blank tab)
  • Open your devtools (F12 or right click+inspect)
  • Click on the network tab (if your browser doesn’t have one, use one that does. I’m using brave, for reference).
  • Now go to https://twitch.tv/
  • You should see the log in the network tab begin to accumulate with requests. If you don’t- you might’ve opened your devtools in a different tab.
  • Near the top of the devtools page, you should see a small search bar, which will allow you to filter your requests.
  • In that bar, type in integrity
    image
  • Next, click on the bottommost log of integrity
  • Scroll through the request headers until you find X-Device-Id
  • Right click on the X-Device-Id field and copy the value to your keyboard
  • Set this value to your CHAT_READER_DEVICE_ID environment variable
  • Next, in the Preview tab (this may be called Response in other browsers), copy the token from the JSON response
    image
  • Set this value to your CHAT_READER_CLIENT_INTEGRITY variable

Once this is completed (and your environment variables have been set), chat_reader will begin to work for Twitch.

Ensure you are using these new binaries of chat_reader: Index of /programs/chat_reader/

6 Likes

Can confirm this works, when you set the environment variable as a system variable instead of a user variable. You’re a very smart person

1 Like

My goal is to do this entirely in the code so no environment variable is needed, but it looks like a cat and mouse game with twitch (theyve had the integrity endpoint for quite a while, but it only recently started spreading to things like the channel or clip graphql commands). The integrity check has also changed a lot and previous solutions started breaking, so it’s really hard to find any documentation on it from other people developing on twitch’s graphql

oh this is so difficult for those who use the translator to understand here, I managed to understand even the part of Set this value to your CHAT_READER_DEVICE_ID environment variable , I couldn’t conclude that

You just need to set 2 environment variables with the names “CHAT_READER_CLIENT_INTEGRITY” (value - integrity token) and “CHAT_READER_DEVICE_ID” (value - X-Device-Id).

You can find the values with the inspect function from your browser.

Maybe switching the browser to English until you set it up would help.

image

1 Like

I could’ve phrased it better, so PM me questions you may have

thread ‘main’ panicked at ‘called Result::unwrap() on an Err value: NotPresent’, src\twitch.rs:16:51
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

a new error

1 Like

i’ve found that I need to repeat this process something like once a day. idk if my ISP is just changing my IP address daily or if Twitch is purposely making it difficult to do this

2 Likes

That error occurs because the program cannot see either the CHAT_READER_CLIENT_INTEGRITY or CHAT_READER_DEVICE_ID environment variable.

Also, you PM’d me earlier today and I didn’t get back because I believe you’re using a windows computer. I don’t have a windows computer on me at the moment, but I’ll get back when I do a screen recording of the entire process to getting the program working on this thread.

Thank you! This worked well for me.

1 Like

Why can‘t i download it on Mac?

Here’re a good alternative. The rechat tool works again. I couldn’t get this tool to work on the first go around. Releases · jdpurcell/RechatTool (github.com)

3 Likes

I would appreciate if someone could search some streamers for me

Here’s some instructions I made a while back.

For the rechat tool, download the program on this page. Releases · jdpurcell/RechatTool (github.com)

Once it’s in your downloads folder, press “shift” and right click on an EMPTY SPACE in your download folder, then click on “open command menu here.” (update. On windows 10 or 11, type “cmd” in the address bar and press enter)

Once the command menu is open you want to paste .\RechatTool -D then put the 9 digit number at the end of a twitch video’s URL behind that copy and paste.

It should look like this .\RechatTool -D 524699648

Twitch (twitch video URL)

Open that file and you can search for key words by pressing F3 (or fn+F3, or ctrl F). Here’s an example.

2 Likes