style(services): reorder imports and formatting
This commit is contained in:
+11
-5
@@ -1,8 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
import logging
|
|
||||||
import random
|
import random
|
||||||
|
import asyncio
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import requests as plain_requests
|
import requests as plain_requests
|
||||||
@@ -39,7 +38,9 @@ def _extract_new_cookie(response):
|
|||||||
return cookie
|
return cookie
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
sc = response.headers.get("set-cookie", "") or response.headers.get("Set-Cookie", "")
|
sc = response.headers.get("set-cookie", "") or response.headers.get(
|
||||||
|
"Set-Cookie", ""
|
||||||
|
)
|
||||||
if ".ROBLOSECURITY=" in sc:
|
if ".ROBLOSECURITY=" in sc:
|
||||||
try:
|
try:
|
||||||
return sc.split(".ROBLOSECURITY=")[1].split(";")[0]
|
return sc.split(".ROBLOSECURITY=")[1].split(";")[0]
|
||||||
@@ -132,7 +133,9 @@ def _sync_fresh_cookie(cookie, proxy=None, timeout=15):
|
|||||||
|
|
||||||
async def fresh_cookie_async(cookie, proxy=None):
|
async def fresh_cookie_async(cookie, proxy=None):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
return await loop.run_in_executor(FRESHER_POOL, _sync_fresh_cookie, cookie, proxy, 15)
|
return await loop.run_in_executor(
|
||||||
|
FRESHER_POOL, _sync_fresh_cookie, cookie, proxy, 15
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def check_cookie_basic(session, cookie, proxy=None) -> CookieValidationResult:
|
async def check_cookie_basic(session, cookie, proxy=None) -> CookieValidationResult:
|
||||||
@@ -234,7 +237,10 @@ async def get_year_donate(cookie, user_id, proxy=None) -> int:
|
|||||||
proxy=f"http://{proxy}" if proxy else None,
|
proxy=f"http://{proxy}" if proxy else None,
|
||||||
timeout=aiohttp.ClientTimeout(total=REQUEST_TIMEOUT),
|
timeout=aiohttp.ClientTimeout(total=REQUEST_TIMEOUT),
|
||||||
) as response:
|
) as response:
|
||||||
if response.status == 200 and response.content_type == "application/json":
|
if (
|
||||||
|
response.status == 200
|
||||||
|
and response.content_type == "application/json"
|
||||||
|
):
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
donate = data.get("purchasesTotal", 0)
|
donate = data.get("purchasesTotal", 0)
|
||||||
if donate != 0:
|
if donate != 0:
|
||||||
|
|||||||
@@ -79,4 +79,5 @@ async def check_treasury_invoice(invoice_id: int) -> bool:
|
|||||||
return bool(items and items[0].get("status") == "paid")
|
return bool(items and items[0].get("status") == "paid")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logging.error("check_treasury_invoice: %s", exc)
|
logging.error("check_treasury_invoice: %s", exc)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user