UNPKG

t-comm

Version:

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

136 lines (133 loc) 4.45 kB
import _regeneratorRuntime from '@babel/runtime/regenerator'; import { _ as __awaiter } from '../tslib.es6-848120af.js'; import { fetchLatestRainbowData } from './api.mjs'; import { SendToRobotTypeMap } from './config.mjs'; import { sendRainbowInfoToRobot } from './robot-msg.mjs'; import { syncRainbowToCOS } from './sync-to-cos.mjs'; import '../fs/fs-util.mjs'; import '@babel/runtime/helpers/toConsumableArray'; import '../fs/fs.mjs'; import '../nodejs/crypto.mjs'; import '../nodejs/fs.mjs'; import '../nodejs/os.mjs'; import '../nodejs/path.mjs'; import '../time/time.mjs'; import '../rainbow/rainbow-admin.mjs'; import '../rainbow/helper/helper.mjs'; import '../rainbow/helper/rainbow-base-request.mjs'; import 'axios'; import '../rainbow/helper/rainbow-signature.mjs'; import '../rainbow/rainbow-user.mjs'; import '../list/flat.mjs'; import '@babel/runtime/helpers/typeof'; import '../rainbow/sdk.mjs'; import '../json/json-parse.mjs'; import './helper/helper.mjs'; import '../string/string.mjs'; import '../tencent-cloud/cos/link.mjs'; import './helper/value-type.mjs'; import '../wecom-robot/batch-send.mjs'; import '../wecom-robot/base.mjs'; import '../wecom-robot/helper.mjs'; import '../wecom-robot/send-img.mjs'; import '../node-img/img.mjs'; import '../nodejs/request.mjs'; import '../tencent-cloud/cos/cos.mjs'; import '../tencent-cloud/cos/helper.mjs'; import '../bite/format-bite.mjs'; import '../third-party/cos-nodejs-sdk-v5.mjs'; /** * 监听rainbow,同步到cos,并发送到机器人 * @param {object} options 配置 * @param {object} options.rainbowSecretInfo 七彩石密钥信息 * @param {object} options.cosInfo 腾讯云信息 * @param {string} options.appName 七彩石项目名称 * * @param {string} options.webhookUrl 机器人回调 * @param {string} options.chatId 会话id * @param {0|1|2} options.sendToRobotType 发送机器人类型,0 不发送,1 发送变化的部分,2 全部发送 * * @example * * await watchRainbowToCosAndSendRobot({ * rainbowSecretInfo: { * appID: RAINBOW_OPEN_APP_ID, * userID: RAINBOW_OPEN_YGW_USER_ID, * secretKey: RAINBOW_OPEN_YGW_SECRET_KEY, * envName: 'Default', * groupName: 'group', * }, * appName: 'configApp', * cosInfo: { * secretId, * secretKey, * bucket: 'bucket', * region: 'ap-guangzhou', * dir: 'rb', * }, * webhookUrl: 'xxx', * chatId: 'xxx', * sendToRobotType: 1, * }); * */ function watchRainbowToCosAndSendRobot(_ref) { var secretInfo = _ref.rainbowSecretInfo, cosInfo = _ref.cosInfo, appName = _ref.appName, webhookUrl = _ref.webhookUrl, chatId = _ref.chatId, _ref$sendToRobotType = _ref.sendToRobotType, sendToRobotType = _ref$sendToRobotType === void 0 ? SendToRobotTypeMap.NO_SEND : _ref$sendToRobotType; return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var _yield$fetchLatestRai, config, originConfig, equal; return _regeneratorRuntime.wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 1; return fetchLatestRainbowData({ secretInfo: secretInfo, appName: appName }); case 1: _yield$fetchLatestRai = _context.sent; config = _yield$fetchLatestRai.config; originConfig = _yield$fetchLatestRai.originConfig; equal = _yield$fetchLatestRai.equal; if (equal) { _context.next = 2; break; } _context.next = 2; return syncRainbowToCOS({ configList: config, secretInfo: secretInfo, appName: appName, cosInfo: cosInfo }); case 2: if (sendToRobotType) { _context.next = 3; break; } return _context.abrupt("return"); case 3: _context.next = 4; return sendRainbowInfoToRobot({ newConfig: config, originConfig: originConfig, secretInfo: secretInfo, cosInfo: cosInfo, appName: appName, webhookUrl: webhookUrl, chatId: chatId, isGenAll: sendToRobotType === 2 }); case 4: case "end": return _context.stop(); } }, _callee); })); } export { watchRainbowToCosAndSendRobot };