(text, desp)
| 1854 | } |
| 1855 | |
| 1856 | function wxpusherNotify(text, desp) { |
| 1857 | return new Promise((resolve) => { |
| 1858 | if (WP_APP_TOKEN) { |
| 1859 | let uids = []; |
| 1860 | for (let i of WP_UIDS.split(";")) { |
| 1861 | if (i.length != 0) |
| 1862 | uids.push(i); |
| 1863 | }; |
| 1864 | let topicIds = []; |
| 1865 | for (let i of WP_TOPICIDS.split(";")) { |
| 1866 | if (i.length != 0) |
| 1867 | topicIds.push(i); |
| 1868 | }; |
| 1869 | desp = `<font size="4"><b>${text}</b></font>\n\n<font size="3">${desp}</font>`; |
| 1870 | desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext |
| 1871 | const body = { |
| 1872 | appToken: `${WP_APP_TOKEN}`, |
| 1873 | content: `${text}\n\n${desp}`, |
| 1874 | summary: `${text}`, |
| 1875 | contentType: 2, |
| 1876 | topicIds: topicIds, |
| 1877 | uids: uids, |
| 1878 | url: `${WP_URL}`, |
| 1879 | }; |
| 1880 | const options = { |
| 1881 | url: `http://wxpusher.zjiecode.com/api/send/message`, |
| 1882 | body: JSON.stringify(body), |
| 1883 | headers: { |
| 1884 | "Content-Type": "application/json", |
| 1885 | }, |
| 1886 | timeout, |
| 1887 | }; |
| 1888 | $.post(options, (err, resp, data) => { |
| 1889 | try { |
| 1890 | if (err) { |
| 1891 | console.log("WxPusher 发送通知调用 API 失败!!\n"); |
| 1892 | console.log(err); |
| 1893 | } else { |
| 1894 | data = JSON.parse(data); |
| 1895 | if (data.code === 1000) { |
| 1896 | console.log("WxPusher 发送通知消息成功!\n"); |
| 1897 | } |
| 1898 | } |
| 1899 | } catch (e) { |
| 1900 | $.logErr(e, resp); |
| 1901 | } |
| 1902 | finally { |
| 1903 | resolve(data); |
| 1904 | } |
| 1905 | }); |
| 1906 | } else { |
| 1907 | resolve(); |
| 1908 | } |
| 1909 | }); |
| 1910 | } |
| 1911 | |
| 1912 | function PushDeerNotify(text, desp) { |
| 1913 | return new Promise((resolve) => { |
no test coverage detected