diff --git a/githubAction.md b/githubAction.md index 18a0e07d..79b38e02 100644 --- a/githubAction.md +++ b/githubAction.md @@ -24,7 +24,8 @@ | `TG_USER_ID` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](./backUp/TG_PUSH.md) | | `DD_BOT_TOKEN` | 钉钉推送 | 非必须 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 | | `DD_BOT_SECRET` | 钉钉推送 | 非必须 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](icon/DD_bot.png) | -| `QYWX_KEY` | 企业微信推送 | 非必须 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770)(环境变量里面corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id的获取,可查看 [此教程](http://note.youdao.com/s/HMiudGkb)) | +| `QYWX_KEY` | 企业微信推送 | 非必须 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) | +| `QYWX_AM` | 企业微信应用消息推送 | 非必须 | corpid,corpsecret,touser,agentid,素材库图片id [参考文档](http://note.youdao.com/s/HMiudGkb)
素材库图片填0为图文消息, 填1为纯文本消息 | | `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) | | `QQ_SKEY` | 酷推(Cool Push)推送 | 非必须 | 推送所需的Skey,登录后获取Skey [参考文档](https://cp.xuthus.cc/) | | `QQ_MODE` | 酷推(Cool Push)推送 | 非必须 | 推送方式(send或group或者wx,默认send) [参考文档](https://cp.xuthus.cc/) | diff --git a/sendNotify.js b/sendNotify.js index 1be8a642..4a113000 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -47,9 +47,13 @@ let DD_BOT_SECRET = ''; let QYWX_KEY = ''; // =======================================企业微信应用消息通知设置区域=========================================== -//此处填你企业微信应用消息的 值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236),依次填上corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id(见https://github.com/LXK9301/jd_scripts/issues/519) 注意用,号隔开,例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat -//corpid的值,corpsecret的值,touser的值,agentid的值,素材库图片id的获取,可查看此教程(http://note.youdao.com/s/HMiudGkb) -//增加一个选择推送消息类型,用图文消息直接填写素材库图片id的值,用卡片消息就填写0(就是数字零) +//此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236) +//依次填入 corpid,corpsecret,touser,agentid,消息类型 +//注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +//可选推送消息类型: +// - 卡片消息: 0 (数字零) +// - 文字消息: 1 (数字一) +// - 图文消息: 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb) //(环境变量名 QYWX_AM) let QYWX_AM = ''; @@ -476,49 +480,62 @@ function qywxamNotify(text, desp) { html=desp.replace(/\n/g,"
") var json = JSON.parse(data); accesstoken = json.access_token; - 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', - btntxt: '更多' - }, - 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: [ - { - title: `${text}`, + let options; + + switch (QYWX_AM_AY[4]) { + case '0': + options = { + msgtype: 'textcard', + textcard: { + title: `${text}`, + description: `${desp}`, + url: '127.0.0.1', + btntxt: '更多' + } + } + break; + + case '1': + options = { + msgtype: 'text', + text: { + content: `${text}\n\n${desp}` + } + } + break; + + default: + options = { + msgtype: 'mpnews', + mpnews: { + articles: [ + { + title: `${text}`, thumb_media_id: `${QYWX_AM_AY[4]}`, author : `智能助手` , content_source_url: ``, content : `${html}`, digest: `${desp}` - } - ] - }, + } + ] + } + } + }; + + options = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser:`${QYWX_AM_AY[2]}`, + agentid:`${QYWX_AM_AY[3]}`, safe:'0', + ...options }, headers: { 'Content-Type': 'application/json', }, - }; - $.post((QYWX_AM_AY[4]==0)?options_textcard:options_mpnews, (err, resp, data) => { + } + + $.post(options, (err, resp, data) => { try { if (err) { console.log('企业微信应用消息发送通知消息失败!!\n');