aiogram_utcpicker
pip install aiogram-utcpicker
UTC selection tool for aiogram3 telegram bots
Use case
The tool is designed to allow users interactively select valid timezones (listed at https://timezonedb.com/time-zones).
To enforce valid timezone selection, the tool has some restrictions:
- Hours: Values only in the range of 0 to 14 (inclusively) are allowed.
- Minutes: Can only be 0, 30 or 45.
Even with the restrictions listed above, it's still possible to select a timezone that is not listed at https://timezonedb.com/time-zones.
If that happens, an error message will be displayed ( as a notification envoked by callback.answer() )
Demo
import logging
import asyncio
import sys
import aiogram.client.default
from aiogram_utcpicker import UtcPickerCallback, start_utc_picker, process_utc_picker
from aiogram import Bot, Dispatcher
from aiogram.enums import ParseMode
from aiogram.filters import Command
from aiogram.filters.callback_data import CallbackData
from aiogram.types import Message, CallbackQuery
dp = Dispatcher()
YOUR_API_TOKEN = ''
@dp.message(Command('utc_picker'))
async def cmd_utc_picker(message: Message):
await message.answer(
'Utc picker demo:\nTry changing the values and submitting\n'
'Only the valid timezones will be accepted, otherwise an error notification will be displayed',
reply_markup=await start_utc_picker()
)
@dp.callback_query(UtcPickerCallback.filter())
async def process_utc_picker_selection(callback: CallbackQuery, callback_data: CallbackData):
canceled, selected, utc_difference = await process_utc_picker(callback, callback_data)
if canceled:
await callback.message.answer('You have canceled utc picker selection')
elif selected:
await callback.message.answer(f'Selected value in minutes: {utc_difference}')
async def main():
bot = Bot(YOUR_API_TOKEN, default=aiogram.client.default.DefaultBotProperties(parse_mode=ParseMode.HTML))
await dp.start_polling(bot)
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
asyncio.run(main())
Localization
By default, all captions are in english.
To customize text captions, pass a dict with your translations to the start_utc_picker() function
It should have the following structure:
{ # do NOT alter this column # change values in this column to whatever language you need
'cancel_button': 'Cancel',
'confirm_button': 'Confirm',
'display_value': 'Time according to selected: ',
'err_msg_invalid': 'Not a valid timezone'
}
Metadata
Release files for aiogram-utcpicker 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiogram_utcpicker-0.1.5.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiogram_utcpicker-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / aiogram_utcpicker-0.1.5.tar.gz
| Download URL | aiogram_utcpicker-0.1.5.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
861c4a6d8770059fdf86a453012f00d6d59d326f754ba6cf51300d4cab4ca650
|
|
BLAKE2b-256 checksum How to use checksums |
82f9d314033e52bab1e9046a0e9eba9a06fab64b31b02dcc73c53370694e75ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 17, 2025.
Transparency logRelease files / aiogram_utcpicker-0.1.5-py3-none-any.whl
| Download URL | aiogram_utcpicker-0.1.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4338ce0409f0d07fd3740d278d9a23e97feae16a8a12d64e0afe9ada591f864a
|
|
BLAKE2b-256 checksum How to use checksums |
e4d17b2f8b96b2e09f82ae5e4f8f04f16a165c6e78b5a660e29547ee9acc18c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 17, 2025.
Transparency log