From 01d9cc021b033184646b48cefb82b90d579b2d33 Mon Sep 17 00:00:00 2001 From: Exteriorgluform Date: Wed, 21 Oct 2026 00:30:13 +0300 Subject: [PATCH] feat(secondno): working 2nd-no.com registration flow - reg2no_fast.py: signup (BOTH password fields + checkbox -- _FILL_JS only filled one, confirm-empty blocked submit) -> save pending creds IMMEDIATELY (password survives t-online confirm-email lag) -> SENTSINCE email poll (420s) -> goto create-account link (fresh token, auto-creates) -> login -> reserve - complete_pending_2no.py: finish pending accounts (login -> get_number -> state.json) - complete_secondno.py: separate t-online IMAP password (read mail) from 2nd-no account password (login) -- was passing 2nd-no pw to IMAP -> login fail - client.py: IMAP4_SSL timeout=30 (t-online throttle fail-fast), wait_email SENTSINCE+FROM fallback, SECONDNO_PROXY (fresh IP bypasses 2-per-IP signup limit) - VERIFIED: signup 200 success, create-account 'Account created', login OK (/app/numbers), free number found via _call(310). Reserve needs turnstile token (sidecar/2captcha -- see captcha.py). --- complete_pending_2no.py | 93 ++++++++++++++++++ complete_secondno.py | 82 ++++++++++++++++ reg2no_fast.py | 202 ++++++++++++++++++++++++++++++++++++++++ secondno/__init__.py | 5 +- secondno/client.py | 144 +++++++++++++++++++++++++++- secondno_register.py | 10 +- 6 files changed, 526 insertions(+), 10 deletions(-) create mode 100644 complete_pending_2no.py create mode 100644 complete_secondno.py create mode 100644 reg2no_fast.py diff --git a/complete_pending_2no.py b/complete_pending_2no.py new file mode 100644 index 0000000..2e7adc9 --- /dev/null +++ b/complete_pending_2no.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 +"""complete_pending_2no.py -- finish 2nd-no accounts saved in pending.json. + +For each pending account (signup done, password retained): login -> reserve a +free PL number -> save to state.json -> drop from pending. Run after reg2no_fast +exited on t-online lag, or to reserve a number for an already-confirmed account. + +Env: SECONDNO_PROXY (fresh IP for the browser). +""" +from __future__ import annotations + +import json +import os +import sys +import time + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +ROOT = os.path.dirname(os.path.abspath(__file__)) +os.environ.setdefault("SECONDNO_HOME", os.path.join(ROOT, "data", "secondno")) + +from secondno import SecondNo, get_solver + +PEND = os.path.join(ROOT, "data", "secondno", "pending.json") +STATE = os.path.join(ROOT, "data", "secondno", "state.json") + + +def log(*a): + print(f"[{time.strftime('%H:%M:%S')}]", *a, flush=True) + + +def load(p, default): + if os.path.exists(p): + try: + return json.load(open(p, encoding="utf-8")) + except Exception: + return default + return default + + +def save(p, obj): + tmp = p + ".tmp" + with open(tmp, "w", encoding="utf-8") as f: + json.dump(obj, f, indent=2, ensure_ascii=False) + os.replace(tmp, p) + + +def main(): + pend = load(PEND, []) + if not pend: + log("no pending accounts"); return + state = load(STATE, {"accounts": []}) + state.setdefault("accounts", []) + done_emails = {a.get("email") for a in state["accounts"]} + + s = SecondNo(solver=get_solver(), headless=True) + s._start() + still = [] + try: + for p in pend: + email = p.get("email"); pwd = p.get("password") + if not email or not pwd: + continue + if email in done_emails: + log("already in state:", email[:8] + "***"); continue + try: + log("login", email[:8] + "***") + s.login(email, pwd) + num = s.get_number() + log("RESERVED", num.get("full"), "expires", num.get("expires")) + state["accounts"].append({ + "email": email, "password": pwd, + "imap_user": p.get("imap_user"), "imap_pw": p.get("imap_pw"), + "full": num.get("full"), "number": num.get("number"), + "country": "PL", "number_id": num.get("number_id"), + "user_number_id": num.get("user_number_id"), + "reserved_at": int(time.time()), "expires": num.get("expires", ""), + "used": False, "last_otp_at": 0, + }) + save(STATE, state) + done_emails.add(email) + log("SAVED -> state.json accounts:", len(state["accounts"])) + except Exception as e: + log("FAIL", email[:8] + "***", repr(e)[:140]) + still.append(p) + # keep only the ones that failed + save(PEND, still) + log("pending remaining:", len(still)) + finally: + s.close() + + +if __name__ == "__main__": + main() diff --git a/complete_secondno.py b/complete_secondno.py new file mode 100644 index 0000000..c88425b --- /dev/null +++ b/complete_secondno.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +"""Complete a 2nd-no.com account that already SIGNED UP (confirmation email sent) +but is not yet confirmed/logged-in. Reads credentials from env (no secrets in file). + +Usage: + ACC_EMAIL=... ACC_PWD=... SECONDNO_PROXY=http://127.0.0.1:8899 \ + python complete_secondno.py + +Flow: wait confirm email (t-online IMAP, UID scan, specific 2nd-no keywords) + -> click confirm link (browser via proxy) -> login -> reserve number + -> save to data/secondno/state.json +""" +import json +import os +import re +import sys +import time + +sys.stdout.reconfigure(encoding="utf-8") +ROOT = os.path.dirname(os.path.abspath(__file__)) +os.environ.setdefault("SECONDNO_HOME", os.path.join(ROOT, "data", "secondno")) +sys.path.insert(0, ROOT) + +from secondno import SecondNo, TOnlineIMAP, get_solver # noqa: E402 +from secondno.client import save_account # noqa: E402 + + +def main(): + email = os.environ.get("ACC_EMAIL", "") + pwd = os.environ.get("ACC_PWD", "") # 2nd-no.com account password + if not email or not pwd: + print(json.dumps({"error": "need ACC_EMAIL and ACC_PWD env"})) + sys.exit(2) + + # The t-online IMAP password (to READ the confirmation mail) is DIFFERENT from + # the 2nd-no account password (to LOGIN). Look up the IMAP creds in mail_pool. + pool = TOnlineIMAP._load_pool(os.path.join(ROOT, "data", "mail_pool.txt")) + imap_acc = next((a for a in pool if a[0] == email), None) + if not imap_acc: + print(json.dumps({"error": f"ACC_EMAIL {email[:8]}*** not found in mail_pool.txt"})) + sys.exit(2) + + ib = TOnlineIMAP(account=imap_acc) # t-online IMAP creds + # Confirmation email was already sent at signup -> do NOT snapshot a baseline + # now (it would skip the email). Empty baseline = scan all, keyword-filtered. + ib._baseline = set() + + s = SecondNo(solver=get_solver(), headless=True) + try: + print(f"[complete] waiting confirm email for {email[:8]}*** ...", flush=True) + msg = ib.wait_email(email, timeout=900) + if not msg: + print(json.dumps({"error": "no confirm email (t-online lag or signup failed)"})) + sys.exit(1) + body = msg.get("raw", "") or "" + links = re.findall(r"https?://[^\s\"'<>]+", body) + link = next((l for l in links if "create-account" in l or "confirm" in l), None) + if not link: + print(json.dumps({"error": "no confirm link in email", "links": links[:3]})) + sys.exit(1) + print(f"[complete] confirm link found, verifying ...", flush=True) + pg = s._start() + pg.goto(link, wait_until="domcontentloaded", timeout=60000) + pg.wait_for_timeout(3000) + print(f"[complete] confirmed, logging in ...", flush=True) + s.login(email, pwd) + print(f"[complete] logged in, reserving number ...", flush=True) + info = s.get_number() + rec = {"email": email, "password": pwd, **info, "ts": int(time.time())} + save_account(rec) + print(json.dumps({"ok": True, "email": email[:8] + "***", + "number": info.get("full"), "expires": info.get("expires")}, + ensure_ascii=False)) + except Exception as e: + print(json.dumps({"error": str(e)[:200]})) + sys.exit(1) + finally: + s.close() + + +if __name__ == "__main__": + main() diff --git a/reg2no_fast.py b/reg2no_fast.py new file mode 100644 index 0000000..6010bb9 --- /dev/null +++ b/reg2no_fast.py @@ -0,0 +1,202 @@ +#!/usr/bin/env python3 +"""reg2no_fast.py -- register a 2nd-no.com account and CONFIRM it FAST (fresh token). + +Acc#2 died because the create-account token expired between signup and confirm +(t-online lag + retries). This does signup -> poll confirm email every 5s -> goto +link immediately -> verify creation -> login -> reserve -> save. One tight flow. + +Usage: python reg2no_fast.py [pool_index] +Env: SECONDNO_PROXY (fresh IP, e.g. http://127.0.0.1:8899) +""" +from __future__ import annotations + +import base64 +import datetime as _dt +import json +import os +import random +import re +import string +import sys +import time + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +ROOT = os.path.dirname(os.path.abspath(__file__)) +os.environ.setdefault("SECONDNO_HOME", os.path.join(ROOT, "data", "secondno")) + +import imaplib +import email as _email + +from secondno import SecondNo, get_solver +from secondno.client import TOnlineIMAP, _FILL_JS, SITE + +POOL_FILE = os.path.join(ROOT, "data", "mail_pool.txt") +STATE = os.path.join(ROOT, "data", "secondno", "state.json") + + +def log(*a): + print(f"[{time.strftime('%H:%M:%S')}]", *a, flush=True) + + +def fetch_link(imap_user, imap_pw, target, max_wait=180): + """Poll t-online IMAP for the 2nd-no create-account link (fresh).""" + since = (_dt.date.today() - _dt.timedelta(days=1)).strftime("%d-%b-%Y") + deadline = time.time() + max_wait + while time.time() < deadline: + try: + M = imaplib.IMAP4_SSL("secureimap.t-online.de", 993, timeout=30) + M.login(imap_user, imap_pw) + M.select("INBOX") + typ, data = M.uid("SEARCH", None, f"(SENTSINCE {since})") + uids = data[0].split() if data and data[0] else [] + link = "" + for uid in reversed(uids[-25:]): + typ, md = M.uid("FETCH", uid, "(RFC822)") + if not md or not md[0]: + continue + msg = _email.message_from_bytes(md[0][1]) + body = "" + for part in msg.walk(): + if part.get_content_type() in ("text/plain", "text/html"): + try: + body += part.get_payload(decode=True).decode( + part.get_content_charset() or "utf-8", "ignore") + except Exception: + pass + if "create-account" in body.lower(): + ls = re.findall(r"https?://[^\s\"'<>]+", body) + link = next((l for l in ls if "create-account" in l), "") + if link: + break + M.logout() + if link: + return link + except Exception as e: + log("imap retry:", repr(e)[:60]) + time.sleep(5) + return "" + + +def main(): + idx = int(sys.argv[1]) if len(sys.argv) > 1 else 3 + pool = TOnlineIMAP._load_pool(POOL_FILE) + if idx >= len(pool): + log("pool index out of range"); sys.exit(2) + imap_user, imap_pw = pool[idx] + email_addr = imap_user + pwd = "Nx" + "".join(random.choices(string.ascii_letters + string.digits, k=8)) + "7!q" + log(f"acc#{idx} email={email_addr[:8]}*** proxy={os.environ.get('SECONDNO_PROXY','none')}") + + s = SecondNo(solver=get_solver(), headless=True) + pg = s._start() + try: + # 1) signup + pg.goto(SITE + "/auth/register", wait_until="domcontentloaded", timeout=60000) + pg.wait_for_selector("input[type=password]", timeout=30000) + pg.wait_for_timeout(1500) + # register() fills BOTH password fields (password + confirm) + checkbox. + # _FILL_JS only fills ONE password -> confirm empty -> submit blocked (st=None). + ok = pg.evaluate("""(args) => { + const setVal = (el, v) => { const setter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(el), 'value').set; + setter.call(el, v); el.dispatchEvent(new Event('input', {bubbles: true})); + el.dispatchEvent(new Event('change', {bubbles: true})); }; + const inputs = Array.from(document.querySelectorAll('input')); + const txt = inputs.find(i => i.type === 'text' || i.type === 'email'); + const pws = inputs.filter(i => i.type === 'password'); + const cb = inputs.find(i => i.type === 'checkbox'); + if (!txt || pws.length < 2) return 'inputs missing'; + setVal(txt, args[0]); setVal(pws[0], args[1]); setVal(pws[1], args[1]); + if (cb && !cb.checked) cb.click(); + return 'ok'; + }""", [email_addr, pwd]) + log("fill:", ok) + pg.wait_for_timeout(500) + signup = {} + def cap(r): + if r.request.method == "POST" and "2no.pl" in r.url and '"id":103' in (r.request.post_data or ""): + try: + signup["st"] = r.status; signup["resp"] = r.text()[:120] + except Exception: + pass + pg.on("response", cap) + pg.click("button[type=submit]", timeout=8000) + pg.wait_for_timeout(6000) + log("signup:", signup.get("st"), signup.get("resp", "")[:60]) + if signup.get("st") != 200: + log("SIGNUP FAILED (likely IP limit) ->", signup.get("resp", "")) + sys.exit(1) + + # 1b) SAVE PENDING CREDS IMMEDIATELY (never lose the password if the + # confirm email lags past our wait -- t-online can take 10+ min). + pend_file = os.path.join(ROOT, "data", "secondno", "pending.json") + os.makedirs(os.path.dirname(pend_file), exist_ok=True) + pend = [] + if os.path.exists(pend_file): + try: + pend = json.load(open(pend_file, encoding="utf-8")) + except Exception: + pend = [] + pend = [p for p in pend if p.get("email") != email_addr] + pend.append({"email": email_addr, "password": pwd, + "imap_user": imap_user, "imap_pw": imap_pw, + "signed_at": int(time.time())}) + with open(pend_file, "w", encoding="utf-8") as f: + json.dump(pend, f, indent=2, ensure_ascii=False) + log("pending creds saved (password retained)") + + # 2) fetch confirm link FAST (t-online lag -> wait up to 7 min) + t0 = time.time() + link = fetch_link(imap_user, imap_pw, email_addr, max_wait=420) + if not link: + log("no confirm email in 180s (t-online lag) -- retry later") + sys.exit(1) + log(f"confirm link found in {time.time()-t0:.0f}s, confirming NOW") + + # 3) goto create-account link (fresh token) + pg.goto(link, wait_until="domcontentloaded", timeout=60000) + pg.wait_for_timeout(5000) + body = pg.evaluate("()=>document.body.innerText.replace(/\\s+/g,' ').slice(0,200)") + log("create-account page:", repr(body[:120])) + if "not created" in body.lower() or "went wrong" in body.lower(): + log("ACCOUNT CREATION FAILED (token/page issue)") + sys.exit(1) + + # 4) login + reserve + ok = s.login(email_addr, pwd) + log("login:", ok, "url:", pg.url) + num = s.get_number() + if not num: + log("reserve failed") + sys.exit(1) + log("RESERVED:", num.get("full")) + + # 5) save + os.makedirs(os.path.dirname(STATE), exist_ok=True) + st = {"accounts": []} + if os.path.exists(STATE): + try: + st = json.load(open(STATE, encoding="utf-8")) + except Exception: + st = {"accounts": []} + st.setdefault("accounts", []).append({ + "email": email_addr, "password": pwd, + "imap_user": imap_user, "imap_pw": imap_pw, + "full": num.get("full"), "country": num.get("country"), + "reservation_id": num.get("reservation_id"), + "reserved_at": int(time.time()), "expires": num.get("expires", ""), + "used": False, "last_otp_at": 0, + }) + tmp = STATE + ".tmp" + with open(tmp, "w", encoding="utf-8") as f: + json.dump(st, f, indent=2, ensure_ascii=False) + os.replace(tmp, STATE) + log("SAVED to state.json -- accounts:", len(st["accounts"])) + except Exception as e: + log("ERR", repr(e)[:200]) + sys.exit(1) + finally: + s.close() + + +if __name__ == "__main__": + main() diff --git a/secondno/__init__.py b/secondno/__init__.py index 6e28813..9bec29b 100644 --- a/secondno/__init__.py +++ b/secondno/__init__.py @@ -1,8 +1,9 @@ -from .client import SecondNo, TempMailLol, GmailForwardInbox, full_cycle, SITEKEY, API, SITE +from .client import (SecondNo, TempMailLol, GmailForwardInbox, TOnlineIMAP, + full_cycle, SITEKEY, API, SITE) from .captcha import (get_solver, get_sidecar, get_2captcha, test_solve, captcha_status, TwoCaptchaTurnstile, SidecarSolver, CaptchaRouter) -__all__ = ["SecondNo", "TempMailLol", "GmailForwardInbox", "full_cycle", +__all__ = ["SecondNo", "TempMailLol", "GmailForwardInbox", "TOnlineIMAP", "full_cycle", "get_solver", "get_sidecar", "get_2captcha", "test_solve", "captcha_status", "TwoCaptchaTurnstile", "SidecarSolver", "CaptchaRouter", "SITEKEY", "API", "SITE"] diff --git a/secondno/client.py b/secondno/client.py index 335a869..38f1341 100644 --- a/secondno/client.py +++ b/secondno/client.py @@ -112,6 +112,128 @@ class GmailForwardInbox: return None +class TOnlineIMAP: + """t-online.de IMAP inbox from data/mail_pool.txt (legit ISP domain — NOT blocked + by 2nd-no.com the way disposable tempmail domains are). t-online mail can lag + minutes -> long WAIT_TIMEOUT. Decodes QP/base64 so register()'s confirm-link + regex matches. Each factory call rotates to the next pool account.""" + IMAP_HOST = "secureimap.t-online.de" + WAIT_TIMEOUT = 900 + _POOL = None + _IDX = [0] + + def __init__(self, pool_file=None, account=None): + self._imaplib = __import__("imaplib") + self._email = __import__("email") + pf = pool_file or os.path.join(os.path.dirname(HOME), "mail_pool.txt") + self.account = account or self._pick(pf) + self.addr = self.account[0] + self.pw = self.account[1] + + @classmethod + def _load_pool(cls, pf): + if cls._POOL is None: + pool = [] + try: + for ln in open(pf, encoding="utf-8", errors="ignore"): + ln = ln.strip() + if not ln or ln.startswith("#") or "@" not in ln or ":" not in ln: + continue + e, _, p = ln.partition(":") + pool.append((e.strip(), p.strip())) + except Exception: + pool = [] + cls._POOL = pool + return cls._POOL + + @classmethod + def _pick(cls, pf): + pool = cls._load_pool(pf) + if not pool: + raise RuntimeError("mail_pool.txt empty/missing") + i = cls._IDX[0] % len(pool) + cls._IDX[0] += 1 + return pool[i] + + def make_address(self, tag=None): + # Snapshot existing UIDs so wait_email only considers NEW mail (the pool + # accounts have dozens of old messages that would false-match). + self._baseline = self._current_uids() + return self.addr + + def _connect(self): + # timeout guards against t-online IMAP throttling (accepts TCP but stalls + # on login/search after many rapid connections) -> fail fast, retry in loop. + M = self._imaplib.IMAP4_SSL(self.IMAP_HOST, 993, timeout=30) + M.login(self.addr, self.pw) + M.select("INBOX") + return M + + def _current_uids(self): + try: + M = self._connect() + typ, data = M.uid("SEARCH", None, "ALL") + uids = set(data[0].split()) + M.logout() + return uids + except Exception: + return set() + + def wait_email(self, target_email, timeout=None, poll=10): + timeout = timeout or self.WAIT_TIMEOUT + baseline = getattr(self, "_baseline", None) + if baseline is None: + baseline = set() + # Fast path: SENTSINCE limits the scan to ~last day of mail. Pool accounts + # have 1000s of old spam; fetching ALL would never finish in time. + since = time.strftime("%d-%b-%Y", time.localtime(time.time() - 86400)) + deadline = time.time() + timeout + while time.time() < deadline: + try: + M = self._connect() + # Targeted: only mail from the 2nd-no sender (kontakt@2nr.pl / + # 2nd-no.com). Fetching all SENTSINCE mail is too slow on pool + # accounts that receive a spam flood (100s/day). + typ, data = M.uid("SEARCH", None, f'(SENTSINCE {since} FROM "2nr")') + uids = data[0].split() + if not uids: + typ, data = M.uid("SEARCH", None, f'(SENTSINCE {since} FROM "2nd-no")') + uids = data[0].split() + if not uids: + typ, data = M.uid("SEARCH", None, f"(SENTSINCE {since})") + uids = data[0].split() + for uid in reversed(uids): + if uid in baseline: + continue + typ, md = M.uid("FETCH", uid, "(RFC822)") + if not md or not md[0]: + continue + msg = self._email.message_from_bytes(md[0][1]) + txt = self._decode(msg) + low = txt.lower() + if ("2nd-no" in low or "2nr" in low or "create-account" in low) and "http" in low: + M.logout() + return {"raw": txt} + M.logout() + except Exception: + pass + time.sleep(poll) + return None + + def _decode(self, msg): + out = [] + for part in msg.walk(): + if part.get_content_type() in ("text/plain", "text/html"): + try: + payload = part.get_payload(decode=True) + if payload: + cs = part.get_content_charset() or "utf-8" + out.append(payload.decode(cs, "ignore")) + except Exception: + pass + return "\n".join(out) + + _FILL_JS = """(args) => { let n = 0; const setVal = (el, v) => { if (!el) return; try { @@ -141,11 +263,15 @@ class SecondNo: def _start(self): if self._pg is None: self._pw = sync_playwright().start() + # SECONDNO_PROXY routes the browser through a fresh IP (2nd-no limits + # free registrations to ~2 per IP -> RegistrationLimitReached 403). + prox = os.environ.get("SECONDNO_PROXY", "").strip() + kw = {"proxy": {"server": prox}} if prox else {} try: self._browser = self._pw.chromium.launch( headless=self.headless, channel="chrome", args=["--no-sandbox", "--disable-blink-features=AutomationControlled", - "--window-position=2400,2400"]) + "--window-position=2400,2400"], **kw) except Exception: # channel="chrome" fails when SYSTEMDRIVE-ish env is broken # (playwright resolves "undefined\Program Files\..."); use @@ -153,7 +279,7 @@ class SecondNo: self._browser = self._pw.chromium.launch( headless=self.headless, args=["--no-sandbox", "--disable-blink-features=AutomationControlled", - "--window-position=2400,2400"]) + "--window-position=2400,2400"], **kw) ctx = self._browser.new_context(user_agent=UA, locale="en-US") self._pg = ctx.new_page() self._pg.add_init_script("Object.defineProperty(navigator,'webdriver',{get:()=>undefined})") @@ -216,16 +342,24 @@ class SecondNo: raise RuntimeError(f"register fill failed: {ok}") pg.evaluate("() => document.querySelector('button[type=submit]').click()") pg.wait_for_timeout(6000) + # debug: did signup succeed / what does the page say? + try: + print(f"[secondno] post-signup url={pg.url}", flush=True) + snip = pg.evaluate("() => document.body ? document.body.innerText.replace(/\\s+/g,' ').slice(0,240) : ''") + print(f"[secondno] page: {snip!r}", flush=True) + except Exception: + pass # confirm email msg = None + _to = getattr(inbox, "WAIT_TIMEOUT", 180) if hasattr(inbox, "wait_email"): try: - msg = inbox.wait_email(sender="2nr", timeout=180) + msg = inbox.wait_email(sender="2nr", timeout=_to) except TypeError: - msg = inbox.wait_email(email, timeout=180) + msg = inbox.wait_email(email, timeout=_to) if msg is None and hasattr(inbox, "wait_email"): try: - msg = inbox.wait_email(email, timeout=60) + msg = inbox.wait_email(email, timeout=min(_to, 120)) except Exception: msg = None link = None diff --git a/secondno_register.py b/secondno_register.py index 70c3be4..825c7fc 100644 --- a/secondno_register.py +++ b/secondno_register.py @@ -21,14 +21,18 @@ ROOT = os.path.dirname(os.path.abspath(__file__)) os.environ.setdefault("SECONDNO_HOME", os.path.join(ROOT, "data", "secondno")) sys.path.insert(0, ROOT) -from secondno import full_cycle, GmailForwardInbox # noqa: E402 +from secondno import full_cycle, GmailForwardInbox, TOnlineIMAP # noqa: E402 def main(): args = [a for a in sys.argv[1:] if not a.startswith("--")] n = int(args[0]) if args else 1 - inbox_factory = GmailForwardInbox if "--gmail" in sys.argv else None - results = full_cycle(n, inbox_factory=inbox_factory) + inbox_factory = None + if "--gmail" in sys.argv: + inbox_factory = GmailForwardInbox + elif "--tonline" in sys.argv: + inbox_factory = TOnlineIMAP + results = full_cycle(n, inbox_factory=inbox_factory, headless=True) ok = 0 for r in results: print(json.dumps(r, ensure_ascii=False), flush=True)