(text, desp, params = {})
| 684 | } |
| 685 | |
| 686 | function iGotNotify(text, desp, params = {}) { |
| 687 | return new Promise(resolve => { |
| 688 | if (IGOT_PUSH_KEY) { |
| 689 | // 校验传入的IGOT_PUSH_KEY是否有效 |
| 690 | const IGOT_PUSH_KEY_REGX = new RegExp("^[a-zA-Z0-9]{24}$") |
| 691 | if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { |
| 692 | console.log('您所提供的IGOT_PUSH_KEY无效\n') |
| 693 | resolve() |
| 694 | return |
| 695 | } |
| 696 | const options = { |
| 697 | url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, |
| 698 | body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, |
| 699 | headers: { |
| 700 | 'Content-Type': 'application/x-www-form-urlencoded' |
| 701 | }, |
| 702 | timeout |
| 703 | } |
| 704 | $.post(options, (err, resp, data) => { |
| 705 | try { |
| 706 | if (err) { |
| 707 | console.log('发送通知调用API失败!!\n') |
| 708 | console.log(err); |
| 709 | } else { |
| 710 | if (typeof data === 'string') data = JSON.parse(data); |
| 711 | if (data.ret === 0) { |
| 712 | console.log('iGot发送通知消息成功🎉\n') |
| 713 | } else { |
| 714 | console.log(`iGot发送通知消息失败:${data.errMsg}\n`) |
| 715 | } |
| 716 | } |
| 717 | } catch (e) { |
| 718 | $.logErr(e, resp); |
| 719 | } finally { |
| 720 | resolve(data); |
| 721 | } |
| 722 | }) |
| 723 | } else { |
| 724 | // console.log('您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知🚫\n'); |
| 725 | resolve() |
| 726 | } |
| 727 | }) |
| 728 | } |
| 729 | |
| 730 | function pushPlusNotify(text, desp) { |
| 731 | return new Promise(resolve => { |
no test coverage detected