Files
faction_war_dispatch_bot/services/ffscouter.py
2026-01-28 16:13:32 -05:00

22 lines
674 B
Python

import aiohttp
import config
async def fetch_batch_stats(ids: list[int]):
#Fetches predicted stats for a list of Torn IDs in a single FFScouter request.
#Returns dict keyed by player_id.
if not ids:
return {}
ids_str = ",".join(map(str, ids))
url = f"https://ffscouter.com/api/v1/get-stats?key={config.FFSCOUTER_KEY}&targets={ids_str}"
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
if resp.status != 200:
print("FFScouter batch error:", resp.status)
return {}
data = await resp.json()
return {str(d["player_id"]): d for d in data}