MCPcopy Create free account
hub / github.com/6dylan6/jdm / gotifyNotify

Function gotifyNotify

sendNotify.js:1882–1916  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

1880}
1881
1882function 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
1918function gobotNotify(text, desp, time = 2100) {
1919 return new Promise((resolve) => {

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected