[patch] 新增DY 图片 视频上传 发送等方法逻辑集成 优化抖音心跳维护与弹性发送心跳包 DY集成内置js环境 PDD取消过滤系统机器消息
This commit is contained in:
@@ -731,7 +731,8 @@ class BackendClient:
|
||||
if platform_type == "京东":
|
||||
self._forward_to_jd(store_id, recv_pin, content)
|
||||
elif platform_type == "抖音":
|
||||
self._forward_to_douyin(store_id, recv_pin, content)
|
||||
# 传递msg_type参数,支持图片/视频等类型
|
||||
self._forward_to_douyin(store_id, recv_pin, content, msg_type)
|
||||
elif platform_type == "千牛":
|
||||
self._forward_to_qianniu(store_id, recv_pin, content)
|
||||
elif platform_type == "拼多多":
|
||||
@@ -821,8 +822,15 @@ class BackendClient:
|
||||
except Exception as e:
|
||||
print(f"[JD Forward] 转发失败: {e}")
|
||||
|
||||
def _forward_to_douyin(self, store_id: str, recv_pin: str, content: str):
|
||||
"""转发消息到抖音平台"""
|
||||
def _forward_to_douyin(self, store_id: str, recv_pin: str, content: str, msg_type: str = "text"):
|
||||
"""转发消息到抖音平台
|
||||
|
||||
Args:
|
||||
store_id: 店铺ID
|
||||
recv_pin: 接收者ID
|
||||
content: 消息内容
|
||||
msg_type: 消息类型(text/image/video)
|
||||
"""
|
||||
try:
|
||||
from Utils.Dy.DyUtils import DouYinWebsocketManager
|
||||
dy_mgr = DouYinWebsocketManager()
|
||||
@@ -838,7 +846,7 @@ class BackendClient:
|
||||
message_handler = platform_info.get('message_handler')
|
||||
|
||||
print(
|
||||
f"[DY Forward] shop_key={shop_key} has_bot={bool(douyin_bot)} has_handler={bool(message_handler)} recv_pin={recv_pin}")
|
||||
f"[DY Forward] shop_key={shop_key} has_bot={bool(douyin_bot)} has_handler={bool(message_handler)} recv_pin={recv_pin} msg_type={msg_type}")
|
||||
|
||||
if douyin_bot and message_handler and content:
|
||||
# 在消息处理器的事件循环中发送消息
|
||||
@@ -847,16 +855,16 @@ class BackendClient:
|
||||
# 获取消息处理器的事件循环
|
||||
loop = message_handler._loop
|
||||
if loop and not loop.is_closed():
|
||||
# 在事件循环中执行发送
|
||||
# 在事件循环中执行发送(传递msg_type参数)
|
||||
future = asyncio.run_coroutine_threadsafe(
|
||||
message_handler.send_message_external(recv_pin, content),
|
||||
message_handler.send_message_external(recv_pin, content, msg_type),
|
||||
loop
|
||||
)
|
||||
# 等待结果
|
||||
try:
|
||||
result = future.result(timeout=5)
|
||||
result = future.result(timeout=30) # 图片/视频需要更长时间
|
||||
if result:
|
||||
print(f"[DY Forward] 已转发到平台: pin={recv_pin}, content_len={len(content)}")
|
||||
print(f"[DY Forward] 已转发到平台: pin={recv_pin}, type={msg_type}, content_len={len(content)}")
|
||||
else:
|
||||
print(f"[DY Forward] 转发失败: 消息处理器返回False")
|
||||
except Exception as fe:
|
||||
|
||||
Reference in New Issue
Block a user