mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-14 14:31:00 +00:00
fix: !list时会显示预设消息 #48
This commit is contained in:
@@ -198,7 +198,7 @@ class DatabaseManager:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# 列出与某个对象的所有对话session
|
# 列出与某个对象的所有对话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("""
|
self.execute("""
|
||||||
select `name`, `type`, `number`, `create_timestamp`, `last_interact_timestamp`, `prompt`, `status`
|
select `name`, `type`, `number`, `create_timestamp`, `last_interact_timestamp`, `prompt`, `status`
|
||||||
from `sessions` where `name` = '{}' order by `last_interact_timestamp` desc limit {} offset {}
|
from `sessions` where `name` = '{}' order by `last_interact_timestamp` desc limit {} offset {}
|
||||||
@@ -219,7 +219,7 @@ class DatabaseManager:
|
|||||||
'subject_number': subject_number,
|
'subject_number': subject_number,
|
||||||
'create_timestamp': create_timestamp,
|
'create_timestamp': create_timestamp,
|
||||||
'last_interact_timestamp': last_interact_timestamp,
|
'last_interact_timestamp': last_interact_timestamp,
|
||||||
'prompt': prompt
|
'prompt': prompt if replace == "" else prompt.replace(replace, "")
|
||||||
})
|
})
|
||||||
|
|
||||||
return sessions
|
return sessions
|
||||||
|
|||||||
@@ -262,4 +262,6 @@ class Session:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def list_history(self, capacity: int = 10, page: int = 0):
|
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 "")
|
||||||
|
|||||||
Reference in New Issue
Block a user