Upload main.py
Browse files
main.py
CHANGED
|
@@ -43,11 +43,14 @@ async def forward_to_rumas(b64_str: str, wa_id: str):
|
|
| 43 |
# ββ send parsed ID back to WhatsApp ββ
|
| 44 |
if wa_id and data.get("status") == "success":
|
| 45 |
det = data["results"][0]["detections"][0]
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
except Exception as e:
|
| 53 |
print(f"[RUMAS] β error while sending '{short}β¦' β", e)
|
|
@@ -110,10 +113,6 @@ async def receive_update(req: Request):
|
|
| 110 |
print("Malformed webhook payload:", e)
|
| 111 |
return JSONResponse({"status": "ignored", "reason": "malformed payload"})
|
| 112 |
|
| 113 |
-
# ββ ignore updates from our own bot to prevent echo loops ββ
|
| 114 |
-
if msg.get("from") == PHONE_NUMBER_ID:
|
| 115 |
-
return JSONResponse({"status": "ignored", "reason": "bot message"})
|
| 116 |
-
|
| 117 |
# IMAGE: if user sent an image, convert to Base64 preview
|
| 118 |
if msg["type"] == "image":
|
| 119 |
media_id = msg["image"]["id"]
|
|
|
|
| 43 |
# ββ send parsed ID back to WhatsApp ββ
|
| 44 |
if wa_id and data.get("status") == "success":
|
| 45 |
det = data["results"][0]["detections"][0]
|
| 46 |
+
reply = (
|
| 47 |
+
"β
*ID processed*\n"
|
| 48 |
+
f"*Name*: {det.get('name','?')} {det.get('surname','')}\n"
|
| 49 |
+
f"*ID No.*: {det.get('id_num','?')}\n"
|
| 50 |
+
f"*DOB*: {det.get('date_of_birth','?')}\n"
|
| 51 |
+
f"*Gender*: {det.get('gender','?')}"
|
| 52 |
+
)
|
| 53 |
+
send_whatsapp_message(wa_id, reply)
|
| 54 |
|
| 55 |
except Exception as e:
|
| 56 |
print(f"[RUMAS] β error while sending '{short}β¦' β", e)
|
|
|
|
| 113 |
print("Malformed webhook payload:", e)
|
| 114 |
return JSONResponse({"status": "ignored", "reason": "malformed payload"})
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
# IMAGE: if user sent an image, convert to Base64 preview
|
| 117 |
if msg["type"] == "image":
|
| 118 |
media_id = msg["image"]["id"]
|