(text, desp)
| 728 | } |
| 729 | |
| 730 | function pushPlusNotify(text, desp) { |
| 731 | return new Promise(resolve => { |
| 732 | if (PUSH_PLUS_TOKEN) { |
| 733 | desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext |
| 734 | const body = { |
| 735 | token: `${PUSH_PLUS_TOKEN}`, |
| 736 | title: `${text}`, |
| 737 | content: `${desp}`, |
| 738 | topic: `${PUSH_PLUS_USER}` |
| 739 | }; |
| 740 | const options = { |
| 741 | url: `http://www.pushplus.plus/send`, |
| 742 | body: JSON.stringify(body), |
| 743 | headers: { |
| 744 | 'Content-Type': ' application/json' |
| 745 | }, |
| 746 | timeout |
| 747 | } |
| 748 | $.post(options, (err, resp, data) => { |
| 749 | try { |
| 750 | if (err) { |
| 751 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`) |
| 752 | console.log(err); |
| 753 | } else { |
| 754 | data = JSON.parse(data); |
| 755 | if (data.code === 200) { |
| 756 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`) |
| 757 | } else { |
| 758 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`) |
| 759 | } |
| 760 | } |
| 761 | } catch (e) { |
| 762 | $.logErr(e, resp); |
| 763 | } finally { |
| 764 | resolve(data); |
| 765 | } |
| 766 | }) |
| 767 | } else { |
| 768 | // console.log('您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知🚫\n'); |
| 769 | resolve() |
| 770 | } |
| 771 | }) |
| 772 | } |
| 773 | |
| 774 | function wxpusher(title, content, uid) { |
| 775 | return new Promise(resolve => { |
no test coverage detected