GamePad64 / python-telegram-bot-django-persistence

Package to use Django ORM as persistence engine in Python Telegram Bot

Home Page:https://pypi.org/project/python-telegram-bot-django-persistence/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python-telegram-bot-django-persistence

PyPI - Downloads All Contributors

Do you use python-telegram-bot or aiogram with Django and want storing FSM info without additional infrastructure?
We've got you covered!

Originally, this package supported only PTB, but we added aiogram, because it is awesome!

Quickstart

πŸ“₯ Install package

If you are using poetry (and if not, please, consider using it πŸ˜‰):

# For python-telegram-bot
poetry add "python-telegram-bot-django-persistence[ptb]"
# For aiogram
poetry add "python-telegram-bot-django-persistence[aiogram]"

Elif you are using pip, then just enter:

pip install python-telegram-bot-django-persistence

πŸ”Œ Add the app to your Django project

Then add python_telegram_bot_django_persistence into your INSTALLED_APPS in your settings file, like so:

INSTALLED_APPS = [
    ...
    "python_telegram_bot_django_persistence",  # For python-telegram-bot
    "aiogram_djpersistence",  # For aiogram
]

☒ Migrate your database

python manage migrate

🌟 Awesome! Now use it in your bot!

python-telegram-bot

updater = Updater(bot=bot, use_context=True, persistence=DjangoPersistence())

aiogram

dp = Dispatcher(storage=DjangoStorage())

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Alexander Shishenko
Alexander Shishenko

πŸ’» πŸ“–
Raman Hutkovich
Raman Hutkovich

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Package to use Django ORM as persistence engine in Python Telegram Bot

https://pypi.org/project/python-telegram-bot-django-persistence/

License:MIT License


Languages

Language:Python 100.0%