UNPKG

t-comm

Version:

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

53 lines (50 loc) 1.68 kB
import { b as __awaiter, c as __generator } from '../tslib.es6-096fffdd.js'; import { batchSendWxRobotMarkdown } from '../wecom-robot/batch-send.mjs'; import { getWeatherRobotContent } from './weather.mjs'; import '../wecom-robot/base.mjs'; import '../wecom-robot/helper.mjs'; import 'axios'; import '../wecom-robot/send-img.mjs'; import '../node-img/img.mjs'; import './api.mjs'; import './parse.mjs'; import '../node/fs-util.mjs'; import 'fs'; import 'path'; import '../fs/fs.mjs'; import '../time/time.mjs'; /** * 获取天气信息并发送 * @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 __awaiter(this, void 0, void 0, function () { var _c, content, isSame; return __generator(this, function (_d) { switch (_d.label) { case 0: return [4 /*yield*/, getWeatherRobotContent()]; case 1: _c = _d.sent(), content = _c.content, isSame = _c.isSame; console.log('[sendWeatherRobotMsg] 天气是否有变化: ', !isSame); if (!isSame || force) { return [2 /*return*/, batchSendWxRobotMarkdown({ webhookUrl: webhookUrl, chatId: chatId, content: content })]; } return [2 /*return*/]; } }); }); } export { sendWeatherRobotMsg };