feat: min balance
This commit is contained in:
parent
fc555244a8
commit
84ad98b4d3
3 changed files with 6 additions and 1 deletions
|
|
@ -7,6 +7,9 @@ TARGET_SIZE=5
|
|||
# Poll interval for checking new accounts when pool incomplete (seconds)
|
||||
POLL_INTERVAL=30
|
||||
|
||||
# Minimum balance threshold - switch token when balance <= MIN_BALANCE
|
||||
MIN_BALANCE=0
|
||||
|
||||
# HTTPS proxy URL (used by Firefox and balance API)
|
||||
HTTPS_PROXY=http://user:pass@host:port
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ ENV PYTHONUNBUFFERED=1
|
|||
ENV PORT=80
|
||||
ENV TARGET_SIZE=5
|
||||
ENV POLL_INTERVAL=30
|
||||
ENV MIN_BALANCE=0
|
||||
ENV DATA_DIR=/data
|
||||
ENV EXTRAS_DIR=/extras
|
||||
ENV EMAILS_FILE=/data/emails.txt
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ logging.basicConfig(level=logging.INFO)
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
PORT = int(os.environ.get("PORT", 8080))
|
||||
MIN_BALANCE = float(os.environ.get("MIN_BALANCE", "0"))
|
||||
|
||||
|
||||
async def on_startup(app: web.Application):
|
||||
|
|
@ -51,7 +52,7 @@ async def token_handler(request: web.Request) -> web.Response:
|
|||
continue
|
||||
|
||||
balance = balance_data.get("balance", balance_data.get("remaining", 0))
|
||||
if balance is None or balance <= 0:
|
||||
if balance is None or balance <= MIN_BALANCE:
|
||||
await pop_token()
|
||||
await trigger_refill()
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue