{"id":13988643,"url":"https://github.com/SergSm/ptb-menu-pagination","last_synced_at":"2025-07-22T09:31:21.966Z","repository":{"id":57455411,"uuid":"436875887","full_name":"SergSm/ptb-menu-pagination","owner":"SergSm","description":"🤖🧭Creates google-like navigation menu using python-telegram-bot wrapper","archived":false,"fork":false,"pushed_at":"2022-04-08T06:29:54.000Z","size":808,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T16:18:09.891Z","etag":null,"topics":["menu","paginate","pagination","paginator","python-telegram-bot","python-telegram-bot-menu","search-results-pagination","telegram","telegram-bot","telegram-bot-example"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SergSm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-10T06:33:15.000Z","updated_at":"2024-07-07T13:19:03.000Z","dependencies_parsed_at":"2022-08-26T10:11:15.896Z","dependency_job_id":null,"html_url":"https://github.com/SergSm/ptb-menu-pagination","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SergSm/ptb-menu-pagination","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergSm%2Fptb-menu-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergSm%2Fptb-menu-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergSm%2Fptb-menu-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergSm%2Fptb-menu-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SergSm","download_url":"https://codeload.github.com/SergSm/ptb-menu-pagination/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SergSm%2Fptb-menu-pagination/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266465069,"owners_count":23933054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["menu","paginate","pagination","paginator","python-telegram-bot","python-telegram-bot-menu","search-results-pagination","telegram","telegram-bot","telegram-bot-example"],"created_at":"2024-08-09T13:01:16.967Z","updated_at":"2025-07-22T09:31:21.564Z","avatar_url":"https://github.com/SergSm.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# python telegram bot menu pagination\n![Actions Status](https://github.com/SergSm/ptb-menu-pagination/workflows/ci/badge.svg)\n[![Maintainability](https://api.codeclimate.com/v1/badges/9eade003d09d837c852e/maintainability)](https://codeclimate.com/github/SergSm/ptb-menu-pagination/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/9eade003d09d837c852e/test_coverage)](https://codeclimate.com/github/SergSm/ptb-menu-pagination/test_coverage)\n\n# Description\n\nMakes a google style pagination line for a list of items.\n\n![](https://github.com/SergSm/ptb-menu-pagination/raw/main/example/media/example2.png)\n\nIn other words it builds a menu for navigation if you have \na lot of search results or whatever list of anything \n\n![](https://github.com/SergSm/ptb-menu-pagination/raw/main/example/media/example3.png)\n\n## Project structure\n```\n│   .gitignore\n│   LICENSE\n│   Makefile\n│   poetry.lock\n│   pyproject.toml\n│   README.md\n├───.github/\n│   └───workflows/\n│           ci.yml\n├───example/\n│   │   search_bot.py\n│   │\n│   ├───fixtures\n│   │       data.txt\n│   │\n│   └───media/\n│           example2.png\n│           example3.png\n├───paginator/\n│   │   consts.py\n│   │   main.py\n│   │   __init__.py\n│   └───composers/\n│           map.py\n│           menu.py\n│           __init__.py\n└───tests/\n    │   test_paginator_get_menu.py\n    │   __init__.py\n    └───fixtures/\n            fixtures.py\n```\n\n### Installation\n\n```\npip install ptb-menu-navigation\n```\n\n\nor if you are working with source code and use Poetry tool:\n\n```\nmake install\n```\n\n### Usage\n```python\nfrom paginator import get_menu\n```\n\n\nUse ```get_menu``` function to create a line of pages\n\n#### Example:\n```python\nfrom paginator import get_menu \nfrom dataclasses import dataclass\n\n# Define initial menu settings in the dataclass.\n@dataclass\nclass Menu:\n    items_per_page: int = 10\n    pages_per_line: int = 3\n    navigation_signature: str = '±'\n    page_label: str = ' p. '\n\n# Add the initial call of get_menu\ndef handling_input(update, context):\n    # ...\n    # On first invocation\n    navigation = get_menu(total_items=len(search_results),\n                          current_page=1,\n                          menu_settings=Menu)\n    # ...\n\n# Add a callback to handle a page switching  \ndef navigate(update, context):\n    # ...\n    navigation = get_menu(total_items=len(search_results),\n                          current_page=int(current_page),\n                          menu_settings=Menu)     \n    # ...            \n```\nwhere ```search_results``` is a list of strings and ```current_page```\nis a number extracted from a ```callback_data```.\n\nSee ```examples/search_bot.py```\n\n### Demo bot launch\nCreate a ```.env``` file with a ```TOKEN``` variable\ninside of an ```/examples``` for launching \nthe\n[demo](https://github.com/SergSm/ptb-menu-pagination/blob/main/example/search_bot.py) bot.\\\neg:\\\n```TOKEN=\u003cYOUR_TELEGRAM_BOT_TOKEN_FROM_BOT_FATHER\u003e```\n\nYou may also provide some additional menu values in the same ```.env``` file:\n```\nITEMS_PER_PAGE=1\nPAGES_PER_LINE=1\nNAVIGATION_SIGNATURE=\"±\"\nPAGE_LABEL=\" p. \"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergSm%2Fptb-menu-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSergSm%2Fptb-menu-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSergSm%2Fptb-menu-pagination/lists"}