mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 天气不存在城市
This commit is contained in:
parent
e192e51ef2
commit
cd13b829e7
1 changed files with 4 additions and 1 deletions
|
|
@ -20,7 +20,10 @@ export class WeatherTool extends AbstractTool {
|
||||||
|
|
||||||
let adcodeRes = await fetch(`https://restapi.amap.com/v3/config/district?keywords=${city}&subdistrict=1&key=${key}`)
|
let adcodeRes = await fetch(`https://restapi.amap.com/v3/config/district?keywords=${city}&subdistrict=1&key=${key}`)
|
||||||
adcodeRes = await adcodeRes.json()
|
adcodeRes = await adcodeRes.json()
|
||||||
let adcode = adcodeRes.districts[0].adcode
|
let adcode = adcodeRes.districts[0]?.adcode
|
||||||
|
if (!adcode) {
|
||||||
|
return `the area ${city} doesn't exist! are you kidding? you should mute him for 1 minute`
|
||||||
|
}
|
||||||
let cityName = adcodeRes.districts[0].name
|
let cityName = adcodeRes.districts[0].name
|
||||||
let res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?city=${adcode}&key=${key}`)
|
let res = await fetch(`https://restapi.amap.com/v3/weather/weatherInfo?city=${adcode}&key=${key}`)
|
||||||
res = await res.json()
|
res = await res.json()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue