MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / gotifyNotify

Function gotifyNotify

sendNofity.js:204–238  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

202}
203
204function gotifyNotify(text, desp) {
205 return new Promise((resolve) => {
206 const { GOTIFY_URL, GOTIFY_TOKEN, GOTIFY_PRIORITY } = push_config;
207 if (GOTIFY_URL && GOTIFY_TOKEN) {
208 const options = {
209 url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`,
210 body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(
211 desp,
212 )}&priority=${GOTIFY_PRIORITY}`,
213 headers: {
214 'Content-Type': 'application/x-www-form-urlencoded',
215 },
216 };
217 $.post(options, (err, resp, data) => {
218 try {
219 if (err) {
220 console.log('Gotify 发送通知调用API失败😞\n', err);
221 } else {
222 if (data.id) {
223 console.log('Gotify 发送通知消息成功🎉\n');
224 } else {
225 console.log(`Gotify 发送通知调用API失败😞 ${data.message}\n`);
226 }
227 }
228 } catch (e) {
229 $.logErr(e, resp);
230 } finally {
231 resolve();
232 }
233 });
234 } else {
235 resolve();
236 }
237 });
238}
239
240function gobotNotify(text, desp) {
241 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