Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aiogram-utcpicker

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aiogram-utcpicker

An inline tool for selecting valid timezone differences to UTC

  • 0.1.2
  • PyPI
  • Socket score

Maintainers
1

aiogram_utcpicker

pip install aiogram-utcpicker

UTC selection tool for aiogram3 telegram bots img.png

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:

{'cancel_button': 'Cancel', 
'confirm_button': 'Confirm',
'display_value': 'Time according to selected: ',
'err_msg_invalid': 'Not a valid timezone'}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc