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

Function pushPlusNotify

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

Source from the content-addressed store, hash-verified

813}
814
815function pushPlusNotify(text, desp) {
816 return new Promise((resolve) => {
817 const {
818 PUSH_PLUS_TOKEN,
819 PUSH_PLUS_USER,
820 PUSH_PLUS_TEMPLATE,
821 PUSH_PLUS_CHANNEL,
822 PUSH_PLUS_WEBHOOK,
823 PUSH_PLUS_CALLBACKURL,
824 PUSH_PLUS_TO,
825 } = push_config;
826 if (PUSH_PLUS_TOKEN) {
827 desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
828 const body = {
829 token: `${PUSH_PLUS_TOKEN}`,
830 title: `${text}`,
831 content: `${desp}`,
832 topic: `${PUSH_PLUS_USER}`,
833 template: `${PUSH_PLUS_TEMPLATE}`,
834 channel: `${PUSH_PLUS_CHANNEL}`,
835 webhook: `${PUSH_PLUS_WEBHOOK}`,
836 callbackUrl: `${PUSH_PLUS_CALLBACKURL}`,
837 to: `${PUSH_PLUS_TO}`,
838 };
839 const options = {
840 url: `https://www.pushplus.plus/send`,
841 body: JSON.stringify(body),
842 headers: {
843 'Content-Type': ' application/json',
844 },
845 timeout,
846 };
847 $.post(options, (err, resp, data) => {
848 try {
849 if (err) {
850 console.log(
851 `pushplus 发送${
852 PUSH_PLUS_USER ? '一对多' : '一对一'
853 }通知消息失败😞\n`,
854 err,
855 );
856 } else {
857 if (data.code === 200) {
858 console.log(
859 `pushplus 发送${
860 PUSH_PLUS_USER ? '一对多' : '一对一'
861 }通知请求成功🎉,可根据流水号查询推送结果:${
862 data.data
863 }\n注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果`,
864 );
865 } else {
866 console.log(
867 `pushplus 发送${
868 PUSH_PLUS_USER ? '一对多' : '一对一'
869 }通知消息异常 ${data.msg}\n`,
870 );
871 }
872 }

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected