Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -9,140 +9,125 @@ from selenium.webdriver.common.by import By
|
|
| 9 |
from pyvirtualdisplay import Display
|
| 10 |
from groq import Groq
|
| 11 |
|
| 12 |
-
# ---
|
| 13 |
CHAVE_GROQ = "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"
|
| 14 |
cliente_ia = Groq(api_key=CHAVE_GROQ)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
NOME_USUARIO = "ERINALDORDSO3"
|
| 23 |
|
| 24 |
def log(acao, status="INFO"):
|
| 25 |
agora = datetime.now().strftime("%H:%M:%S")
|
| 26 |
-
|
| 27 |
-
print(f"[{agora}] [{
|
| 28 |
|
| 29 |
-
# --- SERVIDOR HTTP ---
|
| 30 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 31 |
def do_GET(self):
|
| 32 |
self.send_response(200); self.end_headers()
|
| 33 |
-
self.wfile.write(b"Bot
|
| 34 |
def log_message(self, format, *args): pass
|
| 35 |
|
| 36 |
def manter_dock_viva():
|
| 37 |
-
try:
|
| 38 |
-
HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever()
|
| 39 |
except: pass
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
try:
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# Extrair Nível
|
| 50 |
-
nivel = re.findall(r'Farming\s*Level:\s*(\d+)', texto)
|
| 51 |
-
# Extrair Inventário (ex: 50 / 100)
|
| 52 |
-
inv = re.findall(r'Inventory:\s*(\d+\s*/\s*\d+)', texto)
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
log(
|
| 59 |
-
return
|
| 60 |
-
except:
|
| 61 |
-
return ""
|
| 62 |
|
| 63 |
-
# --- IA ---
|
| 64 |
def o_groq_decide(texto):
|
| 65 |
-
prompt = "
|
| 66 |
try:
|
| 67 |
res = cliente_ia.chat.completions.create(
|
| 68 |
messages=[{"role": "system", "content": prompt}, {"role": "user", "content": texto}],
|
| 69 |
-
model="llama-3.1-8b-instant", temperature=0.1, max_tokens=
|
| 70 |
)
|
| 71 |
return re.findall(r'VENDER|FAZENDA|EXPLORAR|REPOUSO', res.choices[0].message.content.upper())[0]
|
| 72 |
except: return "REPOUSO"
|
| 73 |
|
| 74 |
-
# --- AÇÕES REAIS ---
|
| 75 |
def agir(driver, comando):
|
| 76 |
if comando == "VENDER":
|
| 77 |
-
log("
|
| 78 |
driver.get("https://farmrpg.com/index.php#!/sellall.php")
|
| 79 |
time.sleep(5)
|
| 80 |
-
# Clica no botão e confirma
|
| 81 |
driver.execute_script("""
|
| 82 |
-
var
|
| 83 |
-
if(
|
| 84 |
-
|
| 85 |
-
setTimeout(() => {
|
| 86 |
-
var conf = document.querySelector('.modal-button-bold');
|
| 87 |
-
if(conf) conf.click();
|
| 88 |
-
}, 1000);
|
| 89 |
-
}
|
| 90 |
""")
|
| 91 |
-
time.sleep(4)
|
| 92 |
-
driver.get("https://farmrpg.com/index.php#!/index.php")
|
| 93 |
-
time.sleep(3)
|
| 94 |
-
ler_estado_conta(driver) # Mostra o saldo após venda
|
| 95 |
-
|
| 96 |
-
elif comando == "FAZENDA":
|
| 97 |
-
log("Executando colheita...", "ACAO")
|
| 98 |
-
driver.get("https://farmrpg.com/index.php#!/farm.php")
|
| 99 |
time.sleep(5)
|
| 100 |
-
driver.execute_script("""
|
| 101 |
-
document.querySelectorAll('a.button').forEach(b => {
|
| 102 |
-
if(b.innerText.includes('Harvest All') || b.innerText.includes('Plant All')) b.click();
|
| 103 |
-
});
|
| 104 |
-
""")
|
| 105 |
-
log("Plantas processadas.", "SUCESSO")
|
| 106 |
-
|
| 107 |
elif comando == "EXPLORAR":
|
| 108 |
-
log("
|
| 109 |
driver.get("https://farmrpg.com/index.php#!/area.php?id=1")
|
| 110 |
-
time.sleep(
|
| 111 |
-
driver.execute_script("var c=0; var i=setInterval(
|
| 112 |
time.sleep(10)
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
def iniciar():
|
| 116 |
display = Display(visible=0, size=(1920, 1080)); display.start()
|
| 117 |
driver = Driver(uc=True, headless=False)
|
| 118 |
|
| 119 |
try:
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
while True:
|
| 124 |
driver.get("https://farmrpg.com/index.php#!/index.php")
|
| 125 |
-
time.sleep(
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
|
| 128 |
-
corpo = ler_estado_conta(driver)
|
| 129 |
|
| 130 |
if NOME_USUARIO.upper() not in corpo.upper():
|
| 131 |
-
log("
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
log(f"Estratégia: {comando}", "GROQ")
|
| 136 |
|
| 137 |
-
# 3. Executa
|
| 138 |
if comando != "REPOUSO":
|
| 139 |
agir(driver, comando)
|
| 140 |
|
| 141 |
-
time.sleep(random.randint(
|
| 142 |
|
| 143 |
-
except Exception as e: log(f"
|
| 144 |
-
finally:
|
| 145 |
-
driver.quit(); display.stop()
|
| 146 |
|
| 147 |
if __name__ == "__main__":
|
| 148 |
threading.Thread(target=manter_dock_viva, daemon=True).start()
|
|
|
|
| 9 |
from pyvirtualdisplay import Display
|
| 10 |
from groq import Groq
|
| 11 |
|
| 12 |
+
# --- 🔑 CREDENCIAIS (Sincronizadas com o que enviaste) ---
|
| 13 |
CHAVE_GROQ = "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"
|
| 14 |
cliente_ia = Groq(api_key=CHAVE_GROQ)
|
| 15 |
|
| 16 |
+
# Valores extraídos da tua string
|
| 17 |
+
COOKIES_DATA = {
|
| 18 |
+
"pac_ocean": "A55233B0",
|
| 19 |
+
"HighwindFRPG": "FVQCTfUiHPqufIN4zJcMPQ%3D%3D%3Cstrip%3E%24argon2id%24v%3D19%24m%3D7168%2Ct%3D4%2Cp%3D1%24bm1Ob0lmUWdSZEtHeklNVw%24L1Y8X1pEyJ5zX13VIK8oqNQcdHtwrdhvhHeseXSEhNA",
|
| 20 |
+
"farmrpg_token": "6tgeudskm32f0rlq6oputj0j1kd5f59nkdvolsdv"
|
| 21 |
+
}
|
| 22 |
|
| 23 |
NOME_USUARIO = "ERINALDORDSO3"
|
| 24 |
|
| 25 |
def log(acao, status="INFO"):
|
| 26 |
agora = datetime.now().strftime("%H:%M:%S")
|
| 27 |
+
icons = {"SALDO": "💰", "GROQ": "🧠", "ACAO": "🚜", "SUCESSO": "✅", "ALERTA": "❌"}
|
| 28 |
+
print(f"[{agora}] [{icons.get(status, 'ℹ️')}] {acao}", flush=True)
|
| 29 |
|
|
|
|
| 30 |
class ServidorFalso(BaseHTTPRequestHandler):
|
| 31 |
def do_GET(self):
|
| 32 |
self.send_response(200); self.end_headers()
|
| 33 |
+
self.wfile.write(b"Bot v12 Online - Auditoria Real")
|
| 34 |
def log_message(self, format, *args): pass
|
| 35 |
|
| 36 |
def manter_dock_viva():
|
| 37 |
+
try: HTTPServer(('0.0.0.0', 7860), ServidorFalso).serve_forever()
|
|
|
|
| 38 |
except: pass
|
| 39 |
|
| 40 |
+
def ler_dados_reais(driver):
|
| 41 |
+
"""Tenta ler os valores do topo da página (Silver e Gold)"""
|
| 42 |
try:
|
| 43 |
+
# Tenta pegar elementos específicos da UI do jogo
|
| 44 |
+
silver_el = driver.find_elements(By.CLASS_NAME, "wallet-silver")
|
| 45 |
+
gold_el = driver.find_elements(By.CLASS_NAME, "wallet-gold")
|
| 46 |
+
|
| 47 |
+
texto_completo = driver.find_element(By.TAG_NAME, "body").text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
silver = silver_el[0].text if silver_el else re.findall(r'([\d,]+)\s*Silver', texto_completo)
|
| 50 |
+
gold = gold_el[0].text if gold_el else re.findall(r'([\d,]+)\s*Gold', texto_completo)
|
| 51 |
+
inv = re.findall(r'(\d+\s*/\s*\d+)', texto_completo)
|
| 52 |
+
|
| 53 |
+
res_silver = silver[0] if isinstance(silver, list) and silver else silver
|
| 54 |
+
res_gold = gold[0] if isinstance(gold, list) and gold else gold
|
| 55 |
|
| 56 |
+
log(f"CONTA: {NOME_USUARIO} | Silver: {res_silver} | Gold: {res_gold} | Inv: {inv[0] if inv else '?'}", "SALDO")
|
| 57 |
+
return texto_completo
|
| 58 |
+
except: return ""
|
|
|
|
| 59 |
|
|
|
|
| 60 |
def o_groq_decide(texto):
|
| 61 |
+
prompt = "Analise o Farm RPG. Responda APENAS: VENDER, FAZENDA, EXPLORAR ou REPOUSO."
|
| 62 |
try:
|
| 63 |
res = cliente_ia.chat.completions.create(
|
| 64 |
messages=[{"role": "system", "content": prompt}, {"role": "user", "content": texto}],
|
| 65 |
+
model="llama-3.1-8b-instant", temperature=0.1, max_tokens=10
|
| 66 |
)
|
| 67 |
return re.findall(r'VENDER|FAZENDA|EXPLORAR|REPOUSO', res.choices[0].message.content.upper())[0]
|
| 68 |
except: return "REPOUSO"
|
| 69 |
|
|
|
|
| 70 |
def agir(driver, comando):
|
| 71 |
if comando == "VENDER":
|
| 72 |
+
log("Ação Real: Venda Total", "ACAO")
|
| 73 |
driver.get("https://farmrpg.com/index.php#!/sellall.php")
|
| 74 |
time.sleep(5)
|
|
|
|
| 75 |
driver.execute_script("""
|
| 76 |
+
var b = document.querySelector('a.color-red, .sell-all-btn, button.red');
|
| 77 |
+
if(b) b.click();
|
| 78 |
+
setTimeout(() => { document.querySelector('.modal-button-bold')?.click(); }, 1500);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
elif comando == "EXPLORAR":
|
| 82 |
+
log("Ação Real: Exploração (Area 1)", "ACAO")
|
| 83 |
driver.get("https://farmrpg.com/index.php#!/area.php?id=1")
|
| 84 |
+
time.sleep(5)
|
| 85 |
+
driver.execute_script("var c=0; var i=setInterval(()=>{var b=document.getElementById('explorebtn'); if(b)b.click(); if(++c>=20)clearInterval(i);}, 400);")
|
| 86 |
time.sleep(10)
|
| 87 |
+
elif comando == "FAZENDA":
|
| 88 |
+
log("Ação Real: Ciclo de Farm", "ACAO")
|
| 89 |
+
driver.get("https://farmrpg.com/index.php#!/farm.php")
|
| 90 |
+
time.sleep(5)
|
| 91 |
+
driver.execute_script("document.querySelectorAll('a.button').forEach(b => { if(b.innerText.includes('All')) b.click(); });")
|
| 92 |
+
time.sleep(5)
|
| 93 |
|
| 94 |
def iniciar():
|
| 95 |
display = Display(visible=0, size=(1920, 1080)); display.start()
|
| 96 |
driver = Driver(uc=True, headless=False)
|
| 97 |
|
| 98 |
try:
|
| 99 |
+
# INJEÇÃO ROBUSTA DE COOKIES
|
| 100 |
+
log("Sincronizando com o servidor do jogo...", "INFO")
|
| 101 |
+
driver.get("https://farmrpg.com/robots.txt")
|
| 102 |
+
time.sleep(2)
|
| 103 |
+
for name, value in COOKIES_DATA.items():
|
| 104 |
+
driver.add_cookie({"name": name, "value": value, "domain": "farmrpg.com", "path": "/"})
|
| 105 |
|
| 106 |
while True:
|
| 107 |
driver.get("https://farmrpg.com/index.php#!/index.php")
|
| 108 |
+
time.sleep(8)
|
| 109 |
+
|
| 110 |
+
# Tenta fechar popups de notícias ou tutorial que bloqueiam a visão
|
| 111 |
+
driver.execute_script("var b = document.querySelector('.modal-button, .close-picker'); if(b) b.click();")
|
| 112 |
|
| 113 |
+
corpo = ler_dados_reais(driver)
|
|
|
|
| 114 |
|
| 115 |
if NOME_USUARIO.upper() not in corpo.upper():
|
| 116 |
+
log("FALHA DE LOGIN: O bot não está na tua conta! Verificando cookies...", "ALERTA")
|
| 117 |
+
# Se falhar, tenta forçar o login via URL
|
| 118 |
+
driver.get("https://farmrpg.com/index.php#!/index.php")
|
| 119 |
+
time.sleep(5)
|
| 120 |
|
| 121 |
+
comando = o_groq_decide(corpo[100:2000] if corpo else "REPOUSO")
|
| 122 |
+
log(f"IA Decidiu: {comando}", "GROQ")
|
|
|
|
| 123 |
|
|
|
|
| 124 |
if comando != "REPOUSO":
|
| 125 |
agir(driver, comando)
|
| 126 |
|
| 127 |
+
time.sleep(random.randint(10, 20))
|
| 128 |
|
| 129 |
+
except Exception as e: log(f"Crash: {e}", "ALERTA")
|
| 130 |
+
finally: driver.quit(); display.stop()
|
|
|
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|
| 133 |
threading.Thread(target=manter_dock_viva, daemon=True).start()
|