feat(01-02): convert matrix archive and rename handlers to factories
- register archive and rename as client-aware closure handlers - rename matrix rooms via stored surface_ref when a client is available - keep archive scoped to core chat state for phase 1
This commit is contained in:
parent
c8770da345
commit
b7a04b6cf1
2 changed files with 35 additions and 14 deletions
|
|
@ -130,15 +130,36 @@ async def handle_list_chats(
|
|||
return [OutgoingMessage(chat_id=event.chat_id, text="\n".join(lines))]
|
||||
|
||||
|
||||
async def handle_rename(event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr) -> list:
|
||||
if not event.args:
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Укажите название: !rename Название")]
|
||||
ctx = await chat_mgr.rename(event.chat_id, " ".join(event.args), user_id=event.user_id)
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Переименован в: {ctx.display_name}")]
|
||||
def make_handle_rename(
|
||||
client: Any | None,
|
||||
store: Any | None,
|
||||
) -> Callable[..., Awaitable[list]]:
|
||||
async def handle_rename(
|
||||
event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
if not event.args:
|
||||
return [
|
||||
OutgoingMessage(chat_id=event.chat_id, text="Укажите название: !rename Название")
|
||||
]
|
||||
|
||||
new_name = " ".join(event.args)
|
||||
ctx = await chat_mgr.rename(event.chat_id, new_name, user_id=event.user_id)
|
||||
if client is not None and ctx.surface_ref:
|
||||
await client.room_set_name(ctx.surface_ref, new_name)
|
||||
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text=f"Переименован в: {ctx.display_name}")]
|
||||
|
||||
return handle_rename
|
||||
|
||||
|
||||
async def handle_archive(
|
||||
event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
await chat_mgr.archive(event.chat_id, user_id=event.user_id)
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Чат архивирован.")]
|
||||
def make_handle_archive(
|
||||
client: Any | None,
|
||||
store: Any | None,
|
||||
) -> Callable[..., Awaitable[list]]:
|
||||
async def handle_archive(
|
||||
event: IncomingCommand, auth_mgr, platform, chat_mgr, settings_mgr
|
||||
) -> list:
|
||||
await chat_mgr.archive(event.chat_id, user_id=event.user_id)
|
||||
return [OutgoingMessage(chat_id=event.chat_id, text="Чат архивирован.")]
|
||||
|
||||
return handle_archive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue