The following changes were made by the replace_file_content tool to: /root/MayaXSenderbot/bridge.py. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -411,6 +411,55 @@ def _workspace_fcm_menu(self, ws: Workspace) -> ReplyKeyboardMarkup: return reply_kb(FCM_KB) + def _paginate_list(self, items: list[str], page: int, page_size: int = 8) -> tuple[list[str], int, int]: + total_items = len(items) + total_pages = max(1, (total_items + page_size - 1) // page_size) + page = max(1, min(page, total_pages)) + start = (page - 1) * page_size + end = start + page_size + page_items = items[start:end] + return page_items, page, total_pages + + def _build_paginated_keyboard( + self, + items: list[str], + prefix: str, + page: int, + total_pages: int, + ) -> ReplyKeyboardMarkup: + rows = [[f"{prefix}{item}"] for item in items] + if total_pages > 1: + nav_row = [] + if page > 1: + nav_row.append("ā¬…ļø Prev") + nav_row.append(f"šŸ“„ {page}/{total_pages}") + if page < total_pages: + nav_row.append("āž”ļø Next") + rows.append(nav_row) + rows.append(["šŸ”™ Back to Menu"]) + return reply_kb(rows) + + async def send_paginated_list( + self, + ws: Workspace, + title: str, + subtitle: str, + items: list[str], + prefix: str, + state: str, + ) -> None: + ws.state = state + page_items, current_page, total_pages = self._paginate_list(items, ws.page, page_size=8) + ws.page = current_page + self.save_workspace(ws) + kb = self._build_paginated_keyboard(page_items, prefix, current_page, total_pages) + page_info = f"\nšŸ“„ **Page {current_page} of {total_pages}** ({len(items)} total)" if total_pages > 1 else "" + await self.send( + ws.user_id, + fmt_msg(title, f"{subtitle}{page_info}", success=False), + keyboard=kb, + ) + async def send(self, chat_id: str | int, text: str, keyboard: Optional[Any] = None): if not self.bot: return None [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.