Spaces:
Sleeping
Sleeping
Update command_handler.py
Browse files- command_handler.py +5 -9
command_handler.py
CHANGED
|
@@ -7,7 +7,7 @@ from cwa_service import fetch_cwa_alarm_list, fetch_significant_earthquakes
|
|
| 7 |
from usgs_service import fetch_global_last24h_text, fetch_taiwan_df_this_year
|
| 8 |
from plotting_service import create_and_save_map
|
| 9 |
from ai_service import generate_ai_text
|
| 10 |
-
from weather_service import fetch_forecast_by_location
|
| 11 |
from config import CURRENT_YEAR, HF_SPACE_URL
|
| 12 |
|
| 13 |
def get_help_message() -> TextMessage:
|
|
@@ -21,8 +21,7 @@ def get_help_message() -> TextMessage:
|
|
| 21 |
"• /alert - 獲取 CWA 最新地震預警\n"
|
| 22 |
"• /significant - CWA 最新顯著有感地震\n\n"
|
| 23 |
"【AI 與工具】\n"
|
| 24 |
-
"• /ai <問題> - 與 AI 助理對話\n"
|
| 25 |
-
"• /weather <地點> - 查詢天氣預報\n\n"
|
| 26 |
"【基本指令】\n"
|
| 27 |
"• /info - 關於此機器人\n"
|
| 28 |
"• /help - 顯示此說明"
|
|
@@ -33,8 +32,8 @@ def get_info_message() -> TextMessage:
|
|
| 33 |
"""回傳機器人資訊。"""
|
| 34 |
text = (
|
| 35 |
"🤖 關於我\n\n"
|
| 36 |
-
"
|
| 37 |
-
"• 版本: 2.
|
| 38 |
"• 資料來源: CWA, USGS, Hugging Face\n"
|
| 39 |
"• 開發者: dayichen"
|
| 40 |
)
|
|
@@ -106,10 +105,7 @@ def process_message(user_message_raw: str, request_base_url: str) -> list:
|
|
| 106 |
return [TextMessage(text=fetch_cwa_alarm_list(limit=5))]
|
| 107 |
elif command == '/significant':
|
| 108 |
return [TextMessage(text=fetch_significant_earthquakes(limit=5))]
|
| 109 |
-
elif command == '/weather':
|
| 110 |
-
if not arg:
|
| 111 |
-
return [TextMessage(text="請輸入地點,例如:/weather 台北")]
|
| 112 |
-
return [TextMessage(text=fetch_forecast_by_location(arg))]
|
| 113 |
elif command == '/ai':
|
| 114 |
if not arg:
|
| 115 |
return [TextMessage(text="請輸入問題,例如:/ai 台灣最高的山是哪座?")]
|
|
|
|
| 7 |
from usgs_service import fetch_global_last24h_text, fetch_taiwan_df_this_year
|
| 8 |
from plotting_service import create_and_save_map
|
| 9 |
from ai_service import generate_ai_text
|
| 10 |
+
# [移除] from weather_service import fetch_forecast_by_location
|
| 11 |
from config import CURRENT_YEAR, HF_SPACE_URL
|
| 12 |
|
| 13 |
def get_help_message() -> TextMessage:
|
|
|
|
| 21 |
"• /alert - 獲取 CWA 最新地震預警\n"
|
| 22 |
"• /significant - CWA 最新顯著有感地震\n\n"
|
| 23 |
"【AI 與工具】\n"
|
| 24 |
+
"• /ai <問題> - 與 AI 助理對話\n\n" # [移除] /weather 指令說明
|
|
|
|
| 25 |
"【基本指令】\n"
|
| 26 |
"• /info - 關於此機器人\n"
|
| 27 |
"• /help - 顯示此說明"
|
|
|
|
| 32 |
"""回傳機器人資訊。"""
|
| 33 |
text = (
|
| 34 |
"🤖 關於我\n\n"
|
| 35 |
+
"我是一個多功能助理機器人,提供地震查詢與 AI 對話功能。\n\n" # [修改] 更新功能描述
|
| 36 |
+
"• 版本: 2.2\n"
|
| 37 |
"• 資料來源: CWA, USGS, Hugging Face\n"
|
| 38 |
"• 開發者: dayichen"
|
| 39 |
)
|
|
|
|
| 105 |
return [TextMessage(text=fetch_cwa_alarm_list(limit=5))]
|
| 106 |
elif command == '/significant':
|
| 107 |
return [TextMessage(text=fetch_significant_earthquakes(limit=5))]
|
| 108 |
+
# [移除] elif command == '/weather': ...
|
|
|
|
|
|
|
|
|
|
| 109 |
elif command == '/ai':
|
| 110 |
if not arg:
|
| 111 |
return [TextMessage(text="請輸入問題,例如:/ai 台灣最高的山是哪座?")]
|