import json import os from notify import hooknotify def goldeval(player_file): """Evaluate gold market surplus and send alerts if needed.""" if not os.path.exists(player_file): print(f"❌ File not found: {player_file}") return try: with open(player_file, "r", encoding="utf-8") as f: data = json.load(f) title = data.get("gold_market_title", "Unknown Title") timestamp = data.get("server_received_at", "Unknown Time") market = data.get("gold_market", {}) for resource in ["wood", "stone", "iron"]: res_data = market.get(resource, {}) current = int(res_data.get("current", "0").replace(",", "")) max_val = int(res_data.get("max", "0").replace(",", "")) surplus = max_val - current if surplus > 1000: print(f"📢 Surplus detected: {resource} = {surplus}") hooknotify(timestamp, title, resource, surplus) except Exception as e: print("💥 Error in goldeval:", e)