Skip to content

Commit

Permalink
update v0.0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier committed Jan 5, 2022
1 parent 5e5168f commit 30b5658
Show file tree
Hide file tree
Showing 47 changed files with 1,521 additions and 1,281 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,6 @@ test.py
server.py
member_activity_handle.py
Yu-Gi-Oh/

search_image/
black_word/
csgo/
401 changes: 43 additions & 358 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __version__
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: v0.0.7.1
__version__: v0.0.8.0
231 changes: 201 additions & 30 deletions basic_plugins/hooks/auth_hook.py

Large diffs are not rendered by default.

146 changes: 0 additions & 146 deletions basic_plugins/hooks/limit_hook.py

This file was deleted.

4 changes: 3 additions & 1 deletion basic_plugins/init_plugin_config/init_plugins_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def init_plugins_settings(data_path: str):
plugin_settings = _module.__getattribute__(
"__plugin_settings__"
)
if plugin_settings.get('cost_gold') is None:
plugin_settings['cost_gold'] = 0
if (
plugin_settings["cmd"] is not None
and plugin_name not in plugin_settings["cmd"]
Expand All @@ -97,7 +99,7 @@ def init_plugins_settings(data_path: str):
plugins2settings_manager.add_plugin_settings(
matcher.module,
plugin_type=plugin_type,
data_dict=plugin_settings,
**plugin_settings,
)
except AttributeError:
pass
Expand Down
56 changes: 34 additions & 22 deletions basic_plugins/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from configs.path_config import TEXT_PATH
from asyncio.exceptions import TimeoutError
from utils.http_utils import AsyncHttpx
from utils.utils import scheduler
from pathlib import Path
import nonebot

Expand All @@ -27,31 +28,32 @@ async def update_city():
"""
china_city = Path(TEXT_PATH) / "china_city.json"
data = {}
try:
res = await AsyncHttpx.get(
"http://www.weather.com.cn/data/city3jdata/china.html", timeout=5
)
res.encoding = "utf8"
provinces_data = json.loads(res.text)
for province in provinces_data.keys():
data[provinces_data[province]] = []
if not china_city.exists():
try:
res = await AsyncHttpx.get(
f"http://www.weather.com.cn/data/city3jdata/provshi/{province}.html",
timeout=5,
"http://www.weather.com.cn/data/city3jdata/china.html", timeout=5
)
res.encoding = "utf8"
city_data = json.loads(res.text)
for city in city_data.keys():
data[provinces_data[province]].append(city_data[city])
with open(china_city, "w", encoding="utf8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
logger.info("自动更新城市列表完成.....")
except TimeoutError:
logger.warning("自动更新城市列表超时.....")
except ValueError:
logger.warning("自动城市列表失败.....")
except Exception as e:
logger.error(f"自动城市列表未知错误 {type(e)}{e}")
provinces_data = json.loads(res.text)
for province in provinces_data.keys():
data[provinces_data[province]] = []
res = await AsyncHttpx.get(
f"http://www.weather.com.cn/data/city3jdata/provshi/{province}.html",
timeout=5,
)
res.encoding = "utf8"
city_data = json.loads(res.text)
for city in city_data.keys():
data[provinces_data[province]].append(city_data[city])
with open(china_city, "w", encoding="utf8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
logger.info("自动更新城市列表完成.....")
except TimeoutError:
logger.warning("自动更新城市列表超时.....")
except ValueError:
logger.warning("自动城市列表失败.....")
except Exception as e:
logger.error(f"自动城市列表未知错误 {type(e)}{e}")


@driver.on_startup
Expand Down Expand Up @@ -101,3 +103,13 @@ async def _(bot: Bot):
else:
await GroupInfo.delete_group_info(group_id)
logger.info(f"移除不存在的群聊信息:{group_id}")


# 自动更新城市列表
@scheduler.scheduled_job(
"cron",
hour=6,
minute=1,
)
async def _():
await update_city()
2 changes: 1 addition & 1 deletion plugins/shop/__init__.py → basic_plugins/shop/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
)


nonebot.load_plugins("plugins/shop")
nonebot.load_plugins("basic_plugins/shop")
Loading

0 comments on commit 30b5658

Please sign in to comment.