|
|
@@ -8,6 +8,7 @@ API文档:https://cloud.tencent.com/document/product/269/2738
|
|
|
|
|
|
import httpx
|
|
|
import random
|
|
|
+import time
|
|
|
from typing import List, Optional
|
|
|
from dotenv import load_dotenv
|
|
|
import os
|
|
|
@@ -17,7 +18,7 @@ load_dotenv()
|
|
|
|
|
|
# 腾讯云IM配置
|
|
|
TENCENT_IM_APP_ID = os.getenv("TENCENT_IM_APP_ID")
|
|
|
-TENCENT_IM_ADMIN_ID = os.getenv("TENCENT_IM_ADMIN_ID", "administrator")
|
|
|
+TENCENT_IM_ADMIN_ID = os.getenv("TENCENT_IM_ADMIN_ID")
|
|
|
TENCENT_IM_SECRET_KEY = os.getenv("TENCENT_IM_SECRET_KEY")
|
|
|
|
|
|
|
|
|
@@ -302,6 +303,11 @@ class TencentIMClient:
|
|
|
# 按时间升序排列(最早的在前)
|
|
|
formatted.sort(key=lambda x: x["timestamp"])
|
|
|
|
|
|
+ # 过滤最近30分钟的消息
|
|
|
+ current_time = int(time.time())
|
|
|
+ time_threshold = current_time - 1800 # 30分钟 = 1800秒
|
|
|
+ formatted = [msg for msg in formatted if msg["timestamp"] >= time_threshold]
|
|
|
+
|
|
|
return formatted
|
|
|
|
|
|
|