ChatMarkus1's picture
Update app.py
d0f21f1 verified
Raw History Blame Contribute Delete
3.38 kB
import os
import time
import threading
import gradio as gr
from seleniumbase import SB
class BotState:
def __init__(self):
self.status = "Initializing..."
self.hp = 100
self.resources = {"Wood": 0, "Stone": 0, "Food": 0}
self.active = False
self.last_log = "Waiting for game start..."
state = BotState()
def run_bot_engine():
# Use CDP Mode (Chrome DevTools Protocol) for maximum stealth
with 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 session
sb.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" button
sb.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 curves
try:
sb.solve_captcha() # Internal SeleniumBase magic for ALTCHA/Turnstile
state.last_log = "Captcha bypassed successfully."
except:
# Manual fallback: click the center of the ALTCHA widget
sb.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 = True
state.status = "๐ŸŸข SURVIVING"
while True:
# Using CDP-safe script execution
game_data = sb.execute_script("""
return {
hp: parseInt(document.getElementById('healthBar')?.style.width) || 100,
food: parseInt(document.getElementById('foodDisplay')?.innerText) || 0,
wood: parseInt(document.getElementById('woodDisplay')?.innerText) || 0,
stone: 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 Logic
if 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.resources
return 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__":
threading.Thread(target=run_bot_engine, daemon=True).start()
demo.launch(server_name="0.0.0.0", server_port=7860)