72 lines
2.4 KiB
Python
72 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Гипотеза: грант Theos начисляется при заходе в веб-чат, а не по API-чеку.
|
|
|
|
Берёт N аккаунтов с granted=0, открывает страницу /chat/ai-code браузерными
|
|
заголовками, затем читает /deepai_code/theos и печатает до/после.
|
|
|
|
python theo_grant_probe.py [N]
|
|
"""
|
|
import json
|
|
import sys
|
|
import time
|
|
|
|
import dpcode as D
|
|
|
|
UA_BROWSER = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
"(KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36")
|
|
|
|
|
|
def rows(n):
|
|
recs = {}
|
|
for line in open(D.BANK, encoding="utf-8"):
|
|
line = line.strip()
|
|
if not line:
|
|
continue
|
|
r = json.loads(line)
|
|
if r.get("cookies"):
|
|
recs[r["email"]] = r
|
|
zero = [r for r in recs.values()
|
|
if float(((r.get("theos") or {}).get("granted")) or 0) == 0]
|
|
return zero[:n]
|
|
|
|
|
|
def bal(s, machine):
|
|
st, d = D.theos(s, machine)
|
|
if isinstance(d, dict):
|
|
return st, d.get("balance"), d.get("granted"), d.get("refresh_at")
|
|
return st, None, None, None
|
|
|
|
|
|
def visit(s):
|
|
h = {"User-Agent": UA_BROWSER, "Accept": "text/html,application/xhtml+xml,*/*;q=0.8",
|
|
"Accept-Language": "en-US,en;q=0.9", "Referer": "https://deepai.org/"}
|
|
out = []
|
|
for url in ("https://deepai.org/chat/ai-code", "https://deepai.org/dashboard"):
|
|
try:
|
|
r = s.get(url, headers=h, timeout=45)
|
|
out.append("%s %s" % (url.rsplit("/", 1)[-1], r.status_code))
|
|
except Exception as e:
|
|
out.append("%s ERR %s" % (url.rsplit("/", 1)[-1], str(e)[:40]))
|
|
time.sleep(1.0)
|
|
return ",".join(out)
|
|
|
|
|
|
def main():
|
|
n = int(sys.argv[1]) if len(sys.argv) > 1 else 5
|
|
for rec in rows(n):
|
|
email = rec["email"]
|
|
machine = rec.get("machine") or D.machine_header(salt=email)
|
|
s = D.session_from(rec)
|
|
before = bal(s, machine)
|
|
v = visit(s)
|
|
time.sleep(1.5)
|
|
after = bal(s, machine)
|
|
print("%-42s visit[%s] before=%s/%s after=%s/%s refresh=%s"
|
|
% (email, v, before[1], before[2], after[1], after[2], after[3]), flush=True)
|
|
if float(after[1] or 0) > 0:
|
|
rec["theos"] = {"balance": after[1], "granted": after[2], "refresh_at": after[3]}
|
|
D.append_bank(rec)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |