'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _regeneratorRuntime = require('@babel/runtime/regenerator');
var tslib_es6 = require('../tslib.es6-0d92ef81.js');
var weather_api = require('./api.js');
var weather_parse = require('./parse.js');
require('axios');
require('../fs/fs-util.js');
require('@babel/runtime/helpers/toConsumableArray');
require('../fs/fs.js');
require('../nodejs/crypto.js');
require('../nodejs/fs.js');
require('../nodejs/os.js');
require('../nodejs/path.js');
require('../time/time.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);

/**
 * 获取深圳天气信息，可用于通过机器人发送到群聊
 * @returns {object} 天气信息和是否有变化
 * @example
 *
 * getWeatherRobotContent().then(resp => {
 *   const { content, isSame } = resp
 *
 *   console.log(content)
 *   // ## 深圳当前正在生效的预警如下
 *   // ...
 *
 *   console.log(isSame)
 *   // false
 * })
 */
function getWeatherRobotContent() {
  return tslib_es6.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee() {
    var data, _parseWeatherData, content, isSame;
    return _regeneratorRuntime__default["default"].wrap(function (_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _context.next = 1;
          return weather_api.fetchWeatherData();
        case 1:
          data = _context.sent;
          _parseWeatherData = weather_parse.parseWeatherData(data), content = _parseWeatherData.content, isSame = _parseWeatherData.isSame;
          return _context.abrupt("return", {
            content: content,
            isSame: isSame
          });
        case 2:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
}

exports.getWeatherRobotContent = getWeatherRobotContent;
