(text, desp)
| 2452 | } |
| 2453 | |
| 2454 | function pushPlusNotify(text, desp) { |
| 2455 | return new Promise((resolve) => { |
| 2456 | if (PUSH_PLUS_TOKEN) { |
| 2457 | |
| 2458 | //desp = `<font size="3">${desp}</font>`; |
| 2459 | |
| 2460 | desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext |
| 2461 | const body = { |
| 2462 | token: `${PUSH_PLUS_TOKEN}`, |
| 2463 | title: `${text}`, |
| 2464 | content: `${desp}`, |
| 2465 | topic: `${PUSH_PLUS_USER}`, |
| 2466 | }; |
| 2467 | const options = { |
| 2468 | url: `https://www.pushplus.plus/send`, |
| 2469 | body: JSON.stringify(body), |
| 2470 | headers: { |
| 2471 | 'Content-Type': ' application/json', |
| 2472 | }, |
| 2473 | timeout, |
| 2474 | }; |
| 2475 | $.post(options, (err, resp, data) => { |
| 2476 | try { |
| 2477 | if (err) { |
| 2478 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`); |
| 2479 | PushErrorTime += 1; |
| 2480 | console.log(err); |
| 2481 | } else { |
| 2482 | data = JSON.parse(data); |
| 2483 | if (data.code === 200) { |
| 2484 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`); |
| 2485 | PushErrorTime = 0; |
| 2486 | } else { |
| 2487 | console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`); |
| 2488 | PushErrorTime += 1; |
| 2489 | } |
| 2490 | } |
| 2491 | } catch (e) { |
| 2492 | $.logErr(e, resp); |
| 2493 | } |
| 2494 | finally { |
| 2495 | resolve(data); |
| 2496 | } |
| 2497 | }); |
| 2498 | } else { |
| 2499 | resolve(); |
| 2500 | } |
| 2501 | }); |
| 2502 | } |
| 2503 | function wxpusherNotifyByOne(text, desp, strsummary = "") { |
| 2504 | return new Promise((resolve) => { |
| 2505 | if (WP_APP_TOKEN_ONE) { |
no test coverage detected