mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-18 18:50:05 +08:00
update v0.0.5.0
This commit is contained in:
@@ -7,8 +7,25 @@ from nonebot.typing import T_State
|
||||
import re
|
||||
from utils.utils import get_message_text
|
||||
|
||||
__plugin_name__ = "天气查询"
|
||||
__plugin_usage__ = "普普通通的查天气吧\n示例:北京天气"
|
||||
|
||||
__zx_plugin_name__ = "天气查询"
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
普普通通的查天气吧
|
||||
指令:
|
||||
[城市]天气/天气[城市]
|
||||
""".strip()
|
||||
__plugin_des__ = "出门要看看天气,不要忘了带伞"
|
||||
__plugin_cmd__ = ["[城市]天气/天气[城市]"]
|
||||
__plugin_type__ = ("一些工具",)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = "HibiKier"
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["查询天气", "天气", "天气查询", "查天气"],
|
||||
}
|
||||
|
||||
|
||||
weather = on_regex(r".*?(.*)市?的?天气.*?", priority=5, block=True)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from services.log import logger
|
||||
from utils.message_builder import image
|
||||
from utils.user_agent import get_user_agent
|
||||
from configs.path_config import TXT_PATH
|
||||
from configs.path_config import TEXT_PATH
|
||||
from configs.config import NICKNAME
|
||||
from asyncio.exceptions import TimeoutError
|
||||
from typing import List
|
||||
@@ -13,13 +13,9 @@ import nonebot
|
||||
|
||||
driver: Driver = nonebot.get_driver()
|
||||
|
||||
china_city = Path(TXT_PATH) / "china_city.json"
|
||||
china_city = Path(TEXT_PATH) / "china_city.json"
|
||||
|
||||
try:
|
||||
with open(china_city, "r", encoding="utf8") as f:
|
||||
data = json.load(f)
|
||||
except FileNotFoundError:
|
||||
data = {}
|
||||
data = {}
|
||||
|
||||
|
||||
async def get_weather_of_city(city: str) -> str:
|
||||
@@ -93,6 +89,12 @@ def _check_exists_city(city: str) -> int:
|
||||
|
||||
def get_city_list() -> List[str]:
|
||||
global data
|
||||
if not data:
|
||||
try:
|
||||
with open(china_city, "r", encoding="utf8") as f:
|
||||
data = json.load(f)
|
||||
except FileNotFoundError:
|
||||
data = {}
|
||||
city_list = []
|
||||
for p in data.keys():
|
||||
for c in data[p]:
|
||||
|
||||
Reference in New Issue
Block a user