11
This commit is contained in:
+7
-15
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user