(text, desp)
| 323 | } |
| 324 | |
| 325 | function pushDeerNotify(text, desp) { |
| 326 | return new Promise((resolve) => { |
| 327 | const { DEER_KEY, DEER_URL } = push_config; |
| 328 | if (DEER_KEY) { |
| 329 | // PushDeer 建议对消息内容进行 urlencode |
| 330 | desp = encodeURI(desp); |
| 331 | const options = { |
| 332 | url: DEER_URL || `https://api2.pushdeer.com/message/push`, |
| 333 | body: `pushkey=${DEER_KEY}&text=${text}&desp=${desp}&type=markdown`, |
| 334 | headers: { |
| 335 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 336 | }, |
| 337 | timeout, |
| 338 | }; |
| 339 | $.post(options, (err, resp, data) => { |
| 340 | try { |
| 341 | if (err) { |
| 342 | console.log('PushDeer 通知调用API失败😞\n', err); |
| 343 | } else { |
| 344 | // 通过返回的result的长度来判断是否成功 |
| 345 | if ( |
| 346 | data.content.result.length !== undefined && |
| 347 | data.content.result.length > 0 |
| 348 | ) { |
| 349 | console.log('PushDeer 发送通知消息成功🎉\n'); |
| 350 | } else { |
| 351 | console.log( |
| 352 | `PushDeer 发送通知消息异常😞 ${JSON.stringify(data)}`, |
| 353 | ); |
| 354 | } |
| 355 | } |
| 356 | } catch (e) { |
| 357 | $.logErr(e, resp); |
| 358 | } finally { |
| 359 | resolve(data); |
| 360 | } |
| 361 | }); |
| 362 | } else { |
| 363 | resolve(); |
| 364 | } |
| 365 | }); |
| 366 | } |
| 367 | |
| 368 | function chatNotify(text, desp) { |
| 369 | return new Promise((resolve) => { |
no test coverage detected