mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
修复创建回复历史文件bug
This commit is contained in:
parent
5ddf178b1a
commit
6846b7372e
1 changed files with 10 additions and 4 deletions
|
|
@ -20,12 +20,18 @@ MaoYuNaSetting = character_settings.settings['MaoYuNa'][0]
|
||||||
"""回复历史文件"""
|
"""回复历史文件"""
|
||||||
filename = os.getcwd() + '/src/ai_chat/chat_history.txt'
|
filename = os.getcwd() + '/src/ai_chat/chat_history.txt'
|
||||||
|
|
||||||
|
|
||||||
|
def check_file_exists():
|
||||||
|
if os.path.exists(filename):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
with open(filename, 'w', encoding='utf-8'):
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
# 读取历史记录
|
# 读取历史记录
|
||||||
|
|
||||||
|
|
||||||
def read_chat_history():
|
def read_chat_history():
|
||||||
with open(filename, 'w', encoding='utf-8'):
|
check_file_exists()
|
||||||
pass
|
|
||||||
with open(filename, 'r', encoding='utf-8') as file:
|
with open(filename, 'r', encoding='utf-8') as file:
|
||||||
line_count = 1
|
line_count = 1
|
||||||
for line in file: # 遍历文件中的每一行
|
for line in file: # 遍历文件中的每一行
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue