-
Notifications
You must be signed in to change notification settings - Fork 325
Expand file tree
/
Copy pathsetup.py
More file actions
69 lines (52 loc) · 1.78 KB
/
setup.py
File metadata and controls
69 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""
setup.py — automatic bearer token collection for Dawn Validator BOT.
Script:
- reads emails.txt and captcha_key.txt
- simulates the login and token retrieval process
- saves tokens to tokens.json
Actual HTTP automation can be implemented inside the fetch_token_for_email function.
"""
from __future__ import annotations
import hashlib
import time
from typing import Dict
from config_manager import (
read_emails,
read_captcha_key,
save_tokens,
)
from ui import print_title, info, warn, error, pause
def fetch_token_for_email(email: str, captcha_key: str) -> str:
"""
Stub for actual bearer token retrieval.
Implement here:
- automated login via HTTP/browser
- captcha bypass with 2captcha
- bearer token extraction from responses
"""
seed = f"{email}:{captcha_key}:{time.time()}".encode("utf-8")
return hashlib.sha256(seed).hexdigest()
def run_setup() -> None:
print_title("Automatic Token Setup (setup.py)")
emails = read_emails()
if not emails:
error("No emails found in emails.txt — configure accounts before running Setup.")
pause()
return
captcha_key = read_captcha_key()
if not captcha_key:
error("Captcha key not found — configure captcha_key.txt before running Setup.")
pause()
return
warn(f"Automatic token collection will be performed for {len(emails)} accounts.")
tokens: Dict[str, str] = {}
for idx, email in enumerate(emails, start=1):
info(f"[{idx}/{len(emails)}] Retrieving token for {email} ...")
token = fetch_token_for_email(email, captcha_key)
tokens[email] = token
time.sleep(0.3)
save_tokens(tokens)
info("Setup complete. You can now start the main bot.")
pause()
if __name__ == "__main__":
run_setup()