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

Function PushDeerNotify

function/sendNotify.js:1912–1954  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

1910}
1911
1912function PushDeerNotify(text, desp) {
1913 return new Promise((resolve) => {
1914 if (PUSHDEER_KEY) {
1915 desp = encodeURI(desp);
1916 desp = desp.replace(/%0A/g, '%0A%0A');
1917 const options = {
1918 url: `https://api2.pushdeer.com/message/push`,
1919 body: `pushkey=${PUSHDEER_KEY}&text=${text}&desp=${desp}&type="markdown"`,
1920 headers: {
1921 'Content-Type': 'application/x-www-form-urlencoded',
1922 },
1923 timeout: 5000,
1924 };
1925 $.post(options, (err, resp, data) => {
1926 try {
1927 if (err) {
1928 console.log('发送通知调用API失败!!\n');
1929 console.log(err);
1930 } else {
1931 data = JSON.parse(data);
1932 // 通过返回的result的长度来判断是否成功
1933 if (
1934 data.content.result.length !== undefined &&
1935 data.content.result.length > 0
1936 ) {
1937 console.log('PushDeer发送通知消息成功🎉\n');
1938 } else {
1939 console.log(
1940 `PushDeer发送通知消息异常\n${JSON.stringify(data)}`,
1941 );
1942 }
1943 }
1944 } catch (e) {
1945 $.logErr(e, resp);
1946 } finally {
1947 resolve(data);
1948 }
1949 });
1950 } else {
1951 resolve();
1952 }
1953 });
1954}
1955
1956function GetDateTime(date) {
1957

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected