Update sendNotify.js

企业微信应用消息通知
增加一个选择推送消息类型,用图文消息直接填写素材库图片id的值,用卡片消息就填写0(就是数字零)
This commit is contained in:
huang28
2021-01-06 03:10:22 +08:00
parent 7beb3448a5
commit ce3738d20b

View File

@ -50,6 +50,7 @@ let QYWX_KEY = '';
// =======================================企业微信应用消息通知设置区域===========================================
//此处填你企业微信应用消息的 值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236)依次填上corpid的值,corpsecret的值,touser的值,agentid的值素材库图片id见https://github.com/lxk0301/jd_scripts/issues/519) 注意用,号隔开例如wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat
//增加一个选择推送消息类型用图文消息直接填写素材库图片id的值用卡片消息就填写0(就是数字零)
//注此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_AM)
let QYWX_AM = '';
@ -438,7 +439,24 @@ function qywxamNotify(text, desp) {
html=desp.replace(/\n/g,"<br/>")
var json = JSON.parse(data);
accesstoken = json.access_token;
const options = {
const options_textcard = {
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
json: {
touser:`${QYWX_AM_AY[2]}`,
agentid:`${QYWX_AM_AY[3]}`,
msgtype: 'textcard',
textcard: {
title: `${text}`,
description: `${desp}`,
url: '127.0.0.1',
},
safe:'0',
},
headers: {
'Content-Type': 'application/json',
},
};
const options_mpnews = {
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
json: {
touser:`${QYWX_AM_AY[2]}`,
@ -462,7 +480,7 @@ function qywxamNotify(text, desp) {
'Content-Type': 'application/json',
},
};
$.post(options, (err, resp, data) => {
$.post((QYWX_AM_AY[4]==0)?options_textcard:options_mpnews, (err, resp, data) => {
try {
if (err) {
console.log('企业微信应用消息发送通知消息失败!!\n');