企业微信应用通知,可根据用户ID顺序进行一对一推送(兼容之前设置的用户ID)
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
| `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) |
|
||||
| `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)<br>素材库图片填0为图文消息, 填1为纯文本消息 |
|
||||
| `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) |
|
||||
| `PUSH_PLUS_TOKEN` | pushplus推送 | 非必须 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://pushplus.hxtrip.com/) |
|
||||
|
@@ -463,10 +463,29 @@ function qywxBotNotify(text, desp) {
|
||||
});
|
||||
}
|
||||
|
||||
function ChangeUserId(desp) {
|
||||
const QYWX_AM_AY = QYWX_AM.split(',');
|
||||
if (QYWX_AM_AY[2]) {
|
||||
const userIdTmp = QYWX_AM_AY[2].split("|");
|
||||
let userId = "";
|
||||
for (let i = 0; i < userIdTmp.length; i++) {
|
||||
const count = "账号" + (i + 1);
|
||||
const count2 = "签到号 " + (i + 1);
|
||||
if (desp.match(count) || desp.match(count2)) {
|
||||
userId = userIdTmp[i];
|
||||
}
|
||||
}
|
||||
if (!userId) userId = QYWX_AM_AY[2];
|
||||
return userId;
|
||||
} else {
|
||||
return "@all";
|
||||
}
|
||||
}
|
||||
|
||||
function qywxamNotify(text, desp) {
|
||||
return new Promise(resolve => {
|
||||
if (QYWX_AM) {
|
||||
var QYWX_AM_AY = QYWX_AM.split(',');
|
||||
const QYWX_AM_AY = QYWX_AM.split(',');
|
||||
const options_accesstoken = {
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
|
||||
json: {
|
||||
@@ -521,12 +540,13 @@ function qywxamNotify(text, desp) {
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
options = {
|
||||
url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`,
|
||||
json: {
|
||||
touser:`${QYWX_AM_AY[2]}`,
|
||||
touser: `${ChangeUserId(desp)}`,
|
||||
agentid: `${QYWX_AM_AY[3]}`,
|
||||
safe: '0',
|
||||
...options
|
||||
@@ -539,12 +559,12 @@ function qywxamNotify(text, desp) {
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log('企业微信应用消息发送通知消息失败!!\n');
|
||||
console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息失败!!\n');
|
||||
console.log(err);
|
||||
} else {
|
||||
data = JSON.parse(data);
|
||||
if (data.errcode === 0) {
|
||||
console.log('企业微信应用消息发送通知消息完成。\n');
|
||||
console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息完成。\n');
|
||||
} else {
|
||||
console.log(`${data.errmsg}\n`);
|
||||
}
|
||||
|
Reference in New Issue
Block a user