From 1bffeed3eb52820150331d2e74da726ff262ac75 Mon Sep 17 00:00:00 2001 From: Victor Phan Date: Thu, 23 Jul 2026 14:32:50 +0700 Subject: [PATCH] feat: add FacebookBot class to automate comment posting using uiautomator2 --- serverPython/facebook_bot.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/serverPython/facebook_bot.py b/serverPython/facebook_bot.py index fc44461..0e82c5c 100644 --- a/serverPython/facebook_bot.py +++ b/serverPython/facebook_bot.py @@ -123,17 +123,23 @@ class FacebookBot: done_btn = self.d(textContains="Xong") if not done_btn.exists: done_btn = self.d(textContains="Done") + if done_btn.exists: done_btn.click() time.sleep(1) - else: - logging.warning("Không tìm thấy nút đính kèm ảnh, sẽ chỉ gửi text.") + else: + # Nếu không có nút Xong, bấm Back để gập cái thư viện ảnh lại, vì nó đang che khuất nút Gửi! + logging.info("Không có nút Xong, gập thư viện ảnh xuống...") + self.d.press("back") + time.sleep(1.5) - # Bấm gửi - logging.info("Bấm nút Gửi (Send)...") - send_btn = self.d(descriptionContains="Gửi") + # Tìm nút "Gửi" (Send) + logging.info("Tìm nút Gửi...") + send_btn = self.d(descriptionMatches="(?i)^gửi$") if not send_btn.exists: - send_btn = self.d(descriptionContains="Send") + send_btn = self.d(descriptionMatches="(?i)^send$") + if not send_btn.exists: + send_btn = self.d(descriptionContains="Gửi") if send_btn.exists: send_btn.click()