Skip to main content

Module for deep pagination in an aiogram bot

Project description

aiogram-pagination

This module will help you create layered callback menus. The module is based on the concept that each callback has all the preceding callbacks in it.


INSTALLATION

pip install aiogram-pagination


QUICK START

To create callbacks you need to use the callback factory from the aiogram-pagination module

from aiogram_pagination.utils.callback_stack_factory import CallbackStackFactory
cb = CallbackStackFactory('foo', 'bar')

You can use both the simple version of the callback stack and the version with abbreviated callbacks.

Simple version:

from aiogram_pagination.callback_stack import SimpleCallbackStack


callback_stack = SimpleCallbackStack(callback_data={'foo': 0, 'bar': 1, 'previous': ''},
                                     callback_factory=cb)
callback_stack.next(callback_data={'foo': 6, 'bar': 6},
                    callback_factory=cb)
callback_stack.previous()

Version with abbreviation:

from aiogram_pagination.callback_stack import AbbreviatedCallbackStack


callback_stack = AbbreviatedCallbackStack(
    callback_data={'foo': 0, 'bar': 1, 'previous': ''},
    callback_factory=cb
)

callback_stack.next(callback_data={'foo': 6, 'bar': 6},
                    callback_factory=cb)
callback_stack.previous(default='some:callback')

CONFIGURATION

For configuration, you can use any configuration file placed in the root directory of the project or in the data folder.

The module uses configs under the "callback stack" key. the default is config.json in the data folder of the aiogram-pagination module.

Example:

{
  "callback_stack":
  {
      "storage": "sqlite",
      "cache_time_limit": 3600,
      "max_pagination_depth": false,
      "redis_db": 1
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiogram-pagination-0.1.1.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file aiogram-pagination-0.1.1.tar.gz.

File metadata

  • Download URL: aiogram-pagination-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for aiogram-pagination-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ad070cc5ebc72356a0ffe50b754d10b679527b1b446807a95b14509426045772
MD5 46cbd0909781af8ba7a8fcf6bc2cdb9e
BLAKE2b-256 0be5e259d24ae2ff9ae74c58b5643234f42fde8a715186983e70b1ddbc13af1e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page