Update app.py
Browse files14 unmodified lines15161718181920202121222324232425262728292830313233343536373839404142434445466 unmodified lines53545550565752535455565859606162616263646566671 unmodified line69707170717273747576777814 unmodified linesstate = BotState()
def run_bot_engine(): with SB(uc=True, xvfb=True, interval=0.05) as sb: # Added no_sandbox and disable_gpu for Docker stability with SB(uc=True, xvfb=True, headless=False, no_sandbox=True, disable_gpu=True) as sb: try: state.status = "๐ Loading Moomoo.io..." sb.uc_open_with_reconnect("https://moomoo.io", reconnect_time=5) state.status = "๐ Opening Browser..." sb.set_window_size(1280, 720) sb.uc_open_with_reconnect("https://moomoo.io", reconnect_time=7) state.status = "๐ก๏ธ Handling Anti-Bot..." sb.activate_cdp_mode("https://moomoo.io") state.status = "๐ก๏ธ Bypassing Cloudflare..." sb.sleep(5) # Try a stealthy click in the middle of the screen to wake up the JS try: sb.solve_captcha() sb.click_active_element() sb.uc_gui_handle_captcha() except: pass state.status = "๐ Entering Name..." sb.type("#nameInput", "Survival_Bot_v1") sb.click("#enterGame") state.active = True state.status = "๐ข SURVIVING"
while True: # Scrape data game_data = sb.execute_script(""" return { hp: parseInt(document.getElementById('healthBar')?.style.width) || 100,6 unmodified lines state.hp = game_data['hp'] state.resources = {"Wood": game_data['wood'], "Stone": game_data['stone'], "Food": game_data['food']}
if state.hp < 70: if state.hp < 80: sb.press_keys("body", "q") state.last_log = "โ ๏ธ Healing active" elif state.resources['Wood'] < 100: sb.press_keys("body", "e") state.last_log = "๐ช Farming wood" state.last_log = "โค๏ธ Healing" time.sleep(0.1)
except Exception as e: state.status = "โ Fatal Error" state.last_log = f"Error: {str(e)[:50]}" state.status = "โ Engine Error" state.last_log = f"Error: {str(e)[:60]}"
def get_stats(): res = state.resources1 unmodified line
with gr.Blocks() as demo: gr.Markdown("# ๐ฎ Moomoo Survival Bot") with gr.Row(): display = gr.Markdown("Connecting to engine...") display = gr.Markdown("Connecting...") gr.Timer(1.5).tick(get_stats, outputs=display)
if __name__ == "__main__": threading.Thread(target=run_bot_engine, daemon=True).start() # server_name="0.0.0.0" is essential for HF to see the app demo.launch(server_name="0.0.0.0", server_port=7860)app.py+18-16