Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pxls.space CFAuth & Discord Intent Update #22

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

neurofumo
Copy link
Contributor

@neurofumo neurofumo commented Jul 13, 2024

When running Clueless for the first time with everything in env filled, there are 403 errors everywhere (in pxls.space).
This is because of an API change where if you don't have something called cfauth, it won't let you do anything.

I went ahead and fixed the websocket and the get_content definition by adding a header with the cfauth.
I also updated intents so that it uses only Message Content Intent rather than Intent.all (because that's all it needs) and I updated the env file to add the cfauth.

Update: I made cfauth optional as third-parties don't need such things.

@neurofumo neurofumo marked this pull request as draft July 15, 2024 17:43
Copy link
Contributor

@VanillaSixtySix VanillaSixtySix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the most part!

if data:
return data
timeout = aiohttp.ClientTimeout(
sock_connect=10.0, sock_read=10.0
) # set a timeout of 10 seconds
async with aiohttp.ClientSession(timeout=timeout, **kwargs) as session:
try:
async with session.get(url) as r:
async with session.get(url, headers=headers if pxls_cfauth else None) as r:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think leaving headers in would be fine, even if the dict is empty.

import aiohttp
import numpy as np
from aiohttp.client_exceptions import ClientConnectionError, InvalidURL
from typing_extensions import ParamSpec

from dotenv import load_dotenv # this might be me being lazy but if it works, it works
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick - this is fine, the comment can be removed.

Comment on lines +45 to +53
if self.pxls_cfauth:
headers = {
"Cookie": f"pxls-validate={pxls_validate}",
"x-pxls-cfauth": f"{self.pxls_cfauth}"
}
else:
headers = {
"Cookie": f"pxls-validate={pxls_validate}"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of assigning headers twice, you should assign it once with Cookie as the default item, then add x-pxls-cfauth if using self.pxls_cfauth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take note of this, thanks!

@VanillaSixtySix VanillaSixtySix mentioned this pull request Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants