(text, desp)
| 1880 | } |
| 1881 | |
| 1882 | function gotifyNotify(text, desp) { |
| 1883 | return new Promise((resolve) => { |
| 1884 | if (GOTIFY_URL && GOTIFY_TOKEN) { |
| 1885 | const options = { |
| 1886 | url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`, |
| 1887 | body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`, |
| 1888 | headers: { |
| 1889 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 1890 | } |
| 1891 | }; |
| 1892 | $.post(options, (err, resp, data) => { |
| 1893 | try { |
| 1894 | if (err) { |
| 1895 | console.log('gotify发送通知调用API失败!!\n'); |
| 1896 | console.log(err); |
| 1897 | } else { |
| 1898 | data = JSON.parse(data); |
| 1899 | if (data.id) { |
| 1900 | console.log('gotify发送通知消息成功🎉\n'); |
| 1901 | } else { |
| 1902 | console.log(`${data.message}\n`); |
| 1903 | } |
| 1904 | } |
| 1905 | } catch (e) { |
| 1906 | $.logErr(e, resp); |
| 1907 | } |
| 1908 | finally { |
| 1909 | resolve(); |
| 1910 | } |
| 1911 | }); |
| 1912 | } else { |
| 1913 | resolve(); |
| 1914 | } |
| 1915 | }); |
| 1916 | } |
| 1917 | |
| 1918 | function gobotNotify(text, desp, time = 2100) { |
| 1919 | return new Promise((resolve) => { |
no test coverage detected