UNPKG

t-comm

Version:

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

55 lines (52 loc) 1.65 kB
import _regeneratorRuntime from '@babel/runtime/regenerator'; import { _ as __awaiter } from '../tslib.es6-848120af.js'; import { fetchWeatherData } from './api.mjs'; import { parseWeatherData } from './parse.mjs'; import 'axios'; 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'; /** * 获取深圳天气信息,可用于通过机器人发送到群聊 * @returns {object} 天气信息和是否有变化 * @example * * getWeatherRobotContent().then(resp => { * const { content, isSame } = resp * * console.log(content) * // ## 深圳当前正在生效的预警如下 * // ... * * console.log(isSame) * // false * }) */ function getWeatherRobotContent() { return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var data, _parseWeatherData, content, isSame; return _regeneratorRuntime.wrap(function (_context) { while (1) switch (_context.prev = _context.next) { case 0: _context.next = 1; return fetchWeatherData(); case 1: data = _context.sent; _parseWeatherData = parseWeatherData(data), content = _parseWeatherData.content, isSame = _parseWeatherData.isSame; return _context.abrupt("return", { content: content, isSame: isSame }); case 2: case "end": return _context.stop(); } }, _callee); })); } export { getWeatherRobotContent };