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

Function qywxBotNotify

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

Source from the content-addressed store, hash-verified

2175}
2176
2177function 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
2219function buildLastDesp(desp, author = '') {
2220 author = process.env.NOTIFY_AUTHOR || author;

Callers 1

sendNotifyFunction · 0.70

Calls 3

postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected