MCPcopy Create free account
hub / github.com/6dylan6/jdpro / qywxamNotify

Function qywxamNotify

function/sendNotify.js:1556–1665  ·  view source on GitHub ↗
(text, desp, strsummary = "")

Source from the content-addressed store, hash-verified

1554}
1555
1556function qywxamNotify(text, desp, strsummary = "") {
1557 return new Promise((resolve) => {
1558 if (QYWX_AM) {
1559 const QYWX_AM_AY = QYWX_AM.split(',');
1560 const options_accesstoken = {
1561 url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`,
1562 json: {
1563 corpid: `${QYWX_AM_AY[0]}`,
1564 corpsecret: `${QYWX_AM_AY[1]}`,
1565 },
1566 headers: {
1567 'Content-Type': 'application/json',
1568 },
1569 timeout,
1570 };
1571 $.post(options_accesstoken, (err, resp, data) => {
1572 html = desp.replace(/\n/g, '<br/>');
1573 html = `<font size="3">${html}</font>`;
1574 if (strsummary == "") {
1575 strsummary = desp;
1576 }
1577 var json = JSON.parse(data);
1578 accesstoken = json.access_token;
1579 let options;
1580
1581 switch (QYWX_AM_AY[4]) {
1582 case '0':
1583 options = {
1584 msgtype: 'textcard',
1585 textcard: {
1586 title: `${text}`,
1587 description: `${strsummary}`,
1588 url: 'https://github.com/whyour/qinglong',
1589 btntxt: '更多',
1590 },
1591 };
1592 break;
1593
1594 case '1':
1595 options = {
1596 msgtype: 'text',
1597 text: {
1598 content: `${text}\n\n${desp}`,
1599 },
1600 };
1601 break;
1602
1603 default:
1604 options = {
1605 msgtype: 'mpnews',
1606 mpnews: {
1607 articles: [{
1608 title: `${text}`,
1609 thumb_media_id: `${QYWX_AM_AY[4]}`,
1610 author: `智能助手`,
1611 content_source_url: ``,
1612 content: `${html}`,
1613 digest: `${strsummary}`,

Callers 1

sendNotifyFunction · 0.70

Calls 4

ChangeUserIdFunction · 0.70
postMethod · 0.45
logMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected