mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-07 21:00:21 +08:00
fix
This commit is contained in:
@@ -3,6 +3,7 @@ from .data_source import get_yiqing_data
|
||||
from services.log import logger
|
||||
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
|
||||
from nonebot.typing import T_State
|
||||
from utils.utils import get_message_text
|
||||
|
||||
__plugin_name__ = "疫情查询"
|
||||
__plugin_usage__ = "查询疫情帮助:\n\t对我说 查询疫情 省份/城市,我会回复疫情的实时数据\n\t示例: 查询疫情 温州"
|
||||
@@ -13,7 +14,7 @@ yiqing = on_command("疫情", aliases={"查询疫情", "疫情查询"}, priority
|
||||
|
||||
@yiqing.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
msg = str(event.get_message()).strip()
|
||||
msg = get_message_text(event.json())
|
||||
result = await get_yiqing_data(msg)
|
||||
if result:
|
||||
await yiqing.send(result)
|
||||
|
||||
@@ -25,16 +25,16 @@ async def get_yiqing_data(area: str):
|
||||
if area == '中国':
|
||||
province = area
|
||||
province_type = ""
|
||||
elif area in data.keys():
|
||||
province = area
|
||||
if len(data[area]) == 1:
|
||||
province_type = "市"
|
||||
city = ""
|
||||
else:
|
||||
elif area[-1] != '省':
|
||||
for p in data.keys():
|
||||
if area in data[p]:
|
||||
province = p
|
||||
city = area
|
||||
elif area in data.keys() or area[:-1] in data.keys():
|
||||
province = area if area[-1] != '省' else area[:-1]
|
||||
if len(data[province]) == 1:
|
||||
province_type = "市"
|
||||
city = ""
|
||||
if not province and not city:
|
||||
return "小真寻只支持国内的疫情查询喔..."
|
||||
async with aiohttp.ClientSession(headers=get_user_agent()) as session:
|
||||
|
||||
Reference in New Issue
Block a user