(text, desp, params = {})
| 585 | } |
| 586 | |
| 587 | function iGotNotify(text, desp, params = {}) { |
| 588 | return new Promise(resolve => { |
| 589 | if (IGOT_PUSH_KEY) { |
| 590 | // 校验传入的IGOT_PUSH_KEY是否有效 |
| 591 | const IGOT_PUSH_KEY_REGX = new RegExp("^[a-zA-Z0-9]{24}$") |
| 592 | if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { |
| 593 | console.log('您所提供的IGOT_PUSH_KEY无效\n') |
| 594 | resolve() |
| 595 | return |
| 596 | } |
| 597 | const options = { |
| 598 | url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, |
| 599 | body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, |
| 600 | headers: { |
| 601 | 'Content-Type': 'application/x-www-form-urlencoded' |
| 602 | }, |
| 603 | timeout |
| 604 | } |
| 605 | $.post(options, (err, resp, data) => { |
| 606 | try { |
| 607 | if (err) { |
| 608 | console.log('发送通知调用API失败!!\n') |
| 609 | console.log(err); |
| 610 | } else { |
| 611 | if (typeof data === 'string') data = JSON.parse(data); |
| 612 | if (data.ret === 0) { |
| 613 | console.log('iGot发送通知消息成功🎉\n') |
| 614 | } else { |
| 615 | console.log(`iGot发送通知消息失败:${data.errMsg}\n`) |
| 616 | } |
| 617 | } |
| 618 | } catch (e) { |
| 619 | $.logErr(e, resp); |
| 620 | } finally { |
| 621 | resolve(data); |
| 622 | } |
| 623 | }) |
| 624 | } else { |
| 625 | console.log('您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知🚫\n'); |
| 626 | resolve() |
| 627 | } |
| 628 | }) |
| 629 | } |
| 630 | |
| 631 | function pushPlusNotify(text, desp) { |
| 632 | return new Promise(resolve => { |
no test coverage detected