-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathinit.py
More file actions
31 lines (24 loc) · 838 Bytes
/
init.py
File metadata and controls
31 lines (24 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import logging
import os
from .config import (
BASE_DATA_DIR,
DEFAULT_CATEGORY_DESCRIPTIONS,
MEMES_DATA_PATH,
)
from .utils import copy_default_memes_if_needed, ensure_dir_exists, save_json
logger = logging.getLogger(__name__)
def init_plugin():
"""初始化插件,创建必要的目录和配置文件"""
try:
# 创建基础数据目录
ensure_dir_exists(BASE_DATA_DIR)
# 创建表情包目录
copy_default_memes_if_needed()
# 初始化 memes_data.json
if not os.path.exists(MEMES_DATA_PATH):
save_json(DEFAULT_CATEGORY_DESCRIPTIONS, MEMES_DATA_PATH)
logger.info(f"创建默认类别描述文件: {MEMES_DATA_PATH}")
return True
except Exception as e:
logger.error(f"插件初始化失败: {e}")
return False