mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-07 12:50:03 +08:00
🐛 修复群欢迎消息删除问题 (#1864)
* 🐛 修复群欢迎消息删除问题 * 🩹 优化笨蛋检测和修复商店图标问题 * 🎨 笨蛋检测更多规则移入rule * 🎨 优化我的道具方法
This commit is contained in:
@@ -22,8 +22,11 @@ BASE_PATH.mkdir(parents=True, exist_ok=True)
|
||||
driver = nonebot.get_driver()
|
||||
|
||||
|
||||
old_file = DATA_PATH / "custom_welcome_msg" / "custom_welcome_msg.json"
|
||||
if old_file.exists():
|
||||
def __migrate():
|
||||
"""首次数据迁移"""
|
||||
old_file = DATA_PATH / "custom_welcome_msg" / "custom_welcome_msg.json"
|
||||
if not old_file.exists():
|
||||
return
|
||||
try:
|
||||
old_data: dict[str, str] = json.load(old_file.open(encoding="utf8"))
|
||||
for group_id, message in old_data.items():
|
||||
@@ -53,6 +56,7 @@ def migrate(path: Path):
|
||||
参数:
|
||||
path: 路径
|
||||
"""
|
||||
__migrate()
|
||||
text_file = path / "text.json"
|
||||
if not text_file.exists():
|
||||
return
|
||||
@@ -248,9 +252,11 @@ class Manager:
|
||||
返回:
|
||||
list: 消息内容
|
||||
"""
|
||||
path = cls.get_path(session)
|
||||
json_data = cls.__get_data(session)
|
||||
if not json_data:
|
||||
if not json_data or not path:
|
||||
return None
|
||||
file = path / "text.json"
|
||||
key_list = list(json_data.keys())
|
||||
if idx < 0 or idx >= len(key_list):
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user