generated from nhcarrigan/template
fix: resolve lint issues for Python and TypeScript
CI / dependency-pin-check-typescript (pull_request) Successful in 4s
CI / dependency-pin-check-python (pull_request) Successful in 4s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m15s
CI / typescript (pull_request) Successful in 9m40s
CI / python (pull_request) Successful in 9m22s
CI / dependency-pin-check-typescript (pull_request) Successful in 4s
CI / dependency-pin-check-python (pull_request) Successful in 4s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m15s
CI / typescript (pull_request) Successful in 9m40s
CI / python (pull_request) Successful in 9m22s
- Update pyproject.toml to ignore T201 (print statements) and other rules - Fix quote styles, bare except, set comprehensions in Python scripts - Rename interactive-runner.ts to interactiveRunner.ts (camelCase) - Refactor TypeScript to use import.meta.url instead of __dirname - Add proper JSDoc headers and rename abbreviated variables
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
# Configuration
|
||||
BOT_TOKEN = os.environ["DISCORD_BOT_TOKEN"]
|
||||
@@ -10,7 +10,7 @@ GUILD_ID = "692816967895220344"
|
||||
BASE_URL = "https://discord.com/api/v10"
|
||||
|
||||
# Read Discord IDs from table.md
|
||||
with open("table.md", "r") as f:
|
||||
with open("table.md") as f:
|
||||
content = f.read()
|
||||
|
||||
lines = content.strip().split("\n")
|
||||
@@ -33,7 +33,7 @@ headers = [h.strip() for h in header_line.split("|")[1:-1]]
|
||||
discord_idx = 0 # Discord ID is the first column
|
||||
|
||||
discord_ids = []
|
||||
for line in lines[header_idx + 2:]: # Skip header and separator
|
||||
for line in lines[header_idx + 2 :]: # Skip header and separator
|
||||
if not line.startswith("|"):
|
||||
continue
|
||||
cols = [c.strip() for c in line.split("|")[1:-1]]
|
||||
@@ -59,15 +59,17 @@ for i, discord_id in enumerate(discord_ids):
|
||||
data = json.loads(response.read().decode())
|
||||
username = data.get("user", {}).get("username", "Unknown")
|
||||
verified.append((discord_id, username))
|
||||
print(f"[{i+1}/{len(discord_ids)}] ✓ {discord_id} - {username}")
|
||||
print(f"[{i + 1}/{len(discord_ids)}] ✓ {discord_id} - {username}")
|
||||
except urllib.error.HTTPError as e:
|
||||
if e.code == 404:
|
||||
missing.append(discord_id)
|
||||
print(f"[{i+1}/{len(discord_ids)}] ✗ {discord_id} - NOT IN SERVER")
|
||||
print(f"[{i + 1}/{len(discord_ids)}] ✗ {discord_id} - NOT IN SERVER")
|
||||
elif e.code == 429:
|
||||
# Rate limited - wait and retry
|
||||
retry_after = json.loads(e.read().decode()).get("retry_after", 1)
|
||||
print(f"[{i+1}/{len(discord_ids)}] Rate limited, waiting {retry_after}s...")
|
||||
print(
|
||||
f"[{i + 1}/{len(discord_ids)}] Rate limited, waiting {retry_after}s..."
|
||||
)
|
||||
time.sleep(retry_after + 0.5)
|
||||
# Retry
|
||||
try:
|
||||
@@ -77,32 +79,32 @@ for i, discord_id in enumerate(discord_ids):
|
||||
data = json.loads(response.read().decode())
|
||||
username = data.get("user", {}).get("username", "Unknown")
|
||||
verified.append((discord_id, username))
|
||||
print(f"[{i+1}/{len(discord_ids)}] ✓ {discord_id} - {username} (after retry)")
|
||||
msg = f"[{i + 1}/{len(discord_ids)}] ✓ {discord_id}"
|
||||
print(f"{msg} - {username} (after retry)")
|
||||
except urllib.error.HTTPError as e2:
|
||||
if e2.code == 404:
|
||||
missing.append(discord_id)
|
||||
print(f"[{i+1}/{len(discord_ids)}] ✗ {discord_id} - NOT IN SERVER (after retry)")
|
||||
msg = f"[{i + 1}/{len(discord_ids)}] ✗ {discord_id}"
|
||||
print(f"{msg} - NOT IN SERVER (after retry)")
|
||||
else:
|
||||
errors.append((discord_id, f"HTTP {e2.code}"))
|
||||
print(f"[{i+1}/{len(discord_ids)}] ? {discord_id} - Error {e2.code}")
|
||||
print(
|
||||
f"[{i + 1}/{len(discord_ids)}] ? {discord_id} - Error {e2.code}"
|
||||
)
|
||||
else:
|
||||
errors.append((discord_id, f"HTTP {e.code}"))
|
||||
print(f"[{i+1}/{len(discord_ids)}] ? {discord_id} - Error {e.code}")
|
||||
print(f"[{i + 1}/{len(discord_ids)}] ? {discord_id} - Error {e.code}")
|
||||
|
||||
# Small delay to avoid rate limits
|
||||
time.sleep(0.1)
|
||||
|
||||
print(f"\n=== SUMMARY ===")
|
||||
print("\n=== SUMMARY ===")
|
||||
print(f"Verified: {len(verified)}")
|
||||
print(f"Missing: {len(missing)}")
|
||||
print(f"Errors: {len(errors)}")
|
||||
|
||||
# Save results
|
||||
with open("discord_verification.json", "w") as f:
|
||||
json.dump({
|
||||
"verified": verified,
|
||||
"missing": missing,
|
||||
"errors": errors
|
||||
}, f, indent=2)
|
||||
json.dump({"verified": verified, "missing": missing, "errors": errors}, f, indent=2)
|
||||
|
||||
print("\nResults saved to discord_verification.json")
|
||||
|
||||
Reference in New Issue
Block a user