This commit is contained in:
qsc
2026-01-07 22:57:16 +08:00
parent 723d0a7e4a
commit 98e0d00423
6 changed files with 89 additions and 59 deletions
+7 -15
View File
@@ -1,27 +1,19 @@
from pathlib import Path
from datetime import datetime,date
import aiofiles
def load_template(template_name):
async def load_template(template_name: str) -> str:
"""
从模板文件加载模板内容
Args:
template_name: 模板文件名(不带路径)
Returns:
str: 模板内容
异步加载模板内容(非阻塞)
"""
# 获取模板文件路径
plugin_dir = Path(__file__).parent.parent
template_path = plugin_dir / "templates" / template_name
# 检查文件是否存在
if not template_path.exists():
raise FileNotFoundError(f"模板文件不存在: {template_path}")
# 读取模板内容
with open(template_path, 'r', encoding='utf-8') as f:
return f.read()
async with aiofiles.open(template_path, "r", encoding="utf-8") as f:
return await f.read()
def gold_to_string(gold_amount):