Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -11,7 +11,7 @@ from pyvirtualdisplay import Display
|
|
| 11 |
# --- 🔐 CREDENCIAIS ---
|
| 12 |
USER_TW = "erinaldordso3"
|
| 13 |
PASS_TW = "Miau.1996"
|
| 14 |
-
MUNDO_ID = "br141"
|
| 15 |
|
| 16 |
def log(acao, status="INFO"):
|
| 17 |
agora = datetime.now().strftime("%H:%M:%S")
|
|
@@ -21,117 +21,108 @@ def log(acao, status="INFO"):
|
|
| 21 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 22 |
def do_GET(self):
|
| 23 |
self.send_response(200); self.end_headers()
|
| 24 |
-
self.wfile.write(b"Bot Tribal Wars v2.
|
| 25 |
def log_message(self, format, *args): pass
|
| 26 |
|
| 27 |
def manter_dock_viva():
|
| 28 |
try: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever()
|
| 29 |
except: pass
|
| 30 |
|
| 31 |
-
# ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
def realizar_login(driver):
|
| 33 |
-
log("A abrir
|
| 34 |
driver.get("https://www.tribalwars.com.br/")
|
| 35 |
time.sleep(5)
|
| 36 |
|
| 37 |
try:
|
| 38 |
-
# Preenche as credenciais
|
| 39 |
driver.type('input#user', USER_TW)
|
| 40 |
driver.type('input#password', PASS_TW)
|
| 41 |
time.sleep(1)
|
| 42 |
|
| 43 |
-
log("
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
# --- BUSCA EXAUSTIVA PELO MUNDO ---
|
| 48 |
log(f"A procurar acesso ao Mundo {MUNDO_ID}...", "LOGIN")
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
href = link.get_attribute("href") or ""
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
log(f"Sucesso! Entrámos no {MUNDO_ID}.", "SUCESSO")
|
| 57 |
time.sleep(5)
|
| 58 |
return True
|
| 59 |
|
| 60 |
-
# Tenta o seletor clássico como última alternativa
|
| 61 |
-
if driver.is_element_visible("span.world_button_active"):
|
| 62 |
-
driver.click("span.world_button_active")
|
| 63 |
-
log("Entrámos pelo botão de Mundo Ativo.", "SUCESSO")
|
| 64 |
-
return True
|
| 65 |
-
|
| 66 |
-
log("Não conseguimos encontrar o link do mundo. A página pode ter mudado.", "ALERTA")
|
| 67 |
return False
|
| 68 |
|
| 69 |
except Exception as e:
|
| 70 |
-
log(f"Erro no
|
| 71 |
return False
|
| 72 |
|
| 73 |
def auditoria_e_obras(driver):
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
try:
|
| 81 |
-
# 📊 Auditoria de Recursos
|
| 82 |
mad = driver.find_element(By.ID, "wood").text
|
| 83 |
arg = driver.find_element(By.ID, "stone").text
|
| 84 |
fer = driver.find_element(By.ID, "iron").text
|
| 85 |
-
log(f"
|
| 86 |
|
| 87 |
-
#
|
| 88 |
-
|
| 89 |
-
prioridade = ["wood", "stone", "iron", "storage", "main", "farm"]
|
| 90 |
|
| 91 |
-
for
|
| 92 |
-
btn_seletor = f"a.btn_build[data-building='{
|
| 93 |
if driver.is_element_visible(btn_seletor):
|
| 94 |
-
# Verifica se já há 2 coisas na fila (evita gastar pontos premium)
|
| 95 |
fila = driver.find_elements(By.CLASS_NAME, "buildorder")
|
| 96 |
if len(fila) < 2:
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
log("Fila de construção cheia (2/2).", "INFO")
|
| 103 |
return
|
| 104 |
except Exception as e:
|
| 105 |
-
log(
|
| 106 |
|
| 107 |
def iniciar():
|
| 108 |
display = Display(visible=0, size=(1920, 1080)); display.start()
|
| 109 |
-
# uc=True é vital para contornar a proteção Cloudflare/InnoGames
|
| 110 |
driver = Driver(uc=True, headless=False)
|
| 111 |
|
| 112 |
try:
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
|
| 122 |
-
driver.get(f"https://{MUNDO_ID}.tribalwars.com.br/game.php?screen=report")
|
| 123 |
-
time.sleep(minutos * 60)
|
| 124 |
-
else:
|
| 125 |
-
log("Reiniciando em 1 minuto para tentar novo login...", "ALERTA")
|
| 126 |
-
time.sleep(60)
|
| 127 |
-
|
| 128 |
-
except Exception as e: log(f"Crash no Motor: {e}", "ALERTA")
|
| 129 |
finally:
|
| 130 |
driver.quit(); display.stop()
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
threading.Thread(target=manter_dock_viva, daemon=True).start()
|
| 134 |
-
print("\n" + "X"*50)
|
| 135 |
-
log("TRIBAL WARS ELITE v2.2 - OPERACIONAL", "SUCESSO")
|
| 136 |
-
print("X"*50 + "\n")
|
| 137 |
iniciar()
|
|
|
|
| 11 |
# --- 🔐 CREDENCIAIS ---
|
| 12 |
USER_TW = "erinaldordso3"
|
| 13 |
PASS_TW = "Miau.1996"
|
| 14 |
+
MUNDO_ID = "br141"
|
| 15 |
|
| 16 |
def log(acao, status="INFO"):
|
| 17 |
agora = datetime.now().strftime("%H:%M:%S")
|
|
|
|
| 21 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 22 |
def do_GET(self):
|
| 23 |
self.send_response(200); self.end_headers()
|
| 24 |
+
self.wfile.write(b"Bot Tribal Wars v2.3 - Bypass de Popups Ativo")
|
| 25 |
def log_message(self, format, *args): pass
|
| 26 |
|
| 27 |
def manter_dock_viva():
|
| 28 |
try: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever()
|
| 29 |
except: pass
|
| 30 |
|
| 31 |
+
# --- FUNÇÃO DE CLIQUE INFALÍVEL ---
|
| 32 |
+
def force_click(driver, element):
|
| 33 |
+
"""Clica no elemento via JavaScript, ignorando bloqueios visuais"""
|
| 34 |
+
driver.execute_script("arguments[0].click();", element)
|
| 35 |
+
|
| 36 |
+
# --- LOGIN RESILIENTE ---
|
| 37 |
def realizar_login(driver):
|
| 38 |
+
log("A abrir página principal do Tribos...", "LOGIN")
|
| 39 |
driver.get("https://www.tribalwars.com.br/")
|
| 40 |
time.sleep(5)
|
| 41 |
|
| 42 |
try:
|
|
|
|
| 43 |
driver.type('input#user', USER_TW)
|
| 44 |
driver.type('input#password', PASS_TW)
|
| 45 |
time.sleep(1)
|
| 46 |
|
| 47 |
+
log("A enviar formulário de login...", "LOGIN")
|
| 48 |
+
# Usa JS para clicar no botão de login
|
| 49 |
+
login_btn = driver.find_element(By.CSS_SELECTOR, 'a.btn-login')
|
| 50 |
+
force_click(driver, login_btn)
|
| 51 |
+
time.sleep(10)
|
| 52 |
|
|
|
|
| 53 |
log(f"A procurar acesso ao Mundo {MUNDO_ID}...", "LOGIN")
|
| 54 |
|
| 55 |
+
# Procura todos os links e clica no que contém o ID do mundo via JS
|
| 56 |
+
links = driver.find_elements(By.TAG_NAME, "a")
|
| 57 |
+
for link in links:
|
| 58 |
href = link.get_attribute("href") or ""
|
| 59 |
+
if MUNDO_ID in href:
|
| 60 |
+
force_click(driver, link)
|
| 61 |
+
log(f"Sucesso! Entrámos no {MUNDO_ID} (via JS Bypass).", "SUCESSO")
|
|
|
|
| 62 |
time.sleep(5)
|
| 63 |
return True
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
return False
|
| 66 |
|
| 67 |
except Exception as e:
|
| 68 |
+
log(f"Erro no login: {str(e)[:100]}", "ALERTA")
|
| 69 |
return False
|
| 70 |
|
| 71 |
def auditoria_e_obras(driver):
|
| 72 |
+
# Força a ida para o Edifício Principal
|
| 73 |
+
driver.get(f"https://{MUNDO_ID}.tribalwars.com.br/game.php?screen=main")
|
| 74 |
+
time.sleep(5)
|
| 75 |
+
|
| 76 |
+
# Tenta fechar qualquer modal (pop-up) que apareça dentro do jogo
|
| 77 |
+
driver.execute_script("if(document.querySelector('.popup_box_close')) document.querySelector('.popup_box_close').click();")
|
| 78 |
|
| 79 |
try:
|
|
|
|
| 80 |
mad = driver.find_element(By.ID, "wood").text
|
| 81 |
arg = driver.find_element(By.ID, "stone").text
|
| 82 |
fer = driver.find_element(By.ID, "iron").text
|
| 83 |
+
log(f"ESTADO ATUAL: Mad {mad} | Arg {arg} | Fer {fer}", "AUDITORIA")
|
| 84 |
|
| 85 |
+
# Ordem de upgrade
|
| 86 |
+
prioridade = ["wood", "stone", "iron", "storage", "main"]
|
|
|
|
| 87 |
|
| 88 |
+
for ed in prioridade:
|
| 89 |
+
btn_seletor = f"a.btn_build[data-building='{ed}']"
|
| 90 |
if driver.is_element_visible(btn_seletor):
|
|
|
|
| 91 |
fila = driver.find_elements(By.CLASS_NAME, "buildorder")
|
| 92 |
if len(fila) < 2:
|
| 93 |
+
# Clica via JS para garantir que a obra começa
|
| 94 |
+
btn = driver.find_element(By.CSS_SELECTOR, btn_seletor)
|
| 95 |
+
force_click(driver, btn)
|
| 96 |
+
log(f"CONSTRUÇÃO REALIZADA: {ed.upper()}", "CONSTR")
|
| 97 |
+
time.sleep(3)
|
|
|
|
| 98 |
return
|
| 99 |
except Exception as e:
|
| 100 |
+
log("Erro na leitura de edifícios.", "INFO")
|
| 101 |
|
| 102 |
def iniciar():
|
| 103 |
display = Display(visible=0, size=(1920, 1080)); display.start()
|
|
|
|
| 104 |
driver = Driver(uc=True, headless=False)
|
| 105 |
|
| 106 |
try:
|
| 107 |
+
while True:
|
| 108 |
+
if realizar_login(driver):
|
| 109 |
+
while True:
|
| 110 |
+
auditoria_e_obras(driver)
|
| 111 |
+
|
| 112 |
+
minutos = random.randint(10, 20)
|
| 113 |
+
log(f"Aldeia segura. Próxima inspeção em {minutos} minutos...", "INFO")
|
| 114 |
+
|
| 115 |
+
# Simula ver relatórios antes de dormir
|
| 116 |
+
driver.get(f"https://{MUNDO_ID}.tribalwars.com.br/game.php?screen=report")
|
| 117 |
+
time.sleep(minutos * 60)
|
| 118 |
+
else:
|
| 119 |
+
log("Tentativa de login falhou. Reiniciando ciclo...", "ALERTA")
|
| 120 |
+
time.sleep(60)
|
| 121 |
|
| 122 |
+
except Exception as e: log(f"Crash: {e}", "ALERTA")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
finally:
|
| 124 |
driver.quit(); display.stop()
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
| 127 |
threading.Thread(target=manter_dock_viva, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
| 128 |
iniciar()
|