MCPcopy Create free account
hub / github.com/Semporia/Scripts / iGotNotify

Function iGotNotify

sendNotify.js:587–629  ·  view source on GitHub ↗
(text, desp, params = {})

Source from the content-addressed store, hash-verified

585}
586
587function iGotNotify(text, desp, params = {}) {
588 return new Promise(resolve => {
589 if (IGOT_PUSH_KEY) {
590 // 校验传入的IGOT_PUSH_KEY是否有效
591 const IGOT_PUSH_KEY_REGX = new RegExp("^[a-zA-Z0-9]{24}$")
592 if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) {
593 console.log('您所提供的IGOT_PUSH_KEY无效\n')
594 resolve()
595 return
596 }
597 const options = {
598 url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`,
599 body: `title=${text}&content=${desp}&${querystring.stringify(params)}`,
600 headers: {
601 'Content-Type': 'application/x-www-form-urlencoded'
602 },
603 timeout
604 }
605 $.post(options, (err, resp, data) => {
606 try {
607 if (err) {
608 console.log('发送通知调用API失败!!\n')
609 console.log(err);
610 } else {
611 if (typeof data === 'string') data = JSON.parse(data);
612 if (data.ret === 0) {
613 console.log('iGot发送通知消息成功🎉\n')
614 } else {
615 console.log(`iGot发送通知消息失败:${data.errMsg}\n`)
616 }
617 }
618 } catch (e) {
619 $.logErr(e, resp);
620 } finally {
621 resolve(data);
622 }
623 })
624 } else {
625 console.log('您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知🚫\n');
626 resolve()
627 }
628 })
629}
630
631function pushPlusNotify(text, desp) {
632 return new Promise(resolve => {

Callers 1

sendNotifyFunction · 0.85

Calls 3

logMethod · 0.45
postMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected