(text, desp)
| 513 | } |
| 514 | |
| 515 | function qywxBotNotify(text, desp) { |
| 516 | return new Promise(resolve => { |
| 517 | const options = { |
| 518 | url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, |
| 519 | json: { |
| 520 | msgtype: 'text', |
| 521 | text: { |
| 522 | content: ` ${text}\n\n${desp}`, |
| 523 | }, |
| 524 | }, |
| 525 | headers: { |
| 526 | 'Content-Type': 'application/json', |
| 527 | }, |
| 528 | timeout |
| 529 | }; |
| 530 | if (QYWX_KEY) { |
| 531 | $.post(options, (err, resp, data) => { |
| 532 | try { |
| 533 | if (err) { |
| 534 | console.log('企业微信发送通知消息失败!!\n'); |
| 535 | console.log(err); |
| 536 | } else { |
| 537 | data = JSON.parse(data); |
| 538 | if (data.errcode === 0) { |
| 539 | console.log('企业微信发送通知消息成功🎉。\n'); |
| 540 | } else { |
| 541 | console.log(`${data.errmsg}\n`); |
| 542 | } |
| 543 | } |
| 544 | } catch (e) { |
| 545 | $.logErr(e, resp); |
| 546 | } finally { |
| 547 | resolve(data); |
| 548 | } |
| 549 | }); |
| 550 | } else { |
| 551 | // console.log('您未提供企业微信机器人推送所需的QYWX_KEY,取消企业微信推送消息通知🚫\n'); |
| 552 | resolve(); |
| 553 | } |
| 554 | }); |
| 555 | } |
| 556 | |
| 557 | function ChangeUserId(desp) { |
| 558 | const QYWX_AM_AY = QYWX_AM.split(','); |
no test coverage detected