Update main.py
Browse files
main.py
CHANGED
|
@@ -404,6 +404,25 @@ async def filter_endpoint(request: FilterRequest):
|
|
| 404 |
if not url_to_download:
|
| 405 |
raise HTTPException(status_code=400, detail="URL da mídia (media_url, video_url ou image_url) é obrigatória")
|
| 406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
print(f"📥 Baixando mídia para filtro: {url_to_download}")
|
| 408 |
response = download_file_with_retry(url_to_download, timeout=600)
|
| 409 |
|
|
@@ -508,13 +527,14 @@ Reprovando (exemplo 2):
|
|
| 508 |
return JSONResponse(content={"raw_content": response_gemini.text, "error": "Failed to parse JSON"}, status_code=200)
|
| 509 |
|
| 510 |
try:
|
| 511 |
-
|
|
|
|
| 512 |
"mensagem": filter_data.get("filter_message", ""),
|
| 513 |
"id": request.discord_id
|
| 514 |
-
}
|
| 515 |
-
requests.
|
| 516 |
-
"https://proxy.onrecurve.com/
|
| 517 |
-
|
| 518 |
timeout=5
|
| 519 |
)
|
| 520 |
except Exception as e:
|
|
|
|
| 404 |
if not url_to_download:
|
| 405 |
raise HTTPException(status_code=400, detail="URL da mídia (media_url, video_url ou image_url) é obrigatória")
|
| 406 |
|
| 407 |
+
bot_names = {1: "Diana", 2: "Vicky", 3: "Amanda"}
|
| 408 |
+
discord_id = 1 if request.discord_id is None else request.discord_id
|
| 409 |
+
agent_name = bot_names.get(discord_id, "Sistema")
|
| 410 |
+
|
| 411 |
+
try:
|
| 412 |
+
import urllib.parse
|
| 413 |
+
sys_msg = f"🏃♀️ **{agent_name}** começou a filtrar uma postagem...\n\n📎 **Mídia:** {url_to_download}"
|
| 414 |
+
sys_target_url = "https://discordmsg.arthurmribeiro51.workers.dev/?" + urllib.parse.urlencode({
|
| 415 |
+
"mensagem": sys_msg,
|
| 416 |
+
"id": 0
|
| 417 |
+
})
|
| 418 |
+
requests.get(
|
| 419 |
+
"https://proxy.onrecurve.com/",
|
| 420 |
+
params={"quest": sys_target_url},
|
| 421 |
+
timeout=5
|
| 422 |
+
)
|
| 423 |
+
except Exception as e:
|
| 424 |
+
print(f"⚠️ Erro ao enviar mensagem de sistema para o Discord: {e}")
|
| 425 |
+
|
| 426 |
print(f"📥 Baixando mídia para filtro: {url_to_download}")
|
| 427 |
response = download_file_with_retry(url_to_download, timeout=600)
|
| 428 |
|
|
|
|
| 527 |
return JSONResponse(content={"raw_content": response_gemini.text, "error": "Failed to parse JSON"}, status_code=200)
|
| 528 |
|
| 529 |
try:
|
| 530 |
+
import urllib.parse
|
| 531 |
+
target_url = "https://discordmsg.arthurmribeiro51.workers.dev/?" + urllib.parse.urlencode({
|
| 532 |
"mensagem": filter_data.get("filter_message", ""),
|
| 533 |
"id": request.discord_id
|
| 534 |
+
})
|
| 535 |
+
requests.get(
|
| 536 |
+
"https://proxy.onrecurve.com/",
|
| 537 |
+
params={"quest": target_url},
|
| 538 |
timeout=5
|
| 539 |
)
|
| 540 |
except Exception as e:
|