Skip to content

Commit

Permalink
♻️ 重构(message.py):将urllib.parse模块的导入方式改为从urllib.parse中导入quote_plus
Browse files Browse the repository at this point in the history
  ✨ 功能(message.py):在message2bark函数中添加对content的quote_plus处理
  • Loading branch information
Sitoi committed Mar 7, 2024
1 parent 44081f6 commit 882289f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dailycheckin/utils/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import hmac
import json
import time
import urllib.parse
from urllib.parse import quote_plus

import requests

Expand Down Expand Up @@ -90,7 +90,7 @@ def message2dingtalk(dingtalk_secret, dingtalk_access_token, content):
hmac_code = hmac.new(
secret_enc, string_to_sign_enc, digestmod=hashlib.sha256
).digest()
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code))
sign = quote_plus(base64.b64encode(hmac_code))
send_data = {"msgtype": "text", "text": {"content": content}}
requests.post(
url="https://oapi.dingtalk.com/robot/send?access_token={}&timestamp={}&sign={}".format(
Expand All @@ -106,6 +106,7 @@ def message2bark(bark_url: str, content):
print("Bark 推送开始")
if not bark_url.endswith("/"):
bark_url += "/"
content = quote_plus(content)
url = f"{bark_url}{content}"
headers = {"Content-type": "application/x-www-form-urlencoded"}
requests.get(url=url, headers=headers)
Expand Down

0 comments on commit 882289f

Please sign in to comment.