fix: !list时会显示预设消息 #48

This commit is contained in:
Rock Chin 2022-12-18 20:04:39 +08:00
parent 8c588c5c1d
commit 03a5f15a58
2 changed files with 5 additions and 3 deletions

View File

@ -198,7 +198,7 @@ class DatabaseManager:
}
# 列出与某个对象的所有对话session
def list_history(self, session_name: str, capacity: int, page: int):
def list_history(self, session_name: str, capacity: int, page: int, replace: str = ""):
self.execute("""
select `name`, `type`, `number`, `create_timestamp`, `last_interact_timestamp`, `prompt`, `status`
from `sessions` where `name` = '{}' order by `last_interact_timestamp` desc limit {} offset {}
@ -219,7 +219,7 @@ class DatabaseManager:
'subject_number': subject_number,
'create_timestamp': create_timestamp,
'last_interact_timestamp': last_interact_timestamp,
'prompt': prompt
'prompt': prompt if replace == "" else prompt.replace(replace, "")
})
return sessions

View File

@ -262,4 +262,6 @@ class Session:
return self
def list_history(self, capacity: int = 10, page: int = 0):
return pkg.database.manager.get_inst().list_history(self.name, capacity, page)
return pkg.database.manager.get_inst().list_history(self.name, capacity, page,
(self.user_name + ":" + get_default_prompt() + "\n" +
self.bot_name + ":") if get_default_prompt() != "" else "")