chore: remove session reuse and pin proxy to 7898 for lark notifier

This commit is contained in:
crypto_predictor committed 2026-03-07 12:22:53 +08:00
1 parent 77d084341c
commit ad84ee62c4
1 file changed
+8 -5
+8 -5
View File
@@ -8,9 +8,12 @@ class LarkNotifier:
self.url = "https://zhiyinzhe.xyz/sendMsg/api/send"
self.bot_name = bot_name
self.receive_id = receive_id
# 使用 Session 可以复用底层 TCP 连接,提升发送效率
self.session = requests.Session()
# 代理固定为本地 7898 端口
self.proxies = {
"http": "socks5h://127.0.0.1:7898",
"https": "socks5h://127.0.0.1:7898"
}
def send_alert(self, title: str, content: str):
"""
@@ -26,8 +29,8 @@ class LarkNotifier:
}
try:
# 使用 data=payload 发送 Form Data
response = self.session.post(self.url, data=payload, timeout=5)
# 每次请求直接调用 requests.post,不复用 Session
response = requests.post(self.url, data=payload, timeout=5, proxies=self.proxies)
response.raise_for_status()
print(f"告警发送成功: {title}")
except Exception as e: