t-comm
Version:
专业、稳定、纯粹的工具库
124 lines (119 loc) • 3.97 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib_es6 = require('../tslib.es6-01322ba9.js');
var rainbowToCos_api = require('./api.js');
var rainbowToCos_config = require('./config.js');
var rainbowToCos_robotMsg = require('./robot-msg.js');
var rainbowToCos_syncToCos = require('./sync-to-cos.js');
require('../node/fs-util.js');
require('fs');
require('path');
require('../fs/fs.js');
require('../time/time.js');
require('../rainbow/rainbow-admin.js');
require('../rainbow/helper/helper.js');
require('../rainbow/helper/rainbow-base-request.js');
require('axios');
require('../rainbow/helper/rainbow-signature.js');
require('../rainbow/rainbow-user.js');
require('../rainbow/sdk.js');
require('../json/json-parse.js');
require('../list/flat.js');
require('./helper/helper.js');
require('../tencent-cloud/cos/link.js');
require('./helper/value-type.js');
require('../string/string.js');
require('../wecom-robot/batch-send.js');
require('../wecom-robot/base.js');
require('../wecom-robot/helper.js');
require('../wecom-robot/send-img.js');
require('../node-img/img.js');
require('../tencent-cloud/cos/cos.js');
require('../tencent-cloud/cos/helper.js');
require('../bite/format-bite.js');
/**
* 监听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 ? rainbowToCos_config.SendToRobotTypeMap.NO_SEND : _b;
return tslib_es6.__awaiter(this, void 0, void 0, function () {
var _c, config, originConfig, equal;
return tslib_es6.__generator(this, function (_d) {
switch (_d.label) {
case 0:
return [4 /*yield*/, rainbowToCos_api.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*/, rainbowToCos_syncToCos.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*/, rainbowToCos_robotMsg.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*/];
}
});
});
}
exports.watchRainbowToCosAndSendRobot = watchRainbowToCosAndSendRobot;