天气查询

This commit is contained in:
liuwei
2025-12-29 15:47:30 +08:00
parent 0c98be8c6f
commit d1694b566e

View File

@@ -522,13 +522,13 @@ class WeatherPlugin(MessagePluginInterface):
# 获取实时天气
conn = aiohttp.TCPConnector(ssl=False)
now_url = f'{self.api_domain}/v7/weather/now?key={self.api_key}&location={city_id}'
async with aiohttp.request('GET', now_url, connector=conn,timeout=20) as resp:
async with aiohttp.request('GET', now_url, connector=conn) as resp:
now_json = await resp.json()
# 获取预报
conn = aiohttp.TCPConnector(ssl=False)
daily_url = f'{self.api_domain}/v7/weather/7d?key={self.api_key}&location={city_id}'
async with aiohttp.request('GET', daily_url, connector=conn,timeout=20) as resp:
async with aiohttp.request('GET', daily_url, connector=conn) as resp:
daily_json = await resp.json()
if now_json.get('code') != '200' or daily_json.get('code') != '200':