拼多多实现加密参数登录+京东客服转接
This commit is contained in:
@@ -257,13 +257,19 @@ class WebSocketManager:
|
||||
except Exception as e:
|
||||
self._log(f"启动千牛平台监听失败: {e}", "ERROR")
|
||||
|
||||
def _start_pdd_listener(self, store_id: str, cookies: str):
|
||||
def _start_pdd_listener(self, store_id: str, data: str):
|
||||
"""启动拼多多平台监听"""
|
||||
try:
|
||||
def _runner():
|
||||
try:
|
||||
listener = PDDListenerForGUI_WS(log_callback=self._log)
|
||||
result = asyncio.run(listener.start_with_cookies(store_id=store_id, cookies=cookies))
|
||||
# 判断是登录参数还是Cookie
|
||||
if self._is_pdd_login_params(data):
|
||||
# 使用登录参数启动
|
||||
result = asyncio.run(listener.start_with_login_params(store_id=store_id, login_params=data))
|
||||
else:
|
||||
# 使用Cookie启动(兼容旧方式)
|
||||
result = asyncio.run(listener.start_with_cookies(store_id=store_id, cookies=data))
|
||||
return result
|
||||
except Exception as e:
|
||||
self._log(f"拼多多监听器运行异常: {e}", "ERROR")
|
||||
@@ -312,6 +318,15 @@ class WebSocketManager:
|
||||
except Exception as send_e:
|
||||
self._log(f"失败状态下报拼多多平台连接状态也失败: {send_e}", "ERROR")
|
||||
|
||||
def _is_pdd_login_params(self, data: str) -> bool:
|
||||
"""判断是否为拼多多登录参数"""
|
||||
try:
|
||||
import json
|
||||
parsed_data = json.loads(data)
|
||||
return (parsed_data.get("data", {}).get("login_params") is not None)
|
||||
except:
|
||||
return False
|
||||
|
||||
def send_message(self, message: dict):
|
||||
"""发送消息到后端"""
|
||||
if self.backend_client and self.backend_client.is_connected:
|
||||
|
||||
Reference in New Issue
Block a user