feat: initialize FastAPI server with Shopee and Facebook bot orchestration endpoints

This commit is contained in:
Victor Phan
2026-07-23 13:32:38 +07:00
parent 1f2248351d
commit 78bd883d3c
+5 -3
View File
@@ -31,9 +31,11 @@ class CommissionRequest(BaseModel):
# Cho phép truyền IP linh hoạt từ n8n.
device_ip: Optional[str] = Field(default=None, description="IP:Port của điện thoại, ví dụ 192.168.1.100:5555 (WiFi) hoặc 10.8.0.5:5555 (VPN)")
from typing import Optional, Any
class FacebookCommentRequest(BaseModel):
device_ip: Optional[str] = Field(default=None, description="IP:Port của điện thoại (Cấu hình trên n8n)")
group_id: str
group_id: Any
content: str
image_url: Optional[str] = None
@@ -80,10 +82,10 @@ def post_facebook_comment(req: FacebookCommentRequest):
if req.image_url:
# Tải ảnh về máy chủ Python tạm thời
local_image_path = f"temp_fb_{uuid.uuid4().hex}.jpg"
urllib.request.urlretrieve(req.image_url, local_image_path)
urllib.request.urlretrieve(str(req.image_url), local_image_path)
logging.info(f"Đã tải ảnh tạm thời: {local_image_path}")
result = bot.post_comment(req.group_id, req.content, local_image_path)
result = bot.post_comment(str(req.group_id), str(req.content), local_image_path)
# Dọn dẹp ảnh tạm sau khi xong
if local_image_path and os.path.exists(local_image_path):