Spaces:
Sleeping
Sleeping
Update command_handler.py
Browse files- command_handler.py +7 -2
command_handler.py
CHANGED
|
@@ -9,6 +9,7 @@ from cwa_service import fetch_cwa_alarm_list, fetch_significant_earthquakes, fet
|
|
| 9 |
from usgs_service import fetch_global_last24h_text, fetch_taiwan_df_this_year
|
| 10 |
from ai_service import generate_ai_text
|
| 11 |
from config import CURRENT_YEAR, MCP_SERVER_URL
|
|
|
|
| 12 |
|
| 13 |
def get_help_message() -> TextMessage:
|
| 14 |
"""產生並回傳包含所有指令的說明文字,並附上英文翻譯。"""
|
|
@@ -34,7 +35,10 @@ def get_help_message() -> TextMessage:
|
|
| 34 |
" (e.g., 7 去年最大的地震)\n\n"
|
| 35 |
"【基本指令 (Basic Commands)】\n"
|
| 36 |
"• 8 - 關於此機器人 (About this Bot)\n"
|
| 37 |
-
"• 9 - 顯示此說明 (Show this Help Message)"
|
|
|
|
|
|
|
|
|
|
| 38 |
)
|
| 39 |
return TextMessage(text=text)
|
| 40 |
|
|
@@ -107,6 +111,7 @@ def process_message(user_message_raw: str, request_base_url: str) -> list:
|
|
| 107 |
if command_key == '6': return [TextMessage(text=fetch_significant_earthquakes(limit=5))]
|
| 108 |
if command_key == '8': return [get_info_message()]
|
| 109 |
if command_key == '9': return [get_help_message()]
|
|
|
|
| 110 |
|
| 111 |
if command_key == '7':
|
| 112 |
if not arg: return [TextMessage(text="請輸入問題,例如:7 台灣最高的山是哪座?")]
|
|
@@ -115,4 +120,4 @@ def process_message(user_message_raw: str, request_base_url: str) -> list:
|
|
| 115 |
|
| 116 |
# [核心修改]
|
| 117 |
# 對於所有其他無法識別的訊息 (一般對話),回傳一個空列表,代表「不回應」。
|
| 118 |
-
return []
|
|
|
|
| 9 |
from usgs_service import fetch_global_last24h_text, fetch_taiwan_df_this_year
|
| 10 |
from ai_service import generate_ai_text
|
| 11 |
from config import CURRENT_YEAR, MCP_SERVER_URL
|
| 12 |
+
from pws_service import fetch_cwa_pws_earthquake_info # 匯入新函式
|
| 13 |
|
| 14 |
def get_help_message() -> TextMessage:
|
| 15 |
"""產生並回傳包含所有指令的說明文字,並附上英文翻譯。"""
|
|
|
|
| 35 |
" (e.g., 7 去年最大的地震)\n\n"
|
| 36 |
"【基本指令 (Basic Commands)】\n"
|
| 37 |
"• 8 - 關於此機器人 (About this Bot)\n"
|
| 38 |
+
"• 9 - 顯示此說明 (Show this Help Message)\n\n"
|
| 39 |
+
"【其他服務 (Other Services)】\n"
|
| 40 |
+
"• 11 - 查詢最近地震PWS訊息\n"
|
| 41 |
+
" (Recent PWS Earthquake Info)"
|
| 42 |
)
|
| 43 |
return TextMessage(text=text)
|
| 44 |
|
|
|
|
| 111 |
if command_key == '6': return [TextMessage(text=fetch_significant_earthquakes(limit=5))]
|
| 112 |
if command_key == '8': return [get_info_message()]
|
| 113 |
if command_key == '9': return [get_help_message()]
|
| 114 |
+
if command_key == '11': return [TextMessage(text=fetch_cwa_pws_earthquake_info())]
|
| 115 |
|
| 116 |
if command_key == '7':
|
| 117 |
if not arg: return [TextMessage(text="請輸入問題,例如:7 台灣最高的山是哪座?")]
|
|
|
|
| 120 |
|
| 121 |
# [核心修改]
|
| 122 |
# 對於所有其他無法識別的訊息 (一般對話),回傳一個空列表,代表「不回應」。
|
| 123 |
+
return []
|