Update app.py
Browse files9 unmodified lines10111213141516171819202122232425262728293031323334353637383940414243442 unmodified lines474849505152535455565758596061626364656667686970719 unmodified linesself.hp = 100self.resources = {"Wood": 0, "Stone": 0, "Food": 0}self.active = Falseself.last_log = "Waiting..."state = BotState()def run_bot_engine():# Fix: Removed 'no_sandbox' from SB() and added it via browser argumentswith SB(uc=True, xvfb=True, chromium_arg="--no-sandbox,--disable-dev-shm-usage") as sb:try:state.status = "๐ Connection Stage..."sb.open("https://moomoo.io")sb.sleep(10) # Give ALTCHA time to compute (it's proof-of-work)state.status = "๐ก๏ธ Solving Security..."# Try to force solve the altcha/checkboxtry:sb.uc_gui_handle_captcha()sb.click('div[class*="altcha"]')except:passsb.sleep(5)state.status = "๐ Entering Game..."sb.type("#nameInput", "Survival_Bot")sb.click("#enterGame")state.active = Truestate.status = "๐ข SURVIVING"while True:game_data = sb.execute_script("""return {hp: parseInt(document.getElementById('healthBar')?.style.width) || 100,2 unmodified linesstone: parseInt(document.getElementById('stoneDisplay')?.innerText) || 0}""")state.hp = game_data['hp']state.resources = {"Wood": game_data['wood'], "Stone": game_data['stone'], "Food": game_data['food']}if state.hp < 80:sb.press_keys("body", "q")time.sleep(0.1)except Exception as e:state.status = "โ Engine Error"state.last_log = f"Error: {str(e)[:50]}"def get_stats():res = state.resourcesreturn f"### ๐ Live Stats\n**Status:** {state.status}\n**HP:** {state.hp}%\n**Wood:** {res['Wood']} | **Stone:** {res['Stone']}\n\n**Action Log:** {state.last_log}"with gr.Blocks() as demo:gr.Markdown("# ๐ฎ Moomoo Survival Bot")display = gr.Markdown("Connecting...")gr.Timer(1.5).tick(get_stats, outputs=display)if __name__ == "__main__":9 unmodified lines101112131415161718192021222324252627282930313233343536373839404142434445464748495051522 unmodified lines5556575859606162636465666768697071727374757677787980819 unmodified linesself.hp = 100self.resources = {"Wood": 0, "Stone": 0, "Food": 0}self.active = Falseself.last_log = "Waiting for game start..."state = BotState()def run_bot_engine():# Use CDP Mode (Chrome DevTools Protocol) for maximum stealthwith SB(uc=True, xvfb=True, chromium_arg="--no-sandbox,--disable-dev-shm-usage") as sb:try:state.status = "๐ Phase 1: Stealth Connection"# Open with a long reconnect to bake the sessionsb.uc_open_with_reconnect("https://moomoo.io", reconnect_time=8)state.status = "๐ก๏ธ Phase 2: Solving Proof-of-Work"# Activate CDP mode - this is the "Force" buttonsb.activate_cdp_mode("https://moomoo.io")sb.sleep(12) # MANDATORY: ALTCHA needs time to compute the puzzle# This handles the click using human-like mouse curvestry:sb.solve_captcha() # Internal SeleniumBase magic for ALTCHA/Turnstilestate.last_log = "Captcha bypassed successfully."except:# Manual fallback: click the center of the ALTCHA widgetsb.click('div[class*="altcha"]')state.last_log = "Manual captcha click attempted."sb.sleep(5)state.status = "๐ Phase 3: Joining Game"sb.type("#nameInput", "AI_Force_Bot")sb.click("#enterGame")state.active = Truestate.status = "๐ข SURVIVING"while True:# Using CDP-safe script executiongame_data = sb.execute_script("""return {hp: parseInt(document.getElementById('healthBar')?.style.width) || 100,2 unmodified linesstone: parseInt(document.getElementById('stoneDisplay')?.innerText) || 0}""")state.hp = game_data['hp']state.resources = {"Wood": game_data['wood'], "Stone": game_data['stone'], "Food": game_data['food']}# Survival Logicif state.hp < 75:sb.press_keys("body", "q")time.sleep(0.1)except Exception as e:state.status = "โ Fatal Engine Error"state.last_log = f"Error: {str(e)[:100]}"def get_stats():res = state.resourcesreturn f"### ๐ Bot Intelligence\n**Status:** {state.status}\n**HP:** {state.hp}%\n**Resources:** ๐ชต {res['Wood']} | ๐ชจ {res['Stone']} | ๐ {res['Food']}\n\n**Log:** {state.last_log}"with gr.Blocks() as demo:gr.Markdown("# ๐ฎ Moomoo AI - Force Bypass Edition")display = gr.Markdown("Engine booting...")gr.Timer(1.5).tick(get_stats, outputs=display)if __name__ == "__main__":
app.py+30-20