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

Function pushPlusNotifyhxtrip

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

Source from the content-addressed store, hash-verified

2404 });
2405}
2406function pushPlusNotifyhxtrip(text, desp) {
2407 return new Promise((resolve) => {
2408 if (PUSH_PLUS_TOKEN_hxtrip) {
2409 //desp = `<font size="3">${desp}</font>`;
2410
2411 desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
2412 const body = {
2413 token: `${PUSH_PLUS_TOKEN_hxtrip}`,
2414 title: `${text}`,
2415 content: `${desp}`,
2416 topic: `${PUSH_PLUS_USER_hxtrip}`,
2417 };
2418 const options = {
2419 url: `http://pushplus.hxtrip.com/send`,
2420 body: JSON.stringify(body),
2421 headers: {
2422 'Content-Type': ' application/json',
2423 },
2424 timeout,
2425 };
2426 $.post(options, (err, resp, data) => {
2427 try {
2428 if (err) {
2429 console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息失败!!\n`);
2430 PushErrorTime += 1;
2431 console.log(err);
2432 } else {
2433 if (data.indexOf("200") > -1) {
2434 console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息完成。\n`);
2435 PushErrorTime = 0;
2436 } else {
2437 console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息失败:${data}\n`);
2438 PushErrorTime += 1;
2439 }
2440 }
2441 } catch (e) {
2442 $.logErr(e, resp);
2443 }
2444 finally {
2445 resolve(data);
2446 }
2447 });
2448 } else {
2449 resolve();
2450 }
2451 });
2452}
2453
2454function pushPlusNotify(text, desp) {
2455 return new Promise((resolve) => {

Callers 1

sendNotifyFunction · 0.85

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected