Skip to content

Commit 111826e

Browse files
authored
Merge pull request #121 from VamatoHD/improve-roblox
Improve roblox check
2 parents d976a06 + a206a8a commit 111826e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

user_scanner/gaming/roblox.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from user_scanner.core.orchestrator import generic_validate
1+
from user_scanner.core.orchestrator import generic_validate, status_validate
22
from user_scanner.core.result import Result
33

44

5-
def validate_roblox(user):
5+
def validate_roblox(user: str) -> Result:
66
# official api
77
url = f"https://users.roblox.com/v1/users/search?keyword={user}&limit=10"
88

@@ -13,12 +13,13 @@ def process(response):
1313
return Result.error("Too many requests")
1414

1515
if response.status_code == 400:
16-
error = search_results["errors"][0] #Api states theres always an error
16+
# Api states theres always an error
17+
error = search_results["errors"][0]
1718
if error["code"] == 6:
1819
return Result.error("Username is too short")
1920
if error["code"] == 5:
2021
return Result.error("Username was filtered")
21-
#Shouldn't be able to reach this
22+
# Shouldn't be able to reach this
2223
return Result.error("Invalid username")
2324

2425
# iterates through the entries in the search results
@@ -28,7 +29,16 @@ def process(response):
2829
return Result.taken()
2930
return Result.available()
3031

31-
return generic_validate(url, process, follow_redirects=True)
32+
# First try: Using roblox's API
33+
result = generic_validate(url, process, follow_redirects=True)
34+
35+
if result.get_reason() != "Too many requests":
36+
return result
37+
38+
# If rate limited, uses a simple status validation
39+
url = f"https://www.roblox.com/user.aspx?username={user}"
40+
41+
return status_validate(url, 404, [200, 302], follow_redirects=True)
3242

3343

3444
if __name__ == "__main__":

0 commit comments

Comments
 (0)