t-comm
Version:
专业、稳定、纯粹的工具库
100 lines (97 loc) • 3.38 kB
JavaScript
import _regeneratorRuntime from '@babel/runtime/regenerator';
import { _ as __awaiter } from '../tslib.es6-848120af.js';
import { timeStampFormat } from '../time/time.mjs';
import { batchSendWxRobotMarkdown } from '../wecom-robot/batch-send.mjs';
import { getOpenSourceReport } from './api.mjs';
import { parseOpenSourceReport } from './parse.mjs';
import '../wecom-robot/base.mjs';
import '../wecom-robot/helper.mjs';
import 'axios';
import '../wecom-robot/send-img.mjs';
import '../node-img/img.mjs';
import '../nodejs/crypto.mjs';
import '../nodejs/fs.mjs';
import '../nodejs/request.mjs';
import '../nodejs/path.mjs';
import '@babel/runtime/helpers/toConsumableArray';
var MAX_SHOW_LINK_NAME = 12;
/**
* 请求开源治理数据并发送
* @param options 配置信息
* @example
* ```ts
* await sendOpenSourceReport({
* date: '2024-01-01',
* chatId: 'xxx',
* webhookUrl: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx',
* requestInfo: { ... },
* searchInfo: { ... },
* maxShowLinkNum: 12,
* whiteList: ['some-repo'],
* filterOrgPath: 'group/sub-group',
* });
* ```
*/
function sendOpenSourceReport(_ref) {
var date = _ref.date,
chatId = _ref.chatId,
webhookUrl = _ref.webhookUrl,
requestInfo = _ref.requestInfo,
searchInfo = _ref.searchInfo,
_ref$maxShowLinkNum = _ref.maxShowLinkNum,
maxShowLinkNum = _ref$maxShowLinkNum === void 0 ? MAX_SHOW_LINK_NAME : _ref$maxShowLinkNum,
_ref$whiteList = _ref.whiteList,
whiteList = _ref$whiteList === void 0 ? [] : _ref$whiteList,
_ref$filterOrgPath = _ref.filterOrgPath,
filterOrgPath = _ref$filterOrgPath === void 0 ? '' : _ref$filterOrgPath;
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var time, formattedDate, reportArr, chatContent, _t;
return _regeneratorRuntime.wrap(function (_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
time = timeStampFormat(new Date(date).getTime(), 'yyyyMMdd');
formattedDate = timeStampFormat(new Date(date).getTime(), 'yyyy-MM-dd');
_context.next = 1;
return getOpenSourceReport(Object.assign({
time: time
}, requestInfo || {}));
case 1:
reportArr = _context.sent;
chatContent = parseOpenSourceReport({
reportArr: reportArr,
date: time,
formattedDate: formattedDate,
requestInfo: requestInfo,
searchInfo: searchInfo,
maxShowLinkNum: maxShowLinkNum,
whiteList: whiteList,
filterOrgPath: filterOrgPath
});
if (chatContent) {
_context.next = 2;
break;
}
return _context.abrupt("return");
case 2:
_context.prev = 2;
_context.next = 3;
return batchSendWxRobotMarkdown({
chatId: chatId,
content: chatContent,
webhookUrl: webhookUrl
});
case 3:
_context.next = 5;
break;
case 4:
_context.prev = 4;
_t = _context["catch"](2);
console.log('[sendOpenSourceReport] err', _t);
case 5:
case "end":
return _context.stop();
}
}, _callee, null, [[2, 4]]);
}));
}
export { sendOpenSourceReport };