1- from user_scanner .core .orchestrator import generic_validate
1+ from user_scanner .core .orchestrator import generic_validate , status_validate
22from 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
3444if __name__ == "__main__" :
0 commit comments