(text, desp)
| 1710 | } |
| 1711 | |
| 1712 | function pushPlusNotify(text, desp) { |
| 1713 | return new Promise((resolve) => { |
| 1714 | if (PUSH_PLUS_TOKEN) { |
| 1715 | |
| 1716 | //desp = `<font size="3">${desp}</font>`; |
| 1717 | |
| 1718 | desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext |
| 1719 | const body = { |
| 1720 | token: `${PUSH_PLUS_TOKEN}`, |
| 1721 | title: `${text}`, |
| 1722 | content: `${desp}`, |
| 1723 | topic: `${PUSH_PLUS_USER}`, |
| 1724 | }; |
| 1725 | const options = { |
| 1726 | url: `https://www.pushplus.plus/send`, |
| 1727 | body: JSON.stringify(body), |
| 1728 | headers: { |
| 1729 | 'Content-Type': ' application/json', |
| 1730 | }, |
| 1731 | timeout, |
| 1732 | }; |
| 1733 | $.post(options, (err, resp, data) => { |
| 1734 | try { |
| 1735 | if (err) { |
| 1736 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`); |
| 1737 | PushErrorTime += 1; |
| 1738 | console.log(err); |
| 1739 | } else { |
| 1740 | data = JSON.parse(data); |
| 1741 | if (data.code === 200) { |
| 1742 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`); |
| 1743 | PushErrorTime = 0; |
| 1744 | } else { |
| 1745 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`); |
| 1746 | PushErrorTime += 1; |
| 1747 | } |
| 1748 | } |
| 1749 | } catch (e) { |
| 1750 | $.logErr(e, resp); |
| 1751 | } |
| 1752 | finally { |
| 1753 | resolve(data); |
| 1754 | } |
| 1755 | }); |
| 1756 | } else { |
| 1757 | resolve(); |
| 1758 | } |
| 1759 | }); |
| 1760 | } |
| 1761 | function wxpusherNotifyByOne(text, desp, strsummary = "") { |
| 1762 | return new Promise((resolve) => { |
| 1763 | if (WP_APP_TOKEN_ONE) { |
no test coverage detected