feat: Introduce multi-source weather data collection, including city configuration and robust caching.

This commit is contained in:
2569718930@qq.com
2026-03-12 00:29:34 +08:00
parent 9295899aeb
commit eca0c7f514
4 changed files with 101 additions and 4 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
# Telegram Bot
# Telegram Bot
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here
TELEGRAM_ALERT_PUSH_ENABLED=true
@@ -8,7 +8,7 @@ TELEGRAM_ALERT_MIN_TRIGGER_COUNT=2
TELEGRAM_ALERT_MIN_SEVERITY=medium
# Mispricing radar: skip push when YES buy price is above this cap (10c = 0.10)
TELEGRAM_ALERT_MISPRICING_MAX_YES_BUY=0.10
TELEGRAM_ALERT_CITIES=ankara,london,paris,seoul,toronto,buenos aires,wellington,new york,chicago,dallas,miami,atlanta,seattle,lucknow,sao paulo,munich
TELEGRAM_ALERT_CITIES=ankara,london,paris,seoul,hong kong,shanghai,singapore,tokyo,toronto,buenos aires,wellington,new york,chicago,dallas,miami,atlanta,seattle,lucknow,sao paulo,munich
# AI
GROQ_API_KEY=your_groq_api_key_here
+20 -1
View File
@@ -44,7 +44,26 @@ cities:
country: "Germany"
latitude: 48.3538
longitude: 11.7861
- id: "hong_kong"
city: "Hong Kong"
country: "China"
latitude: 22.3080
longitude: 113.9185
- id: "shanghai"
city: "Shanghai"
country: "China"
latitude: 31.1434
longitude: 121.8052
- id: "singapore"
city: "Singapore"
country: "Singapore"
latitude: 1.3644
longitude: 103.9915
- id: "tokyo"
city: "Tokyo"
country: "Japan"
latitude: 35.5523
longitude: 139.7798
# Logging
logging:
level: "INFO"
+65 -1
View File
@@ -58,6 +58,62 @@ CITY_REGISTRY = {
"distance_km": 48.8,
"warning": "距离太远,海洋性vs大陆性气候差异大。",
},
"hong kong": {
"name": "Hong Kong",
"lat": 22.3080,
"lon": 113.9185,
"icao": "VHHH",
"tz_offset": 28800,
"use_fahrenheit": False,
"is_major": True,
"risk_level": "medium",
"risk_emoji": "🟡",
"airport_name": "Hong Kong 国际机场",
"distance_km": 31.0,
"warning": "海风与地形共同作用,午后对流触发后温度回落可能偏快。",
},
"shanghai": {
"name": "Shanghai",
"lat": 31.1434,
"lon": 121.8052,
"icao": "ZSPD",
"tz_offset": 28800,
"use_fahrenheit": False,
"is_major": True,
"risk_level": "medium",
"risk_emoji": "🟡",
"airport_name": "浦东国际机场",
"distance_km": 33.0,
"warning": "沿海平流与城市热岛叠加,午后最高温落点易出现1-2°C偏差。",
},
"singapore": {
"name": "Singapore",
"lat": 1.3644,
"lon": 103.9915,
"icao": "WSSS",
"tz_offset": 28800,
"use_fahrenheit": False,
"is_major": True,
"risk_level": "low",
"risk_emoji": "🟢",
"airport_name": "樟宜机场",
"distance_km": 17.5,
"warning": "全年温度振幅较小,主要受午后阵雨时段影响。",
},
"tokyo": {
"name": "Tokyo",
"lat": 35.5523,
"lon": 139.7798,
"icao": "RJTT",
"tz_offset": 32400,
"use_fahrenheit": False,
"is_major": True,
"risk_level": "medium",
"risk_emoji": "🟡",
"airport_name": "羽田机场",
"distance_km": 15.0,
"warning": "湾风与热岛效应并存,日最高温时点有时会后移。",
},
"toronto": {
"name": "Toronto",
"lat": 43.6777,
@@ -234,7 +290,10 @@ ALIASES = {
"nyc": "new york", "ny": "new york", "chi": "chicago",
"dal": "dallas", "mia": "miami", "atl": "atlanta",
"sea": "seattle", "tor": "toronto", "sel": "seoul",
"seo": "seoul", "ba": "buenos aires", "wel": "wellington",
"seo": "seoul", "hkg": "hong kong", "hk": "hong kong",
"sha": "shanghai", "sh": "shanghai", "sin": "singapore",
"sg": "singapore", "tok": "tokyo", "tyo": "tokyo",
"ba": "buenos aires", "wel": "wellington",
"luc": "lucknow", "sp": "sao paulo", "mun": "munich",
# Chinese names
@@ -249,6 +308,11 @@ ALIASES = {
"西雅图": "seattle",
"多伦多": "toronto",
"首尔": "seoul",
"香港": "hong kong",
"上海": "shanghai",
"新加坡": "singapore",
"东京": "tokyo",
"東京": "tokyo",
"布宜诺斯艾利斯": "buenos aires",
"惠灵顿": "wellington",
"勒克瑙": "lucknow",
+14
View File
@@ -32,6 +32,10 @@ class WeatherDataCollector:
"new york": ["KLGA", "KJFK", "KEWR", "KTEB", "KHPN"],
"paris": ["LFPG", "LFPO", "LFPB"],
"seoul": ["RKSI", "RKSS"],
"hong kong": ["VHHH", "VMMC", "ZGSZ"],
"shanghai": ["ZSPD", "ZSSS", "ZSNB", "ZSHC"],
"singapore": ["WSSS", "WSAP", "WMKK"],
"tokyo": ["RJTT", "RJAA", "RJAH", "RJTJ"],
"toronto": ["CYYZ", "CYTZ", "CYKF"],
"chicago": ["KORD", "KMDW", "KPWK", "KDPA"],
"dallas": ["KDAL", "KDFW", "KADS", "KGKY"],
@@ -1656,6 +1660,16 @@ class WeatherDataCollector:
"亚特兰大": "Atlanta",
"seoul": "Seoul",
"首尔": "Seoul",
"hong kong": "Hong Kong",
"hong kong international airport": "Hong Kong",
"香港": "Hong Kong",
"shanghai": "Shanghai",
"上海": "Shanghai",
"singapore": "Singapore",
"新加坡": "Singapore",
"tokyo": "Tokyo",
"东京": "Tokyo",
"東京": "Tokyo",
"toronto": "Toronto",
"多伦多": "Toronto",
"ankara": "Ankara",