surfaces/adapter/telegram/keyboards/chat.py
Mikhail Putilovskij 9c555261b3 feat: implement adapter/telegram/ with aiogram 3.x
Virtual DM chats, FSM (idle/waiting_response/settings states),
SQLite local DB for tg_users+chats, converter, keyboards, and
handlers for /start, /new, /chats, /settings, confirm callbacks.
2026-03-31 21:35:16 +03:00

16 lines
673 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# adapter/telegram/keyboards/chat.py
from __future__ import annotations
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
def chats_list_keyboard(chats: list[dict], active_chat_id: str | None) -> InlineKeyboardMarkup:
buttons = []
for chat in chats:
mark = "" if chat["chat_id"] == active_chat_id else ""
buttons.append([InlineKeyboardButton(
text=f"{mark}{chat['name']}",
callback_data=f"switch:{chat['chat_id']}:{chat['name']}",
)])
buttons.append([InlineKeyboardButton(text=" Новый чат", callback_data="new_chat")])
return InlineKeyboardMarkup(inline_keyboard=buttons)