(text, desp)
| 2175 | } |
| 2176 | |
| 2177 | function qywxBotNotify(text, desp) { |
| 2178 | return new Promise((resolve) => { |
| 2179 | const options = { |
| 2180 | url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, |
| 2181 | json: { |
| 2182 | msgtype: 'text', |
| 2183 | text: { |
| 2184 | content: ` ${text}\n\n${desp}`, |
| 2185 | }, |
| 2186 | }, |
| 2187 | headers: { |
| 2188 | 'Content-Type': 'application/json', |
| 2189 | }, |
| 2190 | timeout, |
| 2191 | }; |
| 2192 | if (QYWX_KEY) { |
| 2193 | $.post(options, (err, resp, data) => { |
| 2194 | try { |
| 2195 | if (err) { |
| 2196 | console.log('企业微信发送通知消息失败!!\n'); |
| 2197 | console.log(err); |
| 2198 | } else { |
| 2199 | data = JSON.parse(data); |
| 2200 | if (data.errcode === 0) { |
| 2201 | console.log('企业微信发送通知消息成功🎉。\n'); |
| 2202 | } else { |
| 2203 | console.log(`${data.errmsg}\n`); |
| 2204 | } |
| 2205 | } |
| 2206 | } catch (e) { |
| 2207 | $.logErr(e, resp); |
| 2208 | } |
| 2209 | finally { |
| 2210 | resolve(data); |
| 2211 | } |
| 2212 | }); |
| 2213 | } else { |
| 2214 | resolve(); |
| 2215 | } |
| 2216 | }); |
| 2217 | } |
| 2218 | |
| 2219 | function buildLastDesp(desp, author = '') { |
| 2220 | author = process.env.NOTIFY_AUTHOR || author; |
no test coverage detected