Giter Site home page Giter Site logo

gamepad64 / python-telegram-bot-django-persistence Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 5.0 123 KB

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

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

License: MIT License

Python 100.00%
python django python-telegram-bot django-orm

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

python-telegram-bot-django-persistence

PyPI - Downloads All Contributors

Do you use python-telegram-bot with Django and want persistence without additional infrastructure? We've got you covered!

Quickstart

📥 Install package

If you are using poetry (and if not, please, consider using it 😉):

poetry add python-telegram-bot-django-persistence

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",
]

☢ Migrate your database

python manage migrate

🌟 Awesome! Use DjangoPersistence in python-telegram-bot

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

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Alexander Shishenko

💻 📖

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

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

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.

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

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

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

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

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.