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

Function wxpusherNotify

sendNotify.js:2598–2652  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

2596}
2597
2598function wxpusherNotify(text, desp) {
2599 return new Promise((resolve) => {
2600 if (WP_APP_TOKEN) {
2601 let uids = [];
2602 for (let i of WP_UIDS.split(";")) {
2603 if (i.length != 0)
2604 uids.push(i);
2605 };
2606 let topicIds = [];
2607 for (let i of WP_TOPICIDS.split(";")) {
2608 if (i.length != 0)
2609 topicIds.push(i);
2610 };
2611 desp = `<font size="4"><b>${text}</b></font>\n\n<font size="3">${desp}</font>`;
2612 desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
2613 const body = {
2614 appToken: `${WP_APP_TOKEN}`,
2615 content: `${text}\n\n${desp}`,
2616 summary: `${text}`,
2617 contentType: 2,
2618 topicIds: topicIds,
2619 uids: uids,
2620 url: `${WP_URL}`,
2621 };
2622 const options = {
2623 url: `http://wxpusher.zjiecode.com/api/send/message`,
2624 body: JSON.stringify(body),
2625 headers: {
2626 "Content-Type": "application/json",
2627 },
2628 timeout,
2629 };
2630 $.post(options, (err, resp, data) => {
2631 try {
2632 if (err) {
2633 console.log("WxPusher 发送通知调用 API 失败!!\n");
2634 console.log(err);
2635 } else {
2636 data = JSON.parse(data);
2637 if (data.code === 1000) {
2638 console.log("WxPusher 发送通知消息成功!\n");
2639 }
2640 }
2641 } catch (e) {
2642 $.logErr(e, resp);
2643 }
2644 finally {
2645 resolve(data);
2646 }
2647 });
2648 } else {
2649 resolve();
2650 }
2651 });
2652}
2653
2654function PushDeerNotify(text, desp, time = 2100) {
2655 return new Promise((resolve) => {

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected