29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""Attachment queue handlers for MAX surface."""
|
||
from adapter.max.store import ChatStore
|
||
|
||
|
||
class AttachmentHandler:
|
||
def __init__(self, store: ChatStore):
|
||
self.store = store
|
||
|
||
def handle_list(self, max_chat_id: str) -> str:
|
||
attachments = self.store.get_attachments(max_chat_id)
|
||
if not attachments:
|
||
return "Очередь вложений пуста."
|
||
lines = [f" {i+1}. {name}" for i, (_, name) in enumerate(attachments)]
|
||
return "\n".join(lines)
|
||
|
||
def handle_remove(self, max_chat_id: str, index: str) -> str:
|
||
attachments = self.store.staged_attachments.get(max_chat_id, [])
|
||
if index.lower() == "all":
|
||
self.store.staged_attachments[max_chat_id] = []
|
||
return "Все вложения удалены из очереди."
|
||
|
||
try:
|
||
idx = int(index) - 1
|
||
if 0 <= idx < len(attachments):
|
||
removed = attachments.pop(idx)
|
||
return f"Удалено: {removed[1]}"
|
||
return "Неверный номер."
|
||
except ValueError:
|
||
return "Использование: /remove <номер> или /remove all"
|