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

Function barkNotify

sendNofity.js:404–459  ·  view source on GitHub ↗
(text, desp, params = {})

Source from the content-addressed store, hash-verified

402}
403
404function barkNotify(text, desp, params = {}) {
405 return new Promise((resolve) => {
406 let {
407 BARK_PUSH,
408 BARK_ICON,
409 BARK_SOUND,
410 BARK_GROUP,
411 BARK_LEVEL,
412 BARK_ARCHIVE,
413 BARK_URL,
414 } = push_config;
415 if (BARK_PUSH) {
416 // 兼容BARK本地用户只填写设备码的情况
417 if (!BARK_PUSH.startsWith('http')) {
418 BARK_PUSH = `https://api.day.app/${BARK_PUSH}`;
419 }
420 const options = {
421 url: `${BARK_PUSH}`,
422 json: {
423 title: text,
424 body: desp,
425 icon: BARK_ICON,
426 sound: BARK_SOUND,
427 group: BARK_GROUP,
428 isArchive: BARK_ARCHIVE,
429 level: BARK_LEVEL,
430 url: BARK_URL,
431 ...params,
432 },
433 headers: {
434 'Content-Type': 'application/json',
435 },
436 timeout,
437 };
438 $.post(options, (err, resp, data) => {
439 try {
440 if (err) {
441 console.log('Bark APP 发送通知调用API失败😞\n', err);
442 } else {
443 if (data.code === 200) {
444 console.log('Bark APP 发送通知消息成功🎉\n');
445 } else {
446 console.log(`Bark APP 发送通知消息异常 ${data.message}\n`);
447 }
448 }
449 } catch (e) {
450 $.logErr(e, resp);
451 } finally {
452 resolve();
453 }
454 });
455 } else {
456 resolve();
457 }
458 });
459}
460
461function tgBotNotify(text, desp) {

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected