Giter Club home page Giter Club logo

python-telegram-bot-django-persistence's Introduction

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!

python-telegram-bot-django-persistence's People

Contributors

allcontributors[bot] avatar artrey avatar dependabot[bot] avatar gamepad64 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

python-telegram-bot-django-persistence's Issues

Как это должно работать?

Строки в описании:
updater = Updater(bot=bot, use_context=True, persistence=DjangoPersistence())
для понимания нубаса было недостаточно(

Объекты в джанго создаются с пустыми _namespase, а в data всегда {} - как это должно работать, может быть есть простой пример сохранения сообщений пользователя?

Adding import statement for DjangoPersistence

Bro..
Thanks for creating such an amazing application:)

Don't we need to import the DjangoPersistence class from the persistence module before adding it as an argument for the Updater object.

Value Exception on storing arbitrary callback data

I have encountered an exception when tried to use the python-telegram-bot-django-persistence library. When was initializing the ptb bot Updater class with argument persistence=DjangoPersistence(store_callback_data=True), trigger of any handler was leading to the following exception. It seems to happen when library method DjangoPersistence.update_callback_data tries to store default CDCData to the database, because according to the model.CallbackData the value must be a valid JSON.

I have tried to fix the issue by overriding the function and passing default data like defaults={'data':data}, but this introduced exception during the data fetch with get_callback_data 😢

Versions of the used libraries:

  • django==4.1.3
  • python-telegram-bot==13.14
  • python-telegram-bot-django-persistence==0.1.7

Example of the exception:
LA_tMSC15OI

Package is unavailable at PyPI

$ pip install python-telegram-bot-django-persistence
ERROR: Could not find a version that satisfies the requirement python-telegram-bot-django-persistence (from versions: none)
ERROR: No matching distribution found for python-telegram-bot-django-persistence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.