From 55d374abe2b17d7f97f6163fbf7a8045c5a72243 Mon Sep 17 00:00:00 2001 From: graywolf Date: Wed, 31 Jan 2024 11:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E4=BB=A3=E7=90=86=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sendNotify.js | 12 ++++++++---- sendNotify.py | 17 ++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sendNotify.js b/sendNotify.js index 1a1b12d..821e27a 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -73,7 +73,7 @@ let DD_BOT_SECRET = ''; //此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa //(环境变量名 QYWX_KEY) let QYWX_KEY = ''; - +let QYWX_ORIGIN = 'qyapi.weixin.qq.com'; // =======================================企业微信应用消息通知设置区域=========================================== /* 此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236) @@ -232,6 +232,7 @@ async function sendNotify(text, desp, params = {}, author = "\n================= DD_BOT_TOKEN = ''; DD_BOT_SECRET = ''; QYWX_KEY = ''; + QYWX_ORIGIN = 'qyapi.weixin.qq.com'; QYWX_AM = ''; FS_KEY = ''; IGOT_PUSH_KEY = ''; @@ -684,6 +685,9 @@ async function sendNotify(text, desp, params = {}, author = "\n================= if (process.env["QYWX_AM" + UseGroupNotify] && Use_qywxamNotify) { QYWX_AM = process.env["QYWX_AM" + UseGroupNotify]; } + + if (process.env["QYWX_ORIGIN"]) + QYWX_ORIGIN = process.env["QYWX_ORIGIN"]; if (process.env["FS_KEY" + UseGroupNotify] && Use_fsBotNotify) { FS_KEY = process.env["FS_KEY" + UseGroupNotify]; @@ -1492,7 +1496,7 @@ function ddBotNotify(text, desp) { function qywxBotNotify(text, desp) { return new Promise((resolve) => { const options = { - url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, + url: `https://${QYWX_ORIGIN}/cgi-bin/webhook/send?key=${QYWX_KEY}`, json: { msgtype: 'text', text: { @@ -1610,7 +1614,7 @@ function qywxamNotify(text, desp, strsummary = "") { if (QYWX_AM) { const QYWX_AM_AY = QYWX_AM.split(','); const options_accesstoken = { - url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, + url: `https://${QYWX_ORIGIN}/cgi-bin/gettoken`, json: { corpid: `${QYWX_AM_AY[0]}`, corpsecret: `${QYWX_AM_AY[1]}`, @@ -1677,7 +1681,7 @@ function qywxamNotify(text, desp, strsummary = "") { }; } options = { - url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + url: `https://${QYWX_ORIGIN}/cgi-bin/message/send?access_token=${accesstoken}`, json: { touser: `${ChangeUserId(desp)}`, agentid: `${QYWX_AM_AY[3]}`, diff --git a/sendNotify.py b/sendNotify.py index 3da64f1..e2a3a1c 100644 --- a/sendNotify.py +++ b/sendNotify.py @@ -23,7 +23,7 @@ sys.path.append(root_path) # 通知服务 BARK = '' # bark服务,自行搜索; secrets可填; BARK_PUSH='' # bark自建服务器,要填完整链接,结尾的/不要 -PUSH_KEY = '' # Server酱的PUSH_KEY; secrets可填 +PUSH_KEY = '' # Server酱的PUSH_KEY; secrets可填 TG_BOT_TOKEN = '' # tg机器人的TG_BOT_TOKEN; secrets可填1407203283:AAG9rt-6RDaaX0HBLZQq0laNOh898iFYaRQ TG_USER_ID = '' # tg机器人的TG_USER_ID; secrets可填 1434078534 TG_API_HOST='' # tg 代理api @@ -33,8 +33,9 @@ DD_BOT_TOKEN = '' # 钉钉机器人的DD_BOT_TOKEN; secrets可填 DD_BOT_SECRET = '' # 钉钉机器人的DD_BOT_SECRET; secrets可填 QQ_SKEY = '' # qq机器人的QQ_SKEY; secrets可填 QQ_MODE = '' # qq机器人的QQ_MODE; secrets可填 +QYWX_ORIGIN = 'qyapi.weixin.qq.com' # 企业微信反向代理地址 QYWX_AM = '' # 企业微信 -QYWX_KEY = '' # 企业微信BOT +QYWX_KEY = '' # 企业微信BOT PUSH_PLUS_TOKEN = '' # 微信推送Plus+ FS_KEY = '' #飞书群BOT @@ -70,6 +71,8 @@ if "QYWX_AM" in os.environ: if len(os.environ["QYWX_AM"]) > 1: QYWX_AM = os.environ["QYWX_AM"] +if "QYWX_ORIGIN" in os.environ and os.environ["QYWX_ORIGIN"]: + QYWX_ORIGIN = os.environ["QYWX_ORIGIN"] if "QYWX_KEY" in os.environ: if len(os.environ["QYWX_KEY"]) > 1: @@ -275,8 +278,8 @@ def wecom_key(title, content): } } - print(f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={QYWX_KEY}") - response = requests.post(f"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={QYWX_KEY}", json=data,headers=headers).json() + print(f"https://{QYWX_ORIGIN}/cgi-bin/webhook/send?key={QYWX_KEY}") + response = requests.post(f"https://{QYWX_ORIGIN}/cgi-bin/webhook/send?key={QYWX_KEY}", json=data,headers=headers).json() print(response) # 飞书机器人推送 @@ -339,7 +342,7 @@ class WeCom: self.AGENTID = agentid def get_access_token(self): - url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken' + url = 'https://{QYWX_ORIGIN}/cgi-bin/gettoken' values = {'corpid': self.CORPID, 'corpsecret': self.CORPSECRET, } @@ -348,7 +351,7 @@ class WeCom: return data["access_token"] def send_text(self, message, touser="@all"): - send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + self.get_access_token() + send_url = 'https://{QYWX_ORIGIN}/cgi-bin/message/send?access_token=' + self.get_access_token() send_values = { "touser": touser, "msgtype": "text", @@ -364,7 +367,7 @@ class WeCom: return respone["errmsg"] def send_mpnews(self, title, message, media_id, touser="@all"): - send_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + self.get_access_token() + send_url = 'https://{QYWX_ORIGIN}/cgi-bin/message/send?access_token=' + self.get_access_token() send_values = { "touser": touser, "msgtype": "mpnews",