Skip to content
This repository was archived by the owner on Apr 26, 2026. It is now read-only.

Commit 75ab90d

Browse files
committed
updated proxy in invite validator tool
1 parent b0a14ca commit 75ab90d

1 file changed

Lines changed: 62 additions & 20 deletions

File tree

Tool-09-Invite-Validator.py

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ def load_env():
1818
env_vars[key] = value
1919
except FileNotFoundError:
2020
print(".env file not found. Using default values.")
21-
env_vars["PROXY_URL"] = "https://api.codetabs.com/v1/proxy/?quest="
21+
env_vars["PROXY_URL"] = "https://api.allorigins.win/get?url="
2222
env_vars["DISCORD_INVITE_RATE_LIMIT"] = "20"
2323
return env_vars
2424

2525

2626
env_vars = load_env()
2727

2828
# Configuration
29-
PROXY_URL = env_vars.get("PROXY_URL", "https://api.codetabs.com/v1/proxy/?quest=")
29+
PROXY_URL = env_vars.get("PROXY_URL", "https://api.allorigins.win/get?url=")
3030
RATE_LIMIT = int(env_vars.get("DISCORD_INVITE_RATE_LIMIT", 20))
3131
JSON_FILE_PATH = os.path.join(
3232
os.path.dirname(__file__),
@@ -64,22 +64,64 @@ def check_invite(invite_code):
6464
)
6565

6666
if response.status_code == 200:
67-
# Check if the response indicates an unknown invite
6867
try:
69-
data = response.json()
70-
if (
71-
data.get("code") == 10006
72-
and data.get("message") == "Unknown Invite"
73-
):
68+
# Parse the proxy response
69+
proxy_data = response.json()
70+
71+
# Check if we're using a proxy service like allorigins.win
72+
if 'contents' in proxy_data:
73+
# Extract the actual Discord API response from proxy wrapper
74+
actual_response = proxy_data['contents']
75+
76+
# Parse the actual Discord response
77+
try:
78+
discord_data = json.loads(actual_response)
79+
except (json.JSONDecodeError, TypeError):
80+
# If contents is not JSON string, it might be already parsed
81+
discord_data = actual_response
82+
83+
# Check HTTP status from proxy metadata if available
84+
if 'status' in proxy_data:
85+
status_info = proxy_data['status']
86+
actual_http_code = status_info.get('http_code', 200)
87+
88+
# If Discord API returned 404 (Unknown Invite)
89+
if actual_http_code == 404:
90+
return False, f"https://discord.com/invite/{invite_code}"
91+
92+
# Check Discord API response content
93+
if isinstance(discord_data, dict):
94+
# Check for "Unknown Invite" error
95+
if (discord_data.get("code") == 10006 and
96+
discord_data.get("message") == "Unknown Invite"):
97+
return False, f"https://discord.com/invite/{invite_code}"
98+
99+
# If we got valid guild data, the invite is active
100+
if "guild" in discord_data:
101+
return True, f"https://discord.com/invite/{invite_code}"
102+
103+
# If we can't determine status from content, assume inactive
74104
return False, f"https://discord.com/invite/{invite_code}"
75-
# If we got valid guild data, the invite is active
76-
if "guild" in data:
77-
return True, f"https://discord.com/invite/{invite_code}"
78-
except ValueError:
79-
pass
80-
return False, f"https://discord.com/invite/{invite_code}"
105+
106+
else:
107+
# Direct API response (no proxy)
108+
data = proxy_data
109+
if (data.get("code") == 10006 and
110+
data.get("message") == "Unknown Invite"):
111+
return False, f"https://discord.com/invite/{invite_code}"
112+
113+
if "guild" in data:
114+
return True, f"https://discord.com/invite/{invite_code}"
115+
116+
return False, f"https://discord.com/invite/{invite_code}"
117+
118+
except (json.JSONDecodeError, ValueError) as e:
119+
if PRINT_RESPONSE:
120+
print(f"Error parsing JSON response for {invite_code}: {str(e)}")
121+
return False, f"https://discord.com/invite/{invite_code}"
81122
else:
82123
return False, f"https://discord.com/invite/{invite_code}"
124+
83125
except Exception as e:
84126
if PRINT_RESPONSE:
85127
print(f"Error checking invite {invite_code}: {str(e)}")
@@ -156,25 +198,25 @@ def process_accounts():
156198
surface_domain = account_data.get("SURFACE_URL_DOMAIN", "")
157199

158200
if not (
159-
surface_domain in ["discord.gg", "discord.com"]
160-
and surface_url.startswith(("http://", "https://"))
201+
surface_domain in ["discord.gg", "discord.com"]
202+
and surface_url.startswith(("http://", "https://"))
161203
):
162204
print(
163-
f"[{i+1}/{total_accounts}] Skipping {account_id}: Not a Discord invite URL"
205+
f"[{i + 1}/{total_accounts}] Skipping {account_id}: Not a Discord invite URL"
164206
)
165207
skipped_accounts += 1
166208
continue
167209

168210
invite_code = extract_invite_code(surface_url)
169211
if not invite_code:
170212
print(
171-
f"[{i+1}/{total_accounts}] Skipping {account_id}: Could not extract invite code from URL"
213+
f"[{i + 1}/{total_accounts}] Skipping {account_id}: Could not extract invite code from URL"
172214
)
173215
skipped_accounts += 1
174216
continue
175217

176218
print(
177-
f"[{i+1}/{total_accounts}] Processing {account_id}: Checking invite {invite_code}"
219+
f"[{i + 1}/{total_accounts}] Processing {account_id}: Checking invite {invite_code}"
178220
)
179221

180222
# Check if invite was already checked
@@ -220,4 +262,4 @@ def process_accounts():
220262

221263

222264
if __name__ == "__main__":
223-
process_accounts()
265+
process_accounts()

0 commit comments

Comments
 (0)