(text, desp)
| 415 | } |
| 416 | |
| 417 | function qywxBotNotify(text, desp) { |
| 418 | return new Promise(resolve => { |
| 419 | const options = { |
| 420 | url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, |
| 421 | json: { |
| 422 | msgtype: 'text', |
| 423 | text: { |
| 424 | content: ` ${text}\n\n${desp}`, |
| 425 | }, |
| 426 | }, |
| 427 | headers: { |
| 428 | 'Content-Type': 'application/json', |
| 429 | }, |
| 430 | timeout |
| 431 | }; |
| 432 | if (QYWX_KEY) { |
| 433 | $.post(options, (err, resp, data) => { |
| 434 | try { |
| 435 | if (err) { |
| 436 | console.log('企业微信发送通知消息失败!!\n'); |
| 437 | console.log(err); |
| 438 | } else { |
| 439 | data = JSON.parse(data); |
| 440 | if (data.errcode === 0) { |
| 441 | console.log('企业微信发送通知消息成功🎉。\n'); |
| 442 | } else { |
| 443 | console.log(`${data.errmsg}\n`); |
| 444 | } |
| 445 | } |
| 446 | } catch (e) { |
| 447 | $.logErr(e, resp); |
| 448 | } finally { |
| 449 | resolve(data); |
| 450 | } |
| 451 | }); |
| 452 | } else { |
| 453 | console.log('您未提供企业微信机器人推送所需的QYWX_KEY,取消企业微信推送消息通知🚫\n'); |
| 454 | resolve(); |
| 455 | } |
| 456 | }); |
| 457 | } |
| 458 | |
| 459 | function ChangeUserId(desp) { |
| 460 | const QYWX_AM_AY = QYWX_AM.split(','); |
no test coverage detected