From 87bf0721790b3604015b9a40f8a5b1a36c67d8a8 Mon Sep 17 00:00:00 2001 From: snowy Date: Fri, 13 Oct 2023 13:49:46 +0800 Subject: [PATCH] Update --- r.txt | 3 +- .../liteyuki_plugin_weather/api/__init__.py | 0 .../liteyuki_plugin_weather/api/geo.py | 40 +++++++++++++++++++ .../liteyuki_plugin_weather/api/weather.py | 29 ++++++++++++++ .../liteyuki_plugin_weather/qweather.py | 0 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/builtin/liteyuki_plugin_weather/api/__init__.py create mode 100644 src/builtin/liteyuki_plugin_weather/api/geo.py create mode 100644 src/builtin/liteyuki_plugin_weather/api/weather.py create mode 100644 src/builtin/liteyuki_plugin_weather/qweather.py diff --git a/r.txt b/r.txt index 132ebdd8..6d137a95 100644 --- a/r.txt +++ b/r.txt @@ -1,2 +1,3 @@ nonebot-adapter-onebot==2.3.0 -nonebot2==2.1.1 \ No newline at end of file +nonebot2==2.1.1 +pydantic==2.4.2 \ No newline at end of file diff --git a/src/builtin/liteyuki_plugin_weather/api/__init__.py b/src/builtin/liteyuki_plugin_weather/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/builtin/liteyuki_plugin_weather/api/geo.py b/src/builtin/liteyuki_plugin_weather/api/geo.py new file mode 100644 index 00000000..7f951ea0 --- /dev/null +++ b/src/builtin/liteyuki_plugin_weather/api/geo.py @@ -0,0 +1,40 @@ +from typing import List, Dict + +from pydantic import BaseModel + + +class Location(BaseModel): + name: str + id: str + lat: str + lon: str + adm2: str + adm1: str + country: str + tz: str + utcOffset: str + isDst: str + type: str + rank: str + fxLink: str + + +class CityLookup(BaseModel): + code: str + location: List['Location'] = list() + refer: Dict[str, List[str,]] = {'sources': None, 'license': None} + + +class CityTop(BaseModel): + code: str + topCityList: List['Location'] = list() + refer: Dict[str, List[str,]] = {'sources': None, 'license': None} + + +class PoiLookup(BaseModel): + code: str + poi: List['Location'] = list() + refer: Dict[str, List[str,]] = {'sources': None, 'license': None} + + +PoiRange = PoiLookup diff --git a/src/builtin/liteyuki_plugin_weather/api/weather.py b/src/builtin/liteyuki_plugin_weather/api/weather.py new file mode 100644 index 00000000..597242af --- /dev/null +++ b/src/builtin/liteyuki_plugin_weather/api/weather.py @@ -0,0 +1,29 @@ +from typing import Dict, List + +from pydantic import BaseModel + + +class Now(BaseModel): + obsTime: str + temp: str + feelsLike: str + icon: str + text: str + wind360: str + windDir: str + windScale: str + windSpeed: str + humidity: str + precip: str + pressure: str + vis: str + cloud: str = None + dew: str = None + refer: Dict[str, List[str,]] = {'sources': None, 'license': None} + + +class WeatherNow(BaseModel): + code: str + updateTime: str + fxLink: str + now: 'NOW' diff --git a/src/builtin/liteyuki_plugin_weather/qweather.py b/src/builtin/liteyuki_plugin_weather/qweather.py new file mode 100644 index 00000000..e69de29b