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

Function pushPlusNotify

tools/sendNotify.js:815–879  ·  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 发送${PUSH_PLUS_USER ? '一对多' : '一对一'
852 }通知消息失败😞\n`,
853 err,
854 );
855 } else {
856 if (data.code === 200) {
857 console.log(
858 `pushplus 发送${PUSH_PLUS_USER ? '一对多' : '一对一'
859 }通知请求成功🎉,可根据流水号查询推送结果:${data.data
860 }\n注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果`,
861 );
862 } else {
863 console.log(
864 `pushplus 发送${PUSH_PLUS_USER ? '一对多' : '一对一'
865 }通知消息异常 ${data.msg}\n`,
866 );
867 }
868 }
869 } catch (e) {
870 $.logErr(e, resp);
871 } finally {
872 resolve(data);

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected