mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复python和JavaScript钉钉推送的环境变量不一致 (#659)
This commit is contained in:
parent
b3ac81b7b7
commit
0cbfca979e
|
@ -25,7 +25,7 @@ TG_BOT_TOKEN = '' # tg
|
|||
TG_USER_ID = '' # tg机器人的TG_USER_ID; secrets可填
|
||||
TG_PROXY_IP = '' # tg机器人的TG_PROXY_IP; secrets可填
|
||||
TG_PROXY_PORT = '' # tg机器人的TG_PROXY_PORT; secrets可填
|
||||
DD_BOT_ACCESS_TOKEN = '' # 钉钉机器人的DD_BOT_ACCESS_TOKEN; secrets可填
|
||||
DD_BOT_TOKEN = '' # 钉钉机器人的DD_BOT_TOKEN; secrets可填
|
||||
DD_BOT_SECRET = '' # 钉钉机器人的DD_BOT_SECRET; secrets可填
|
||||
QYWX_APP = '' # 企业微信应用的QYWX_APP; secrets可填 参考http://note.youdao.com/s/HMiudGkb
|
||||
|
||||
|
@ -39,8 +39,8 @@ if "SCKEY" in os.environ and os.environ["SCKEY"]:
|
|||
if "TG_BOT_TOKEN" in os.environ and os.environ["TG_BOT_TOKEN"] and "TG_USER_ID" in os.environ and os.environ["TG_USER_ID"]:
|
||||
TG_BOT_TOKEN = os.environ["TG_BOT_TOKEN"]
|
||||
TG_USER_ID = os.environ["TG_USER_ID"]
|
||||
if "DD_BOT_ACCESS_TOKEN" in os.environ and os.environ["DD_BOT_ACCESS_TOKEN"] and "DD_BOT_SECRET" in os.environ and os.environ["DD_BOT_SECRET"]:
|
||||
DD_BOT_ACCESS_TOKEN = os.environ["DD_BOT_ACCESS_TOKEN"]
|
||||
if "DD_BOT_TOKEN" in os.environ and os.environ["DD_BOT_TOKEN"] and "DD_BOT_SECRET" in os.environ and os.environ["DD_BOT_SECRET"]:
|
||||
DD_BOT_TOKEN = os.environ["DD_BOT_TOKEN"]
|
||||
DD_BOT_SECRET = os.environ["DD_BOT_SECRET"]
|
||||
if "QYWX_APP" in os.environ and os.environ["QYWX_APP"]:
|
||||
QYWX_APP = os.environ["QYWX_APP"]
|
||||
|
@ -54,7 +54,7 @@ if SCKEY:
|
|||
if TG_BOT_TOKEN and TG_USER_ID:
|
||||
notify_mode.append('telegram_bot')
|
||||
print("Telegram 推送打开")
|
||||
if DD_BOT_ACCESS_TOKEN and DD_BOT_SECRET:
|
||||
if DD_BOT_TOKEN and DD_BOT_SECRET:
|
||||
notify_mode.append('dingding_bot')
|
||||
print("钉钉机器人 推送打开")
|
||||
if QYWX_APP:
|
||||
|
@ -123,7 +123,7 @@ def dingding_bot(title, content):
|
|||
hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest()
|
||||
sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) # 签名
|
||||
print('开始使用 钉钉机器人 推送消息...', end='')
|
||||
url = f'https://oapi.dingtalk.com/robot/send?access_token={DD_BOT_ACCESS_TOKEN}×tamp={timestamp}&sign={sign}'
|
||||
url = f'https://oapi.dingtalk.com/robot/send?access_token={DD_BOT_TOKEN}×tamp={timestamp}&sign={sign}'
|
||||
headers = {'Content-Type': 'application/json;charset=utf-8'}
|
||||
data = {
|
||||
'msgtype': 'text',
|
||||
|
@ -249,7 +249,7 @@ def send(title, content):
|
|||
print('未启用 Server酱')
|
||||
continue
|
||||
elif i == 'dingding_bot':
|
||||
if DD_BOT_ACCESS_TOKEN and DD_BOT_SECRET:
|
||||
if DD_BOT_TOKEN and DD_BOT_SECRET:
|
||||
dingding_bot(title=title, content=content)
|
||||
else:
|
||||
print('未启用 钉钉机器人')
|
||||
|
@ -274,4 +274,4 @@ def main():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user