调整天气触发词

This commit is contained in:
liuwei
2025-05-20 15:39:10 +08:00
parent f19d7f954f
commit d22eecc28a

View File

@@ -84,8 +84,8 @@ class WeatherPlugin(MessagePluginInterface):
roomid = message.get("roomid", "") roomid = message.get("roomid", "")
# 只处理群消息且包含"天气"的消息 # 只处理群消息且包含"天气"的消息
if not roomid or content.startswith("天气") or content.endswith("天气") : if not roomid and not (content.startswith("天气") or content.endswith("天气")):
return True return False
return True return True
@@ -113,7 +113,8 @@ class WeatherPlugin(MessagePluginInterface):
# 配置密钥检查 # 配置密钥检查
if not self.api_key: if not self.api_key:
await bot.send_text_message((roomid if roomid else sender), "\n你还没配置天气API密钥请在config.toml中配置Weather.API_KEY", sender) await bot.send_text_message((roomid if roomid else sender),
"\n你还没配置天气API密钥请在config.toml中配置Weather.API_KEY", sender)
return False, "API密钥未配置" return False, "API密钥未配置"
try: try:
@@ -165,7 +166,8 @@ class WeatherPlugin(MessagePluginInterface):
} }
geo_api_url = f"{self.api_domain}/geo/v2/city/lookup" geo_api_url = f"{self.api_domain}/geo/v2/city/lookup"
conn_ssl = aiohttp.TCPConnector(ssl=False) conn_ssl = aiohttp.TCPConnector(ssl=False)
async with aiohttp.request('GET', url=geo_api_url, connector=conn_ssl, headers=headers, params=params) as response: async with aiohttp.request('GET', url=geo_api_url, connector=conn_ssl, headers=headers,
params=params) as response:
geoapi_json = await response.json() geoapi_json = await response.json()
await conn_ssl.close() await conn_ssl.close()