fix max-bot, add tests
This commit is contained in:
parent
7abbaf7e7a
commit
2ad1438e1c
17 changed files with 1621 additions and 494 deletions
|
|
@ -7,7 +7,15 @@ class ChatHandler:
|
|||
def __init__(self, store: ChatStore):
|
||||
self.store = store
|
||||
|
||||
def handle_new(self, max_chat_id: str, user_id: str, agent_id: str, name: str = None) -> str:
|
||||
def handle_new(
|
||||
self,
|
||||
max_chat_id: str,
|
||||
user_id: str,
|
||||
agent_id: str,
|
||||
name: str | None = None,
|
||||
*,
|
||||
workspace_path: str = "",
|
||||
) -> str:
|
||||
platform_chat_id = str(uuid.uuid4())
|
||||
room = RoomMeta(
|
||||
platform_chat_id=platform_chat_id,
|
||||
|
|
@ -15,6 +23,7 @@ class ChatHandler:
|
|||
name=name or "New Chat",
|
||||
user_id=user_id,
|
||||
agent_id=agent_id,
|
||||
workspace_path=workspace_path,
|
||||
)
|
||||
self.store.add_room(room)
|
||||
return platform_chat_id
|
||||
|
|
@ -22,27 +31,27 @@ class ChatHandler:
|
|||
def handle_chats(self, user_id: str) -> str:
|
||||
rooms = self.store.list_rooms_for_user(user_id)
|
||||
if not rooms:
|
||||
return "No active chats."
|
||||
return "Нет активных чатов."
|
||||
lines = [f" {i+1}. {r.name}" for i, r in enumerate(rooms)]
|
||||
return "\n".join(lines)
|
||||
|
||||
def handle_rename(self, max_chat_id: str, new_name: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
return "Чат не найден."
|
||||
room.name = new_name
|
||||
return f"Chat renamed to: {new_name}"
|
||||
return f"Чат переименован в: {new_name}"
|
||||
|
||||
def handle_archive(self, max_chat_id: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
return "Чат не найден."
|
||||
self.store.remove_room(max_chat_id)
|
||||
return "Chat archived."
|
||||
return "Чат архивирован."
|
||||
|
||||
def handle_clear(self, max_chat_id: str) -> str:
|
||||
room = self.store.get_room_by_max_chat_id(max_chat_id)
|
||||
if not room:
|
||||
return "Chat not found."
|
||||
return "Чат не найден."
|
||||
room.platform_chat_id = str(uuid.uuid4())
|
||||
return "Chat context cleared."
|
||||
return "Контекст чата очищен."
|
||||
Loading…
Add table
Add a link
Reference in a new issue