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

Function fsBotNotify

function/sendNotify.js:1482–1522  ·  view source on GitHub ↗
(text, desp)

Source from the content-addressed store, hash-verified

1480}
1481
1482function fsBotNotify(text, desp) {
1483 return new Promise((resolve) => {
1484 const options = {
1485 url: `https://open.feishu.cn/open-apis/bot/v2/hook/${FS_KEY}`,
1486 json: {
1487 msg_type: 'text',
1488 content: {
1489 text: ` ${text}\n\n${desp}`,
1490 },
1491 },
1492 headers: {
1493 'Content-Type': 'application/json',
1494 },
1495 timeout,
1496 };
1497 if (FS_KEY) {
1498 $.post(options, (err, resp, data) => {
1499 try {
1500 if (err) {
1501 console.log('飞书发送通知消息失败!!\n');
1502 console.log(err);
1503 } else {
1504 data = JSON.parse(data);
1505 if (data.errcode === 0) {
1506 console.log('飞书发送通知消息成功🎉。\n');
1507 } else {
1508 console.log(`${data.errmsg}\n`);
1509 }
1510 }
1511 } catch (e) {
1512 $.logErr(e, resp);
1513 }
1514 finally {
1515 resolve(data);
1516 }
1517 });
1518 } else {
1519 resolve();
1520 }
1521 });
1522}
1523
1524function buildLastDesp(desp, author = '') {
1525 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