(text, desp, params = {})
| 771 | } |
| 772 | |
| 773 | function iGotNotify(text, desp, params = {}) { |
| 774 | return new Promise((resolve) => { |
| 775 | const { IGOT_PUSH_KEY } = push_config; |
| 776 | if (IGOT_PUSH_KEY) { |
| 777 | // 校验传入的IGOT_PUSH_KEY是否有效 |
| 778 | const IGOT_PUSH_KEY_REGX = new RegExp('^[a-zA-Z0-9]{24}$'); |
| 779 | if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { |
| 780 | console.log('您所提供的 IGOT_PUSH_KEY 无效\n'); |
| 781 | resolve(); |
| 782 | return; |
| 783 | } |
| 784 | const options = { |
| 785 | url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, |
| 786 | body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, |
| 787 | headers: { |
| 788 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 789 | }, |
| 790 | timeout, |
| 791 | }; |
| 792 | $.post(options, (err, resp, data) => { |
| 793 | try { |
| 794 | if (err) { |
| 795 | console.log('IGot 发送通知调用API失败😞\n', err); |
| 796 | } else { |
| 797 | if (data.ret === 0) { |
| 798 | console.log('IGot 发送通知消息成功🎉\n'); |
| 799 | } else { |
| 800 | console.log(`IGot 发送通知消息异常 ${data.errMsg}\n`); |
| 801 | } |
| 802 | } |
| 803 | } catch (e) { |
| 804 | $.logErr(e, resp); |
| 805 | } finally { |
| 806 | resolve(data); |
| 807 | } |
| 808 | }); |
| 809 | } else { |
| 810 | resolve(); |
| 811 | } |
| 812 | }); |
| 813 | } |
| 814 | |
| 815 | function pushPlusNotify(text, desp) { |
| 816 | return new Promise((resolve) => { |
no test coverage detected