(text, desp)
| 883 | } |
| 884 | |
| 885 | function wePlusBotNotify(text, desp) { |
| 886 | return new Promise((resolve) => { |
| 887 | const { WE_PLUS_BOT_TOKEN, WE_PLUS_BOT_RECEIVER, WE_PLUS_BOT_VERSION } = |
| 888 | push_config; |
| 889 | if (WE_PLUS_BOT_TOKEN) { |
| 890 | let template = 'txt'; |
| 891 | if (desp.length > 800) { |
| 892 | desp = desp.replace(/[\n\r]/g, '<br>'); |
| 893 | template = 'html'; |
| 894 | } |
| 895 | const body = { |
| 896 | token: `${WE_PLUS_BOT_TOKEN}`, |
| 897 | title: `${text}`, |
| 898 | content: `${desp}`, |
| 899 | template: `${template}`, |
| 900 | receiver: `${WE_PLUS_BOT_RECEIVER}`, |
| 901 | version: `${WE_PLUS_BOT_VERSION}`, |
| 902 | }; |
| 903 | const options = { |
| 904 | url: `https://www.weplusbot.com/send`, |
| 905 | body: JSON.stringify(body), |
| 906 | headers: { |
| 907 | 'Content-Type': ' application/json', |
| 908 | }, |
| 909 | timeout, |
| 910 | }; |
| 911 | $.post(options, (err, resp, data) => { |
| 912 | try { |
| 913 | if (err) { |
| 914 | console.log(`微加机器人发送通知消息失败😞\n`, err); |
| 915 | } else { |
| 916 | if (data.code === 200) { |
| 917 | console.log(`微加机器人发送通知消息完成🎉\n`); |
| 918 | } else { |
| 919 | console.log(`微加机器人发送通知消息异常 ${data.msg}\n`); |
| 920 | } |
| 921 | } |
| 922 | } catch (e) { |
| 923 | $.logErr(e, resp); |
| 924 | } finally { |
| 925 | resolve(data); |
| 926 | } |
| 927 | }); |
| 928 | } else { |
| 929 | resolve(); |
| 930 | } |
| 931 | }); |
| 932 | } |
| 933 | |
| 934 | function aibotkNotify(text, desp) { |
| 935 | return new Promise((resolve) => { |
no test coverage detected