Simple Inline Calendar & Date Selection tool for Aiogram Telegram bots
Project description
Date Selection tool for Aiogram Telegram Bots
Description
A simple inline calendar, date selection tool for aiogram telegram bots written in Python.
Offers two types of date pickers:
Navigation calendar - user can either select a date or move to the next or previous month/year by clicking a singe button.
Dialog calendar - user selects year on first stage, month on next stage, day on last stage.
From version 0.2 supports aiogram 3, use version 0.1.1 with aiogram 2.
Main features
- Two calendars with abilities to navigate years, months, days altogether or in dialog
- Ability to set specified locale (language of captions) or inherit from user`s locale
- Limiting the range of dates to select from
- Highlighting todays date
Usage
Install package
pip install aiogram_calendar
A full working example on how to use aiogram-calendar is provided in *bot_example.py*
.
In example keyboard with buttons is created.
Each button triggers a calendar in a different way by adding it to a message with a reply_markup.
reply_markup=await SimpleCalendar().start_calendar()
^^ will reply with a calendar created using English localization (months and days of week captions). Locale can be overridden by passing locale argument:
reply_markup=await SimpleCalendar(locale='uk_UA').start_calendar()
or by getting locale from User data provided by telegram API using get_user_locale method by passing message.from_user
to it
reply_markup=await SimpleCalendar(locale=await get_user_locale(message.from_user)).start_calendar()
Depending on what button of calendar user will press callback is precessed using the process_selection method.
selected, date = await SimpleCalendar(locale=await get_user_locale(callback_query.from_user)).process_selection(callback_query, callback_data)
Here locale is specified from callback_query.from_user
Gif demo:
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
Built Distribution
File details
Details for the file aiogram_calendar-0.5.0.tar.gz
.
File metadata
- Download URL: aiogram_calendar-0.5.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d76bd55ccfbc5d2c1cb0866636a626d57ea09052fdf10ce62dd39162aa4225 |
|
MD5 | 1083132638398c4e0694da1eb355616e |
|
BLAKE2b-256 | e2ba4e8c40ab1bcd15fd3627de0b03c72fd4cd43a1bca50e61ab2fba94cd1742 |
File details
Details for the file aiogram_calendar-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: aiogram_calendar-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73b1f900b946aea51e54ba0049cdd308ec775d1cb028599fcebd89fd38a0ff61 |
|
MD5 | 64905acaa76376b1931f3a30c218ac4b |
|
BLAKE2b-256 | 54c9c27cafbab53c72ec14af24b89408d6fbeff50fd529956d8eb8b041883b52 |