dynamic config reloading

This commit is contained in:
2026-01-28 16:13:32 -05:00
parent 1fbea7e701
commit a1ff38424b
6 changed files with 131 additions and 80 deletions

View File

@@ -1,7 +1,7 @@
# services/torn_api.py
import aiohttp
import asyncio
from config import TORN_API_KEY
import config
from .ffscouter import fetch_batch_stats
from .server_state import STATE
@@ -21,7 +21,7 @@ async def populate_faction(faction_id: int, kind: str):
#Fetch members + FFScouter estimates once and store in STATE.
#kind: "friendly" or "enemy"
url = f"https://api.torn.com/v2/faction/{faction_id}?selections=members&key={TORN_API_KEY}"
url = f"https://api.torn.com/v2/faction/{faction_id}?selections=members&key={config.TORN_API_KEY}"
try:
async with aiohttp.ClientSession() as session:
@@ -86,7 +86,7 @@ async def refresh_status_loop(faction_id: int, kind: str, lock: asyncio.Lock, in
#Periodically refresh member statuses in STATE.
while True:
try:
url = f"https://api.torn.com/v2/faction/{faction_id}?selections=members&key={TORN_API_KEY}"
url = f"https://api.torn.com/v2/faction/{faction_id}?selections=members&key={config.TORN_API_KEY}"
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
if resp.status != 200: