t-comm
Version:
专业、稳定、纯粹的工具库
121 lines (118 loc) • 3.8 kB
JavaScript
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.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 '../node/fs-util.mjs';
import 'fs';
import 'path';
import '../fs/fs.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 '../tencent-cloud/cos/cos.mjs';
import '../tencent-cloud/cos/helper.mjs';
import '../bite/format-bite.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(_a) {
var secretInfo = _a.rainbowSecretInfo,
cosInfo = _a.cosInfo,
appName = _a.appName,
webhookUrl = _a.webhookUrl,
chatId = _a.chatId,
_b = _a.sendToRobotType,
sendToRobotType = _b === void 0 ? SendToRobotTypeMap.NO_SEND : _b;
return __awaiter(this, void 0, void 0, function () {
var _c, config, originConfig, equal;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
return [4 /*yield*/, fetchLatestRainbowData({
secretInfo: secretInfo,
appName: appName
})];
case 1:
_c = _d.sent(), config = _c.config, originConfig = _c.originConfig, equal = _c.equal;
if (!!equal) return [3 /*break*/, 3];
return [4 /*yield*/, syncRainbowToCOS({
configList: config,
secretInfo: secretInfo,
appName: appName,
cosInfo: cosInfo
})];
case 2:
_d.sent();
_d.label = 3;
case 3:
if (!sendToRobotType) {
return [2 /*return*/];
}
return [4 /*yield*/, sendRainbowInfoToRobot({
newConfig: config,
originConfig: originConfig,
secretInfo: secretInfo,
cosInfo: cosInfo,
appName: appName,
webhookUrl: webhookUrl,
chatId: chatId,
isGenAll: sendToRobotType === 2
})];
case 4:
_d.sent();
return [2 /*return*/];
}
});
});
}
export { watchRainbowToCosAndSendRobot };