@@ -1,6 +1,6 @@
|
|||||||
[Weather]
|
[Weather]
|
||||||
enable = true
|
enable = true
|
||||||
command = ["天气", "天气订阅", "取消天气订阅"]
|
command = ["天气", "订阅天气", "取消订阅"]
|
||||||
command-format = """
|
command-format = """
|
||||||
⚙️获取天气:
|
⚙️获取天气:
|
||||||
天气 城市名
|
天气 城市名
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class WeatherPlugin(MessagePluginInterface):
|
|||||||
def can_process(self, message: Dict[str, Any]) -> bool:
|
def can_process(self, message: Dict[str, Any]) -> bool:
|
||||||
if not self.enable: return False
|
if not self.enable: return False
|
||||||
content = str(message.get("content", "")).strip()
|
content = str(message.get("content", "")).strip()
|
||||||
for cmd in ["天气", "天气订阅", "取消天气订阅"]:
|
for cmd in ["天气", "订阅天气", "取消订阅"]:
|
||||||
if content.startswith(cmd): return True
|
if content.startswith(cmd): return True
|
||||||
|
|
||||||
@plugin_stats_decorator(plugin_name="天气查询")
|
@plugin_stats_decorator(plugin_name="天气查询")
|
||||||
@@ -169,10 +169,10 @@ class WeatherPlugin(MessagePluginInterface):
|
|||||||
# --- 业务分流 ---
|
# --- 业务分流 ---
|
||||||
|
|
||||||
# 1. 订阅逻辑 (核心修改点)
|
# 1. 订阅逻辑 (核心修改点)
|
||||||
if content.startswith("天气订阅"):
|
if content.startswith("订阅天气"):
|
||||||
if not self.redis_manager: return False, "数据库未连接"
|
if not self.redis_manager: return False, "数据库未连接"
|
||||||
|
|
||||||
input_city = content.replace("天气订阅", "").strip()
|
input_city = content.replace("订阅天气", "").strip()
|
||||||
if not input_city: return False, "请指定城市"
|
if not input_city: return False, "请指定城市"
|
||||||
|
|
||||||
# Step A: 模糊查询获取 唯一ID 和 标准名
|
# Step A: 模糊查询获取 唯一ID 和 标准名
|
||||||
@@ -209,7 +209,7 @@ class WeatherPlugin(MessagePluginInterface):
|
|||||||
return True, "订阅成功"
|
return True, "订阅成功"
|
||||||
|
|
||||||
# 2. 取消订阅
|
# 2. 取消订阅
|
||||||
elif content.startswith("取消天气订阅"):
|
elif content.startswith("取消订阅"):
|
||||||
if not self.redis_manager: return False, "数据库不可用"
|
if not self.redis_manager: return False, "数据库不可用"
|
||||||
unique_id = f"{roomid}_{sender}" if roomid else f"private_{sender}"
|
unique_id = f"{roomid}_{sender}" if roomid else f"private_{sender}"
|
||||||
self.redis_manager.remove_subscription(unique_id)
|
self.redis_manager.remove_subscription(unique_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user