Skip to content

Commit

Permalink
🔥 Update headers logic
Browse files Browse the repository at this point in the history
  • Loading branch information
shamhi committed Sep 24, 2024
1 parent ab55215 commit d72ca17
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions bot/utils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,30 @@ def get_headers(name: str):

profiles = db.get_data()

headers = profiles.get(name, {}).get('headers', DEFAULT_HEADERS)
headers = profiles.get(name, {}).get('headers', {})

if settings.USE_RANDOM_USERAGENT:
android_version = random.randint(24, 33)
webview_version = random.randint(70, 125)
if not headers or not isinstance(headers, dict):
headers = DEFAULT_HEADERS

headers['Sec-Ch-Ua'] = (
f'"Android WebView";v="{webview_version}", '
f'"Chromium";v="{webview_version}", '
f'"Not?A_Brand";v="{android_version}"'
)
headers['User-Agent'] = get_mobile_user_agent()
if settings.USE_RANDOM_USERAGENT:
android_version = random.randint(24, 33)
webview_version = random.randint(70, 125)

if not profiles.get(name):
profiles[name] = {"proxy": "", "headers": headers}
else:
profiles[name]["headers"] = headers
headers['Sec-Ch-Ua'] = (
f'"Android WebView";v="{webview_version}", '
f'"Chromium";v="{webview_version}", '
f'"Not?A_Brand";v="{android_version}"'
)
headers['User-Agent'] = get_mobile_user_agent()

db.save_data(profiles)
if not profiles.get(name):
profiles[name] = {"tonAddress": "", "proxy": "", "headers": headers, "fingerprint": {}}
else:
profiles[name]["headers"] = headers

db.save_data(profiles)

return headers

return headers

Expand Down

0 comments on commit d72ca17

Please sign in to comment.