feat:重构request请求模块

This commit is contained in:
2025-10-28 09:25:27 +08:00
parent a7aa32dd40
commit 857dd9bd1d
5 changed files with 76 additions and 18 deletions

View File

@@ -1,8 +1,9 @@
from enum import Enum
import requests
import json
from message.request_message import send_request
webhook_url = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send'
webhook_key_estun = 'f09eb098-f709-4fc6-83b5-4a08a8431b8f'
webhook_key_sweet_hut = '5ccae111-43a1-4672-a94f-0d34713259c0'
@@ -24,17 +25,21 @@ def send_wechat_message(message_type: MessageEnum, message: str, has_sweet_hut=F
case MessageEnum.MARKDOWN2:
wechat_message = {"msgtype": "markdown_v2", "markdown_v2": {"content": message}}
requests.post(
webhook_url,
send_request(
url=webhook_url,
method="POST",
headers={"Content-Type": "application/json"},
params={'key': webhook_key_estun},
data=json.dumps(wechat_message, ensure_ascii=False).encode('utf-8')
data=json.dumps(wechat_message, ensure_ascii=False).encode('utf-8'),
timeout=5
)
if has_sweet_hut:
requests.post(
webhook_url,
send_request(
url=webhook_url,
method="POST",
headers={"Content-Type": "application/json"},
params={'key': webhook_key_sweet_hut},
data=json.dumps(wechat_message, ensure_ascii=False).encode('utf-8')
data=json.dumps(wechat_message, ensure_ascii=False).encode('utf-8'),
timeout=5
)