user-scanner 1.0.5.0__py3-none-any.whl → 1.0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. user_scanner/__init__.py +0 -1
  2. user_scanner/__main__.py +113 -64
  3. user_scanner/cli/banner.py +2 -0
  4. user_scanner/cli/printer.py +117 -0
  5. user_scanner/community/__init__.py +1 -0
  6. user_scanner/community/coderlegion.py +15 -14
  7. user_scanner/community/stackoverflow.py +35 -0
  8. user_scanner/core/orchestrator.py +167 -95
  9. user_scanner/core/result.py +128 -0
  10. user_scanner/core/utils.py +9 -0
  11. user_scanner/creator/devto.py +13 -11
  12. user_scanner/creator/hashnode.py +25 -28
  13. user_scanner/creator/itch_io.py +12 -15
  14. user_scanner/creator/kaggle.py +12 -11
  15. user_scanner/creator/medium.py +18 -22
  16. user_scanner/creator/patreon.py +12 -16
  17. user_scanner/creator/producthunt.py +38 -31
  18. user_scanner/dev/codeberg.py +13 -11
  19. user_scanner/dev/cratesio.py +19 -17
  20. user_scanner/dev/dockerhub.py +17 -15
  21. user_scanner/dev/github.py +46 -27
  22. user_scanner/dev/gitlab.py +18 -15
  23. user_scanner/dev/huggingface.py +19 -0
  24. user_scanner/dev/launchpad.py +19 -17
  25. user_scanner/dev/npmjs.py +21 -34
  26. user_scanner/dev/replit.py +13 -11
  27. user_scanner/donation/buymeacoffee.py +10 -12
  28. user_scanner/donation/liberapay.py +36 -0
  29. user_scanner/gaming/chess_com.py +17 -20
  30. user_scanner/gaming/minecraft.py +19 -0
  31. user_scanner/gaming/monkeytype.py +7 -12
  32. user_scanner/gaming/osu.py +13 -16
  33. user_scanner/gaming/roblox.py +35 -26
  34. user_scanner/gaming/steam.py +18 -19
  35. user_scanner/social/bluesky.py +20 -24
  36. user_scanner/social/discord.py +17 -21
  37. user_scanner/social/instagram.py +22 -20
  38. user_scanner/social/mastodon.py +12 -16
  39. user_scanner/social/pinterest.py +15 -13
  40. user_scanner/social/reddit.py +16 -13
  41. user_scanner/social/snapchat.py +28 -26
  42. user_scanner/social/soundcloud.py +43 -0
  43. user_scanner/social/telegram.py +19 -17
  44. user_scanner/social/threads.py +23 -21
  45. user_scanner/social/x.py +20 -28
  46. user_scanner/social/youtube.py +41 -47
  47. user_scanner/utils/update.py +0 -0
  48. user_scanner/utils/version.py +2 -0
  49. user_scanner/version.json +1 -1
  50. {user_scanner-1.0.5.0.dist-info → user_scanner-1.0.9.0.dist-info}/METADATA +58 -23
  51. user_scanner-1.0.9.0.dist-info/RECORD +61 -0
  52. user_scanner-1.0.5.0.dist-info/RECORD +0 -52
  53. {user_scanner-1.0.5.0.dist-info → user_scanner-1.0.9.0.dist-info}/WHEEL +0 -0
  54. {user_scanner-1.0.5.0.dist-info → user_scanner-1.0.9.0.dist-info}/entry_points.txt +0 -0
  55. {user_scanner-1.0.5.0.dist-info → user_scanner-1.0.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,5 @@
1
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
2
3
 
3
4
  def validate_monkeytype(user: str) -> int:
4
5
 
@@ -24,21 +25,15 @@ def validate_monkeytype(user: str) -> int:
24
25
  available = payload.get("available")
25
26
 
26
27
  if available is True:
27
- return 1
28
+ return Result.available()
28
29
  elif available is False:
29
- return 0
30
- return 2
31
-
30
+ return Result.taken()
31
+ return Result.error("Invalid status code")
32
32
 
33
- return generic_validate(url, process, headers = headers)
33
+ return generic_validate(url, process, headers=headers)
34
34
 
35
- if __name__ == "__main__":
36
- try:
37
- import httpx # noqa: F401
38
- except ImportError:
39
- print("Error: 'httpx' library is not installed.")
40
- raise SystemExit(1)
41
35
 
36
+ if __name__ == "__main__":
42
37
  user = input("Username?: ").strip()
43
38
  result = validate_monkeytype(user)
44
39
 
@@ -1,22 +1,19 @@
1
- from ..core.orchestrator import status_validate
1
+ from user_scanner.core.orchestrator import status_validate
2
+
2
3
 
3
4
  def validate_osu(user):
4
- """
5
- Checks if a Osu username is available.
6
- Returns: 1 -> available, 0 -> taken, 2 -> error
7
- """
8
-
9
5
  url = f"https://osu.ppy.sh/users/{user}"
10
-
11
- return status_validate(url, 404, [200, 302], follow_redirects = True)
6
+
7
+ return status_validate(url, 404, [200, 302], follow_redirects=True)
8
+
12
9
 
13
10
  if __name__ == "__main__":
14
- user = input ("Username?: ").strip()
15
- result = validate_osu(user)
11
+ user = input("Username?: ").strip()
12
+ result = validate_osu(user)
16
13
 
17
- if result == 1:
18
- print("Available!")
19
- elif result == 0:
20
- print("Unavailable!")
21
- else:
22
- print("Error occurred!")
14
+ if result == 1:
15
+ print("Available!")
16
+ elif result == 0:
17
+ print("Unavailable!")
18
+ else:
19
+ print("Error occurred!")
@@ -1,34 +1,43 @@
1
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
2
3
 
3
- def validate_roblox(user):
4
- """
5
- Checks if a roblox username is available.
6
- Returns: 1 -> available, 0 -> taken, 2 -> error
7
- """
8
4
 
9
- url = f"https://users.roblox.com/v1/users/search?keyword={user}&limit=10" # official api
5
+ def validate_roblox(user):
6
+ # official api
7
+ url = f"https://users.roblox.com/v1/users/search?keyword={user}&limit=10"
10
8
 
11
9
  def process(response):
12
- search_results = response.json() # api response
13
-
14
- if "errors" in search_results: # this usually triggers when timeout or ratelimit
15
- return 2
16
-
17
- for entry in search_results["data"]: # iterates through the entries in the search results
10
+ search_results = response.json() # api response
11
+
12
+ if response.status_code == 429:
13
+ return Result.error("Too many requests")
14
+
15
+ if response.status_code == 400:
16
+ error = search_results["errors"][0] #Api states theres always an error
17
+ if error["code"] == 6:
18
+ return Result.error("Username is too short")
19
+ if error["code"] == 5:
20
+ return Result.error("Username was filtered")
21
+ #Shouldn't be able to reach this
22
+ return Result.error("Invalid username")
23
+
24
+ # iterates through the entries in the search results
25
+ for entry in search_results["data"]:
18
26
  # .lower() so casing from the API doesn't matter
19
- if entry["name"].lower() == user.lower(): # if a username matches the user
20
- return 0
21
- return 1
27
+ if entry["name"].lower() == user.lower(): # if a username matches the user
28
+ return Result.taken()
29
+ return Result.available()
30
+
31
+ return generic_validate(url, process, follow_redirects=True)
22
32
 
23
- return generic_validate(url, process, follow_redirects = True)
24
33
 
25
34
  if __name__ == "__main__":
26
- user = input ("Username?: ").strip()
27
- result = validate_roblox(user)
28
-
29
- if result == 1:
30
- print("Available!")
31
- elif result == 0:
32
- print("Unavailable!")
33
- else:
34
- print("Error occurred!")
35
+ user = input("Username?: ").strip()
36
+ result = validate_roblox(user)
37
+
38
+ if result == 1:
39
+ print("Available!")
40
+ elif result == 0:
41
+ print("Unavailable!")
42
+ else:
43
+ print("Error occurred!")
@@ -1,30 +1,29 @@
1
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
2
3
 
3
- def validate_steam(user):
4
- """
5
- Checks if a steam username is available.
6
- Returns: 1 -> available, 0 -> taken, 2 -> error
7
- """
8
4
 
5
+ def validate_steam(user):
9
6
  url = f"https://steamcommunity.com/id/{user}/"
10
7
 
11
8
  def process(response):
12
9
  if response.status_code == 200:
13
- if response.text.find("Error</title>") != -1:
14
- return 1
10
+ if "Error</title>" in response.text:
11
+ return Result.available()
15
12
  else:
16
- return 0
17
- return 2
13
+ return Result.taken()
14
+
15
+ return Result.error("Invalid status code")
18
16
 
19
17
  return generic_validate(url, process)
20
18
 
19
+
21
20
  if __name__ == "__main__":
22
- user = input ("Username?: ").strip()
23
- result = validate_steam(user)
24
-
25
- if result == 1:
26
- print("Available!")
27
- elif result == 0:
28
- print("Unavailable!")
29
- else:
30
- print("Error occurred!")
21
+ user = input("Username?: ").strip()
22
+ result = validate_steam(user)
23
+
24
+ if result == 1:
25
+ print("Available!")
26
+ elif result == 0:
27
+ print("Unavailable!")
28
+ else:
29
+ print("Error occurred!")
@@ -1,5 +1,6 @@
1
- import re
2
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
3
+
3
4
 
4
5
  def validate_bluesky(user):
5
6
  handle = user if user.endswith('.bsky.social') else f"{user}.bsky.social"
@@ -24,35 +25,30 @@ def validate_bluesky(user):
24
25
  'handle': handle,
25
26
  }
26
27
 
27
- if not re.fullmatch(r"^[a-zA-Z0-9\.-]{1,64}$", user):
28
- return 2
29
-
30
28
  def process(response):
31
29
  if response.status_code == 200:
32
30
  data = response.json()
33
31
  result_type = data.get('result', {}).get('$type')
34
32
 
35
33
  if result_type == "com.atproto.temp.checkHandleAvailability#resultAvailable":
36
- return 1
34
+ return Result.available()
37
35
  elif result_type == "com.atproto.temp.checkHandleAvailability#resultUnavailable":
38
- return 0
39
- return 2
36
+ return Result.taken()
37
+ elif response.status_code == 400:
38
+ return Result.error("Username can only contain letters, numbers, hyphens (no leading/trailing)")
39
+
40
+ return Result.error("Invalid status code!")
41
+
42
+ return generic_validate(url, process, headers=headers, params=params, timeout=15.0)
40
43
 
41
- return generic_validate(url, process, headers = headers, params = params, timeout = 15.0)
42
44
 
43
45
  if __name__ == "__main__":
44
- try:
45
- import httpx
46
- except ImportError:
47
- print("Error: 'httpx' library is not installed.")
48
- exit()
49
-
50
- user = input ("Username?: ").strip()
51
- result = validate_bluesky(user)
52
-
53
- if result == 1:
54
- print("Available!")
55
- elif result == 0:
56
- print("Unavailable!")
57
- else:
58
- print("Error occured!")
46
+ user = input("Username?: ").strip()
47
+ result = validate_bluesky(user)
48
+
49
+ if result == 1:
50
+ print("Available!")
51
+ elif result == 0:
52
+ print("Unavailable!")
53
+ else:
54
+ print("Error occured!")
@@ -1,5 +1,5 @@
1
1
  import httpx
2
- from httpx import ConnectError, TimeoutException
2
+ from user_scanner.core.result import Result
3
3
 
4
4
  def validate_discord(user):
5
5
  url = "https://discord.com/api/v9/unique-username/username-attempt-unauthed"
@@ -12,33 +12,29 @@ def validate_discord(user):
12
12
  "origin": "https://discord.com",
13
13
  "referer": "https://discord.com/register"
14
14
  }
15
-
15
+
16
16
  data = {"username": user}
17
-
17
+
18
18
  try:
19
19
  response = httpx.post(url, headers=headers, json=data, timeout=3.0)
20
20
  if response.status_code == 200:
21
21
  status = response.json().get("taken")
22
22
  if status is True:
23
- return 0
23
+ return Result.taken()
24
24
  elif status is False:
25
- return 1
26
- return 2
27
- except (ConnectError, TimeoutException):
28
- return 2
29
- except Exception:
30
- return 2
31
-
32
- if __name__ == "__main__":
33
- user = input ("Username?: ").strip()
34
- result = validate_discord(user)
35
-
36
- if result == 1:
37
- print("Available!")
38
- elif result == 0:
39
- print("Unavailable!")
40
- else:
41
- print("Error occured!")
25
+ return Result.available()
26
+ return Result.error("Invalid status code")
27
+ except Exception as e:
28
+ return Result.error(e)
42
29
 
43
30
 
31
+ if __name__ == "__main__":
32
+ user = input("Username?: ").strip()
33
+ result = validate_discord(user)
44
34
 
35
+ if result == 1:
36
+ print("Available!")
37
+ elif result == 0:
38
+ print("Unavailable!")
39
+ else:
40
+ print("Error occured!")
@@ -1,27 +1,29 @@
1
- from ..core.orchestrator import status_validate
1
+ from user_scanner.core.orchestrator import status_validate
2
+
2
3
 
3
4
  def validate_instagram(user):
4
- url = f"https://www.instagram.com/api/v1/users/web_profile_info/?username={user}"
5
+ url = f"https://www.instagram.com/api/v1/users/web_profile_info/?username={user}"
6
+
7
+ headers = {
8
+ 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
9
+ 'X-IG-App-ID': "936619743392459",
10
+ 'Accept': "application/json, text/javascript, */*; q=0.01",
11
+ 'Accept-Encoding': "gzip, deflate, br",
12
+ 'Accept-Language': "en-US,en;q=0.9",
13
+ 'X-Requested-With': "XMLHttpRequest",
14
+ 'Referer': f"https://www.instagram.com/{user}/",
15
+ }
5
16
 
6
- headers = {
7
- 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
8
- 'X-IG-App-ID': "936619743392459",
9
- 'Accept': "application/json, text/javascript, */*; q=0.01",
10
- 'Accept-Encoding': "gzip, deflate, br",
11
- 'Accept-Language': "en-US,en;q=0.9",
12
- 'X-Requested-With': "XMLHttpRequest",
13
- 'Referer': f"https://www.instagram.com/{user}/",
14
- }
17
+ return status_validate(url, 404, 200, headers=headers)
15
18
 
16
- return status_validate(url, 404, 200, headers = headers)
17
19
 
18
20
  if __name__ == "__main__":
19
- user = input ("Username?: ").strip()
20
- result = validate_instagram(user)
21
+ user = input("Username?: ").strip()
22
+ result = validate_instagram(user)
21
23
 
22
- if result == 1:
23
- print("Available!")
24
- elif result == 0:
25
- print("Unavailable!")
26
- else:
27
- print("Error occured!")
24
+ if result == 1:
25
+ print("Available!")
26
+ elif result == 0:
27
+ print("Unavailable!")
28
+ else:
29
+ print("Error occured!")
@@ -1,23 +1,19 @@
1
- from ..core.orchestrator import status_validate
1
+ from user_scanner.core.orchestrator import status_validate
2
+
2
3
 
3
4
  def validate_mastodon(user):
4
5
  url = f"https://mastodon.social/@{user}"
5
6
 
6
- return status_validate(url, 404, 200, follow_redirects = True)
7
+ return status_validate(url, 404, 200, follow_redirects=True)
7
8
 
8
- if __name__ == "__main__":
9
- try:
10
- import httpx
11
- except ImportError:
12
- print("Error: 'httpx' library is not installed.")
13
- exit()
14
9
 
15
- user = input ("Username?: ").strip()
16
- result = validate_mastodon(user)
10
+ if __name__ == "__main__":
11
+ user = input("Username?: ").strip()
12
+ result = validate_mastodon(user)
17
13
 
18
- if result == 1:
19
- print("Available!")
20
- elif result == 0:
21
- print("Unavailable!")
22
- else:
23
- print("Error occured!")
14
+ if result == 1:
15
+ print("Available!")
16
+ elif result == 0:
17
+ print("Unavailable!")
18
+ else:
19
+ print("Error occured!")
@@ -1,4 +1,5 @@
1
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
2
3
 
3
4
  def validate_pinterest(user):
4
5
  url = f"https://www.pinterest.com/{user}/"
@@ -6,21 +7,22 @@ def validate_pinterest(user):
6
7
  def process(response):
7
8
  if response.status_code == 200:
8
9
  if "User not found." in response.text:
9
- return 1
10
+ return Result.available()
10
11
  else:
11
- return 0
12
+ return Result.taken()
12
13
  else:
13
- return 2
14
+ return Result.error("Invalid status code")
15
+
16
+ return generic_validate(url, process, follow_redirects=True)
14
17
 
15
- return generic_validate(url, process, follow_redirects = True)
16
18
 
17
19
  if __name__ == "__main__":
18
- user = input ("Username?: ").strip()
19
- result = validate_pinterest(user)
20
+ user = input("Username?: ").strip()
21
+ result = validate_pinterest(user)
20
22
 
21
- if result == 1:
22
- print("Available!")
23
- elif result == 0:
24
- print("Unavailable!")
25
- else:
26
- print("Error occured!")
23
+ if result == 1:
24
+ print("Available!")
25
+ elif result == 0:
26
+ print("Unavailable!")
27
+ else:
28
+ print("Error occured!")
@@ -1,4 +1,6 @@
1
- from ..core.orchestrator import generic_validate
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
3
+
2
4
 
3
5
  def validate_reddit(user):
4
6
  url = f"https://www.reddit.com/user/{user}/"
@@ -6,21 +8,22 @@ def validate_reddit(user):
6
8
  def process(response):
7
9
  if response.status_code == 200:
8
10
  if "Sorry, nobody on Reddit goes by that name." in response.text:
9
- return 1
11
+ return Result.available()
10
12
  else:
11
- return 0
13
+ return Result.taken()
12
14
  else:
13
- return 2
15
+ return Result.error()
16
+
17
+ return generic_validate(url, process, follow_redirects=True)
14
18
 
15
- return generic_validate(url, process, follow_redirects = True)
16
19
 
17
20
  if __name__ == "__main__":
18
- user = input ("Username?: ").strip()
19
- result = validate_reddit(user)
21
+ user = input("Username?: ").strip()
22
+ result = validate_reddit(user)
20
23
 
21
- if result == 1:
22
- print("Available!")
23
- elif result == 0:
24
- print("Unavailable!")
25
- else:
26
- print("Error occured!")
24
+ if result == 1:
25
+ print("Available!")
26
+ elif result == 0:
27
+ print("Unavailable!")
28
+ else:
29
+ print("Error occured!")
@@ -1,33 +1,35 @@
1
- from ..core.orchestrator import status_validate
1
+ from user_scanner.core.orchestrator import status_validate
2
+
2
3
 
3
4
  def validate_snapchat(user):
4
- url = f"https://www.snapchat.com/@{user}"
5
+ url = f"https://www.snapchat.com/@{user}"
6
+
7
+ headers = {
8
+ 'User-Agent': "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36",
9
+ 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
10
+ 'Accept-Encoding': "gzip, deflate, br, zstd",
11
+ 'sec-ch-ua': "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"",
12
+ 'sec-ch-ua-mobile': "?1",
13
+ 'sec-ch-ua-platform': "\"Android\"",
14
+ 'upgrade-insecure-requests': "1",
15
+ 'sec-fetch-site': "none",
16
+ 'sec-fetch-mode': "navigate",
17
+ 'sec-fetch-user': "?1",
18
+ 'sec-fetch-dest': "document",
19
+ 'accept-language': "en-US,en;q=0.9",
20
+ 'priority': "u=0, i"
21
+ }
5
22
 
6
- headers = {
7
- 'User-Agent': "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36",
8
- 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
9
- 'Accept-Encoding': "gzip, deflate, br, zstd",
10
- 'sec-ch-ua': "\"Google Chrome\";v=\"141\", \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"141\"",
11
- 'sec-ch-ua-mobile': "?1",
12
- 'sec-ch-ua-platform': "\"Android\"",
13
- 'upgrade-insecure-requests': "1",
14
- 'sec-fetch-site': "none",
15
- 'sec-fetch-mode': "navigate",
16
- 'sec-fetch-user': "?1",
17
- 'sec-fetch-dest': "document",
18
- 'accept-language': "en-US,en;q=0.9",
19
- 'priority': "u=0, i"
20
- }
23
+ return status_validate(url, 404, 200, headers=headers, follow_redirects=True)
21
24
 
22
- return status_validate(url, 404, 200, headers = headers, follow_redirects = True)
23
25
 
24
26
  if __name__ == "__main__":
25
- user = input ("Username?: ").strip()
26
- result = validate_snapchat(user)
27
+ user = input("Username?: ").strip()
28
+ result = validate_snapchat(user)
27
29
 
28
- if result == 1:
29
- print("Available!")
30
- elif result == 0:
31
- print("Unavailable!")
32
- else:
33
- print("Error occured!")
30
+ if result == 1:
31
+ print("Available!")
32
+ elif result == 0:
33
+ print("Unavailable!")
34
+ else:
35
+ print("Error occured!")
@@ -0,0 +1,43 @@
1
+ from user_scanner.core.orchestrator import generic_validate
2
+ from user_scanner.core.result import Result
3
+
4
+
5
+ def validate_soundcloud(user):
6
+ url = f"https://soundcloud.com/{user}"
7
+
8
+ headers = {
9
+ 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
10
+ 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
11
+ }
12
+
13
+ def process(response):
14
+ if response.status_code == 404:
15
+ return Result.available()
16
+
17
+ if response.status_code == 200:
18
+ text = response.text
19
+
20
+ if f'soundcloud://users:{user}' in text:
21
+ return Result.taken()
22
+ if f'"username":"{user}"' in text:
23
+ return Result.taken()
24
+ if 'soundcloud://users:' in text and '"username":"' in text:
25
+ return Result.taken()
26
+
27
+ return Result.available()
28
+
29
+ return Result.error()
30
+
31
+ return generic_validate(url, process, headers=headers, follow_redirects=True)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ user = input("Username?: ").strip()
36
+ result = validate_soundcloud(user)
37
+
38
+ if result == 1:
39
+ print("Available!")
40
+ elif result == 0:
41
+ print("Unavailable!")
42
+ else:
43
+ print("Error occured!")
@@ -1,27 +1,29 @@
1
1
  import re
2
- from ..core.orchestrator import generic_validate
2
+ from user_scanner.core.orchestrator import generic_validate
3
+ from user_scanner.core.result import Result
4
+
3
5
 
4
6
  def validate_telegram(user: str) -> int:
5
- """
6
- Checks if a Telegram username is available.
7
- Returns: 1 -> available, 0 -> taken, 2 -> error
8
- """
9
7
  url = f"https://t.me/{user}"
10
8
 
11
9
  def process(r):
12
10
  if r.status_code == 200:
13
- return 0 if re.search(r'<div[^>]*class="tgme_page_extra"[^>]*>', r.text) else 1
14
- return 2
15
-
16
- return generic_validate(url, process, follow_redirects = True)
11
+ if re.search(r'<div[^>]*class="tgme_page_extra"[^>]*>', r.text):
12
+ return Result.taken()
13
+ else:
14
+ return Result.available()
15
+ return Result.error()
16
+
17
+ return generic_validate(url, process, follow_redirects=True)
18
+
17
19
 
18
20
  if __name__ == "__main__":
19
- user = input ("Username?: ").strip()
20
- result = validate_telegram(user)
21
+ user = input("Username?: ").strip()
22
+ result = validate_telegram(user)
21
23
 
22
- if result == 1:
23
- print("Available!")
24
- elif result == 0:
25
- print("Unavailable!")
26
- else:
27
- print("Error occured!")
24
+ if result == 1:
25
+ print("Available!")
26
+ elif result == 0:
27
+ print("Unavailable!")
28
+ else:
29
+ print("Error occured!")