UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

74 lines (71 loc) 2.46 kB
import { b as __awaiter, c as __generator, _ as __assign } from '../tslib.es6-48fa7a9b.js'; import { getOpenSourceReport } from './api.js'; import { parseOpenSourceReport } from './parse.js'; import { timeStampFormat } from '../time/time.js'; import { batchSendWxRobotMarkdown } from '../wecom-robot/batch-send.js'; import '../wecom-robot/send-img.js'; import '../wecom-robot/base.js'; import '../wecom-robot/helper.js'; import '../node-img/img.js'; var MAX_SHOW_LINK_NAME = 12; /** * 请求开源治理数据并发送 * @param options 配置信息 */ function sendOpenSourceReport(_a) { var date = _a.date, chatId = _a.chatId, webhookUrl = _a.webhookUrl, requestInfo = _a.requestInfo, searchInfo = _a.searchInfo, _b = _a.maxShowLinkNum, maxShowLinkNum = _b === void 0 ? MAX_SHOW_LINK_NAME : _b, _c = _a.whiteList, whiteList = _c === void 0 ? [] : _c, _d = _a.filterOrgPath, filterOrgPath = _d === void 0 ? '' : _d; return __awaiter(this, void 0, void 0, function () { var time, formattedDate, reportArr, chatContent, err_1; return __generator(this, function (_e) { switch (_e.label) { case 0: time = timeStampFormat(new Date(date).getTime(), 'yyyyMMdd'); formattedDate = timeStampFormat(new Date(date).getTime(), 'yyyy-MM-dd'); return [4 /*yield*/, getOpenSourceReport(__assign({ time: time }, requestInfo || {}))]; case 1: reportArr = _e.sent(); chatContent = parseOpenSourceReport({ reportArr: reportArr, date: time, formattedDate: formattedDate, requestInfo: requestInfo, searchInfo: searchInfo, maxShowLinkNum: maxShowLinkNum, whiteList: whiteList, filterOrgPath: filterOrgPath }); if (!chatContent) return [2 /*return*/]; _e.label = 2; case 2: _e.trys.push([2, 4,, 5]); return [4 /*yield*/, batchSendWxRobotMarkdown({ chatId: chatId, content: chatContent, webhookUrl: webhookUrl })]; case 3: _e.sent(); return [3 /*break*/, 5]; case 4: err_1 = _e.sent(); console.log('[sendOpenSourceReport] err', err_1); return [3 /*break*/, 5]; case 5: return [2 /*return*/]; } }); }); } export { sendOpenSourceReport };