Update sendNotify.js
企业微信应用消息通知 增加一个选择推送消息类型,用图文消息直接填写素材库图片id的值,用卡片消息就填写0(就是数字零)
This commit is contained in:
@@ -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
|
//此处填你企业微信应用消息的 值(详见文档 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)
|
//注:此处设置github action用户填写到Settings-Secrets里面(Name输入QYWX_AM)
|
||||||
let QYWX_AM = '';
|
let QYWX_AM = '';
|
||||||
|
|
||||||
@@ -423,31 +424,48 @@ function qywxBotNotify(text, desp) {
|
|||||||
function qywxamNotify(text, desp) {
|
function qywxamNotify(text, desp) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
if (QYWX_AM) {
|
if (QYWX_AM) {
|
||||||
var QYWX_AM_AY = QYWX_AM.split(',');
|
var QYWX_AM_AY = QYWX_AM.split(',');
|
||||||
const options_accesstoken = {
|
const options_accesstoken = {
|
||||||
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
||||||
json: {
|
json: {
|
||||||
corpid:`${QYWX_AM_AY[0]}`,
|
corpid:`${QYWX_AM_AY[0]}`,
|
||||||
corpsecret:`${QYWX_AM_AY[1]}`,
|
corpsecret:`${QYWX_AM_AY[1]}`,
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
$.post(options_accesstoken, (err, resp, data) => {
|
$.post(options_accesstoken, (err, resp, data) => {
|
||||||
html=desp.replace(/\n/g,"<br/>")
|
html=desp.replace(/\n/g,"<br/>")
|
||||||
var json = JSON.parse(data);
|
var json = JSON.parse(data);
|
||||||
accesstoken = json.access_token;
|
accesstoken = json.access_token;
|
||||||
const options = {
|
const options_textcard = {
|
||||||
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
|
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
|
||||||
json: {
|
json: {
|
||||||
touser:`${QYWX_AM_AY[2]}`,
|
touser:`${QYWX_AM_AY[2]}`,
|
||||||
agentid:`${QYWX_AM_AY[3]}`,
|
agentid:`${QYWX_AM_AY[3]}`,
|
||||||
msgtype: 'mpnews',
|
msgtype: 'textcard',
|
||||||
mpnews: {
|
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]}`,
|
||||||
|
agentid:`${QYWX_AM_AY[3]}`,
|
||||||
|
msgtype: 'mpnews',
|
||||||
|
mpnews: {
|
||||||
articles: [
|
articles: [
|
||||||
{
|
{
|
||||||
title: `${text}`,
|
title: `${text}`,
|
||||||
thumb_media_id: `${QYWX_AM_AY[4]}`,
|
thumb_media_id: `${QYWX_AM_AY[4]}`,
|
||||||
author : `智能助手` ,
|
author : `智能助手` ,
|
||||||
content_source_url: ``,
|
content_source_url: ``,
|
||||||
@@ -455,14 +473,14 @@ function qywxamNotify(text, desp) {
|
|||||||
digest: `${desp}`
|
digest: `${desp}`
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
safe:'0',
|
safe:'0',
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
$.post(options, (err, resp, data) => {
|
$.post((QYWX_AM_AY[4]==0)?options_textcard:options_mpnews, (err, resp, data) => {
|
||||||
try {
|
try {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('企业微信应用消息发送通知消息失败!!\n');
|
console.log('企业微信应用消息发送通知消息失败!!\n');
|
||||||
|
Reference in New Issue
Block a user