Change platform to rocket.chat
This commit is contained in:
@@ -275,9 +275,6 @@ async def wait_for_thread_reply(room_id: str, thread_id: str, existing_message_c
|
||||
start_time = time.time()
|
||||
check_interval = 3 # 每 3 秒檢查一次
|
||||
|
||||
# 取得 bot 帳號的用戶名,用於過濾
|
||||
bot_username = ROCKETCHAT_USER
|
||||
|
||||
print(f"🔄 開始輪詢執行緒回覆 (thread_id: {thread_id}, 現有訊息: {existing_message_count})")
|
||||
|
||||
try:
|
||||
@@ -303,25 +300,18 @@ async def wait_for_thread_reply(room_id: str, thread_id: str, existing_message_c
|
||||
# 按時間排序,取最新的訊息
|
||||
sorted_messages = sorted(messages, key=lambda m: m.get("ts", ""), reverse=True)
|
||||
|
||||
# 尋找管理員的新回覆(不是 bot 發送的)
|
||||
# 尋找管理員的新回覆
|
||||
for msg in sorted_messages:
|
||||
# 跳過原始訊息
|
||||
if msg["_id"] == thread_id:
|
||||
continue
|
||||
|
||||
# 檢查發送者
|
||||
sender = msg.get("u", {})
|
||||
sender_username = sender.get("username", "")
|
||||
|
||||
# 跳過 bot 自己發送的訊息(系統轉發的用戶訊息)
|
||||
if sender_username == bot_username:
|
||||
continue
|
||||
|
||||
# 檢查是否為真人回覆(有 u 欄位且不是 bot 標記)
|
||||
if sender and not msg.get("bot"):
|
||||
# 檢查是否為真人回覆(有 u 欄位且不是 bot)
|
||||
if "u" in msg and not msg.get("bot"):
|
||||
reply_text = msg.get("msg", "")
|
||||
if reply_text:
|
||||
print(f"✅ 收到管理員回覆 (from: {sender_username}): {reply_text[:50]}...")
|
||||
# 跳過用戶自己的訊息(檢查是否包含對話標記)
|
||||
if reply_text and not reply_text.startswith("[對話"):
|
||||
print(f"✅ 收到管理員回覆: {reply_text[:50]}...")
|
||||
return reply_text
|
||||
else:
|
||||
print(f" ⚠️ API 回應異常: {resp.status_code}")
|
||||
|
||||
Reference in New Issue
Block a user