docs: invite mechanics - why balance is 0 and how to get your own /i/ link
This commit is contained in:
+21
-2
@@ -269,6 +269,18 @@ def pool_enroll(s: Session) -> dict:
|
||||
return {"http": st, "body": body[:160]}
|
||||
|
||||
|
||||
def invite_summary(s: Session) -> dict:
|
||||
"""Own referral link + counters (the page does exactly this fetch)."""
|
||||
st, _h, body, _f = s.request(BASE + "/invite/summary",
|
||||
headers={"Accept": "application/json"})
|
||||
if st != 200:
|
||||
return {"http": st, "raw": body[:120]}
|
||||
try:
|
||||
return json.loads(body)
|
||||
except Exception:
|
||||
return {"http": st, "raw": body[:120]}
|
||||
|
||||
|
||||
def create_key(s: Session, name: str = "auto") -> dict:
|
||||
payload = {"name": name, "filter_mode": "all", "allowed_models": []}
|
||||
st, _h, body, _f = s.request(BASE + "/pool/keys", data=json.dumps(payload).encode(),
|
||||
@@ -328,7 +340,8 @@ def list_models(api_key: str) -> dict:
|
||||
# one account
|
||||
# --------------------------------------------------------------------------- #
|
||||
def run_account(cookie: str, invite: str = "", proxy: str | None = None,
|
||||
want_key: bool = True, model: str = "deepseek-v4-flash") -> dict:
|
||||
want_key: bool = True, model: str = "deepseek-v4-flash",
|
||||
want_invite: bool = False) -> dict:
|
||||
s = gh_cookie_session(cookie, proxy)
|
||||
t0 = time.time()
|
||||
res: dict = {"ok": False}
|
||||
@@ -356,6 +369,9 @@ def run_account(cookie: str, invite: str = "", proxy: str | None = None,
|
||||
res["balance_after_enroll"] = bal
|
||||
res["spendable"] = bal.get("spendable")
|
||||
|
||||
if want_invite:
|
||||
res["my_invite"] = invite_summary(s)
|
||||
|
||||
if want_key:
|
||||
k = create_key(s)
|
||||
res["key_http"] = k["http"]
|
||||
@@ -383,6 +399,8 @@ def main() -> int:
|
||||
ap.add_argument("--proxy", default=os.environ.get("HTTPS_PROXY", ""))
|
||||
ap.add_argument("--model", default="deepseek-v4-flash")
|
||||
ap.add_argument("--no-key", action="store_true", help="stop after balance")
|
||||
ap.add_argument("--my-invite", action="store_true",
|
||||
help="also print your own /i/<code> referral link (GET /invite/summary)")
|
||||
ap.add_argument("--json", action="store_true")
|
||||
args = ap.parse_args()
|
||||
|
||||
@@ -400,7 +418,8 @@ def main() -> int:
|
||||
|
||||
rc = 0
|
||||
for i, c in enumerate(cookies, 1):
|
||||
res = run_account(c, args.invite, args.proxy or None, not args.no_key, args.model)
|
||||
res = run_account(c, args.invite, args.proxy or None, not args.no_key, args.model,
|
||||
args.my_invite)
|
||||
if args.json:
|
||||
print(json.dumps(res))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user