Skip to content

Commit

Permalink
Beacons.ai
Browse files Browse the repository at this point in the history
  • Loading branch information
ghluka committed May 7, 2024
1 parent e58341b commit 714a044
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ $ pip install -r requirements.txt
$ python3 main.py
```

## 📃 Supported websites <!-- Websites start -->[16 total]
## 📃 Supported websites <!-- Websites start -->[17 total]

- [Beacons.ai](https://beacons.ai/)
- [Chess.com](https://chess.com/)
- [Github](https://github.com/)
- [Gitlab](https://gitlab.com/)
Expand Down
35 changes: 35 additions & 0 deletions src/checkers/beacons-ai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""https://beacons.ai/
"""
import time

import httpx
from httpx._models import Response

from base.checker import BaseChecker


class Checker(BaseChecker):
ENDPOINT = "https://account.beacons.ai/api/user_profile"

@BaseChecker.check.register
def _(self, username:str) -> str|None:
if len(username) > 30:
return None
elif username.startswith(".") or username.endswith(".") or ".." in username:
return None
elif "__" in username:
return None
elif not all(c.isalnum() and c.isascii() or c in "_." for c in username):
return None

headers = {"X-Beacons-Application-Viewed": "web", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0"}
payload = {"new_username": username, "action": "is_username_taken"}

r = Response(429)
while r.status_code == 429:
with httpx.Client(verify=False, proxies=self.proxies) as client:
r = client.post(self.ENDPOINT, json=payload, headers=headers)
if r.status_code == 429:
time.sleep(self.RATELIMIT_TIMEOUT)

return username if r.json()["username_taken"] == False else None
2 changes: 1 addition & 1 deletion src/checkers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Checker(BaseChecker):
def _(self, username:str) -> str|None:
if len(username) > 39:
return None
elif username.endswith("-") or username.endswith("-") or "--" in username:
elif username.startswith("-") or username.endswith("-") or "--" in username:
return None
elif not all(c.isalnum() and c.isascii() or c in "-" for c in username):
return None
Expand Down
1 change: 0 additions & 1 deletion src/checkers/linktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ def _(self, username:str) -> str|None:
if r.status_code == 429:
time.sleep(self.RATELIMIT_TIMEOUT)

print(r.status_code)
return username if r.json()["result"] == "success" else None

0 comments on commit 714a044

Please sign in to comment.