t-comm
Version:
专业、稳定、纯粹的工具库
57 lines (52 loc) • 1.81 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib_es6 = require('../tslib.es6-01322ba9.js');
var wecomRobot_batchSend = require('../wecom-robot/batch-send.js');
var weather_weather = require('./weather.js');
require('../wecom-robot/base.js');
require('../wecom-robot/helper.js');
require('axios');
require('../wecom-robot/send-img.js');
require('../node-img/img.js');
require('./api.js');
require('./parse.js');
require('../node/fs-util.js');
require('fs');
require('path');
require('../fs/fs.js');
require('../time/time.js');
/**
* 获取天气信息并发送
* @param {object} options 配置
* @param {string} options.webhookUrl 机器人hook地址
* @param {string} [options.chatId] 会话Id
* @param {string} [options.force] 是否在和之前获取数据相同时,也发送
* @returns {Promise<Object>} 请求Promise
*/
function sendWeatherRobotMsg(_a) {
var webhookUrl = _a.webhookUrl,
chatId = _a.chatId,
_b = _a.force,
force = _b === void 0 ? false : _b;
return tslib_es6.__awaiter(this, void 0, void 0, function () {
var _c, content, isSame;
return tslib_es6.__generator(this, function (_d) {
switch (_d.label) {
case 0:
return [4 /*yield*/, weather_weather.getWeatherRobotContent()];
case 1:
_c = _d.sent(), content = _c.content, isSame = _c.isSame;
console.log('[sendWeatherRobotMsg] 天气是否有变化: ', !isSame);
if (!isSame || force) {
return [2 /*return*/, wecomRobot_batchSend.batchSendWxRobotMarkdown({
webhookUrl: webhookUrl,
chatId: chatId,
content: content
})];
}
return [2 /*return*/];
}
});
});
}
exports.sendWeatherRobotMsg = sendWeatherRobotMsg;