(text, desp)
| 2596 | } |
| 2597 | |
| 2598 | function 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 | |
| 2654 | function PushDeerNotify(text, desp, time = 2100) { |
| 2655 | return new Promise((resolve) => { |
no test coverage detected