mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
更新天气api
This commit is contained in:
parent
a41e62cefe
commit
d39dfbe62f
@ -296,6 +296,10 @@ PS: **ARM平台** 请使用全量版 同时 **如果你的机器 RAM < 1G 可能
|
|||||||
|
|
||||||
## 更新
|
## 更新
|
||||||
|
|
||||||
|
### 2022/11/13
|
||||||
|
|
||||||
|
* 更新天气api
|
||||||
|
|
||||||
### 2022/11/12
|
### 2022/11/12
|
||||||
|
|
||||||
* 更新yiqing插件数据显示 [@pull/1168](https://github.com/HibiKier/zhenxun_bot/pull/1168)
|
* 更新yiqing插件数据显示 [@pull/1168](https://github.com/HibiKier/zhenxun_bot/pull/1168)
|
||||||
|
|||||||
@ -25,27 +25,22 @@ async def get_weather_of_city(city: str) -> str:
|
|||||||
elif code == 998:
|
elif code == 998:
|
||||||
return f"{NICKNAME}没查到!!试试查火星的天气?"
|
return f"{NICKNAME}没查到!!试试查火星的天气?"
|
||||||
else:
|
else:
|
||||||
data_json = json.loads(
|
data_json = (
|
||||||
(
|
await AsyncHttpx.get(
|
||||||
await AsyncHttpx.get(
|
f"https://v0.yiketianqi.com/api?unescape=1&version=v91&appid=43656176&appsecret=I42og6Lm&ext=&cityid=&city={city[:-1]}"
|
||||||
f"http://wthrcdn.etouch.cn/weather_mini?city={city}"
|
)
|
||||||
)
|
).json()
|
||||||
).text
|
if wh := data_json.get('data'):
|
||||||
)
|
w_type = wh[0]["wea_day"]
|
||||||
if "desc" in data_json:
|
w_max = wh[0]["tem1"]
|
||||||
if data_json["desc"] == "invilad-citykey":
|
w_min = wh[0]["tem2"]
|
||||||
return f"{NICKNAME}没查到!!试试查火星的天气?" + image("shengqi", "zhenxun")
|
fengli = wh[0]["win_speed"]
|
||||||
elif data_json["desc"] == "OK":
|
ganmao = wh[0]["narrative"]
|
||||||
w_type = data_json["data"]["forecast"][0]["type"]
|
fengxiang = ','.join(wh[0].get('win', []))
|
||||||
w_max = data_json["data"]["forecast"][0]["high"][3:]
|
repass = f"{city}的天气是 {w_type} 天\n最高温度: {w_max}\n最低温度: {w_min}\n风力: {fengli} {fengxiang}\n{ganmao}"
|
||||||
w_min = data_json["data"]["forecast"][0]["low"][3:]
|
return repass
|
||||||
fengli = data_json["data"]["forecast"][0]["fengli"][9:-3]
|
|
||||||
ganmao = data_json["data"]["ganmao"]
|
|
||||||
fengxiang = data_json["data"]["forecast"][0]["fengxiang"]
|
|
||||||
repass = f"{city}的天气是 {w_type} 天\n最高温度: {w_max}\n最低温度: {w_min}\n风力: {fengli} {fengxiang}\n{ganmao}"
|
|
||||||
return repass
|
|
||||||
else:
|
else:
|
||||||
return "好像出错了?再试试?"
|
return data_json.get("errmsg") or "好像出错了?再试试?"
|
||||||
|
|
||||||
|
|
||||||
def _check_exists_city(city: str) -> int:
|
def _check_exists_city(city: str) -> int:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user