UNPKG

t-comm

Version:

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

112 lines (109 loc) 3.77 kB
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.js'; import { batchSendWxRobotMarkdown } from '../wecom-robot/batch-send.js'; import { getHistoryModeConfigDiff } from './api.js'; import '../wecom-robot/base.js'; import '../wecom-robot/helper.js'; import 'axios'; import '../wecom-robot/send-img.js'; import '../node-img/img.js'; import '../rainbow-to-cos/api.js'; import '../node/fs-util.js'; import 'fs'; import 'path'; import '../fs/fs.js'; import '../time/time.js'; import '../rainbow/rainbow-admin.js'; import '../rainbow/helper/helper.js'; import '../rainbow/helper/rainbow-base-request.js'; import '../rainbow/helper/rainbow-signature.js'; import '../rainbow/rainbow-user.js'; import '../list/flat.js'; import '@babel/runtime/helpers/typeof'; import '../rainbow/sdk.js'; import '../json/json-parse.js'; import '../rainbow-to-cos/helper/helper.js'; import '../string/string.js'; import '../tencent-cloud/cos/link.js'; import '../rainbow-to-cos/helper/value-type.js'; function getHistoryModeConfigDiffAndSendRobot(_a) { var secretInfo = _a.secretInfo, appName = _a.appName, key = _a.key, chatId = _a.chatId, webhookUrl = _a.webhookUrl, mentions = _a.mentions; return __awaiter(this, void 0, void 0, function () { var res, equal, addedMap, deletedMap, message; return __generator(this, function (_b) { switch (_b.label) { case 0: return [4 /*yield*/, getHistoryModeConfigDiff({ secretInfo: secretInfo, appName: appName, key: key })]; case 1: res = _b.sent(); equal = res.equal, addedMap = res.addedMap, deletedMap = res.deletedMap; if (equal) { return [2 /*return*/, { message: '', equal: equal, addedMap: addedMap, deletedMap: deletedMap }]; } message = genMessage({ addedMap: addedMap, deletedMap: deletedMap, mentions: mentions }); try { if (chatId && webhookUrl) { batchSendWxRobotMarkdown({ chatId: chatId, content: message, webhookUrl: webhookUrl }); } } catch (err) { console.log('[sendRainbowInfoToRobot] err: \n', err); } return [2 /*return*/, { message: message, equal: equal, addedMap: addedMap, deletedMap: deletedMap }]; } }); }); } function genMessage(_a) { var _b; var addedMap = _a.addedMap, deletedMap = _a.deletedMap, mentions = _a.mentions; var mentionStr = ((_b = mentions === null || mentions === void 0 ? void 0 : mentions.map(function (item) { return "<@".concat(item, ">"); })) === null || _b === void 0 ? void 0 : _b.join('')) || ''; var result = ["> \u26A0\uFE0F \u3010History \u6A21\u5F0F\u9519\u8BEF\u66F4\u65B0\u53EF\u80FD\u5BFC\u81F4\u6240\u6709\u9879\u76EE\u767D\u5C4F\uFF0C\u8BF7\u5173\u6CE8\u53D8\u66F4\u5E76\u4E8C\u6B21\u786E\u8BA4\u3011".concat(mentionStr)]; Object.keys(addedMap).forEach(function (domain) { var list = addedMap[domain].map(function (item) { return "`".concat(item, "`"); }); if (list.length) { result.push("- ".concat(domain, " \u65B0\u589E: ").concat(list.join('、'))); } }); Object.keys(deletedMap).forEach(function (domain) { var list = deletedMap[domain].map(function (item) { return "`".concat(item, "`"); }); if (list.length) { result.push("- ".concat(domain, " \u5220\u9664: ").concat(list.join('、'))); } }); return result.join('\n'); } export { getHistoryModeConfigDiffAndSendRobot };