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

Function iGotNotify

function/sendNotify.js:1667–1710  ·  view source on GitHub ↗
(text, desp, params = {})

Source from the content-addressed store, hash-verified

1665}
1666
1667function iGotNotify(text, desp, params = {}) {
1668 return new Promise((resolve) => {
1669 if (IGOT_PUSH_KEY) {
1670 // 校验传入的IGOT_PUSH_KEY是否有效
1671 const IGOT_PUSH_KEY_REGX = new RegExp('^[a-zA-Z0-9]{24}$');
1672 if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) {
1673 console.log('您所提供的IGOT_PUSH_KEY无效\n');
1674 resolve();
1675 return;
1676 }
1677 const options = {
1678 url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`,
1679 body: `title=${text}&content=${desp}&${querystring.stringify(params)}`,
1680 headers: {
1681 'Content-Type': 'application/x-www-form-urlencoded',
1682 },
1683 timeout,
1684 };
1685 $.post(options, (err, resp, data) => {
1686 try {
1687 if (err) {
1688 console.log('发送通知调用API失败!!\n');
1689 console.log(err);
1690 } else {
1691 if (typeof data === 'string')
1692 data = JSON.parse(data);
1693 if (data.ret === 0) {
1694 console.log('iGot发送通知消息成功🎉\n');
1695 } else {
1696 console.log(`iGot发送通知消息失败:${data.errMsg}\n`);
1697 }
1698 }
1699 } catch (e) {
1700 $.logErr(e, resp);
1701 }
1702 finally {
1703 resolve(data);
1704 }
1705 });
1706 } else {
1707 resolve();
1708 }
1709 });
1710}
1711
1712function pushPlusNotify(text, desp) {
1713 return new Promise((resolve) => {

Callers 1

sendNotifyFunction · 0.70

Calls 3

logMethod · 0.45
postMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected