update:更改tg_bot消息发送方式

This commit is contained in:
yangzhiqiang 2022-06-24 20:14:04 +08:00
parent 2578aae0ba
commit a2ba64dc50

View File

@ -469,8 +469,8 @@ def telegram_bot(title: str, content: str) -> None:
url = (
f"https://api.telegram.org/bot{push_config.get('TG_BOT_TOKEN')}/sendMessage"
)
headers = {"Content-Type": "application/x-www-form-urlencoded"}
payload = {
headers = {"Content-Type": "application/json"}
data = {
"chat_id": str(push_config.get("TG_USER_ID")),
"text": f"{title}\n\n{content}",
"disable_web_page_preview": "true",
@ -489,9 +489,7 @@ def telegram_bot(title: str, content: str) -> None:
push_config.get("TG_PROXY_HOST"), push_config.get("TG_PROXY_PORT")
)
proxies = {"http": proxyStr, "https": proxyStr}
response = requests.post(
url=url, headers=headers, params=payload, proxies=proxies
).json()
response = requests.post(url=url, headers=headers, json=data, proxies=proxies).json()
if response["ok"]:
print("tg 推送成功!")