All Projects → lugodev → ptb-django-cookiecutter

lugodev / ptb-django-cookiecutter

Licence: BSD-3-Clause License
A simple cookiecutter to create Python Telegram bots, wrapped with Django.

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects
Makefile
30231 projects

Projects that are alternatives of or similar to ptb-django-cookiecutter

cookiecutter-modern-pypackage
Cookiecutter template for a modern Python package.
Stars: ✭ 97 (+361.9%)
Mutual labels:  cookiecutter
flask-project-template
DO NOT FORK, CLICK "Use this template" - A github template to start a Flask Project - this uses github actions to generate your project based on the template.
Stars: ✭ 74 (+252.38%)
Mutual labels:  cookiecutter
django-naqsh
Naqsh is a bootstrapping tool for quickly creating production-ready Django web services.
Stars: ✭ 47 (+123.81%)
Mutual labels:  cookiecutter
qt-qml-project-template-with-ci
Template for a Qt/QML application with batteries included: GitHub C.I. for your QML app; automated gui testing with Xvfb; automatic code-format checks and more. Compiles for Desktop and Mobile (Linux, Mac, Windows, and Android).
Stars: ✭ 33 (+57.14%)
Mutual labels:  cookiecutter
cookiecutter-qt-app
A cookiecutter to create Qt applications, with translations and packaging
Stars: ✭ 29 (+38.1%)
Mutual labels:  cookiecutter
dst
yet another custom data science template via cookiecutter
Stars: ✭ 59 (+180.95%)
Mutual labels:  cookiecutter
minimal-flask-react
🍸 A minimal modern setup for flask and react
Stars: ✭ 120 (+471.43%)
Mutual labels:  cookiecutter
fastapi-starter
A FastAPI based low code starter: Async SQLAlchemy, Postgres, React-Admin, pytest and cypress
Stars: ✭ 97 (+361.9%)
Mutual labels:  cookiecutter
cookiecutter-pypackage-pythonic
Pythonic cookiecutter template for a Python package. See https://github.com/audreyr/cookiecutter.
Stars: ✭ 29 (+38.1%)
Mutual labels:  cookiecutter
cookiecutter-cpp-project
A cookiecutter for a C++ Project with lots of configuration options
Stars: ✭ 25 (+19.05%)
Mutual labels:  cookiecutter
cookiecutter-reveal.js
📊 A cookiecutter template for reveal.js presentations.
Stars: ✭ 15 (-28.57%)
Mutual labels:  cookiecutter
talkshow
A Call 4 Papers System - A simple base app as example of Flask Architecture
Stars: ✭ 56 (+166.67%)
Mutual labels:  cookiecutter
django-template
The ultimate Django template: production ready Django 3.2 with Docker, HTTPS and CI/CD using Github actions ‎️‍🔥
Stars: ✭ 20 (-4.76%)
Mutual labels:  cookiecutter
django-quick-start
Deploy a Django app on Render
Stars: ✭ 17 (-19.05%)
Mutual labels:  cookiecutter
yehua
Make a project in 1 minute from a project template but keep updating it forever
Stars: ✭ 22 (+4.76%)
Mutual labels:  cookiecutter
cookiecutter-pyms
Cookiecutter template for a Python microservice.
Stars: ✭ 49 (+133.33%)
Mutual labels:  cookiecutter
at-python-template
The official Python Project Template of Alexander Thamm GmbH
Stars: ✭ 34 (+61.9%)
Mutual labels:  cookiecutter
painless-continuous-delivery
A cookiecutter for projects with continuous delivery baked in.
Stars: ✭ 46 (+119.05%)
Mutual labels:  cookiecutter
hovercraft-slides
🍪 A template for new Hovercraft presentation projects (impress.js slides in reStructuredText)
Stars: ✭ 12 (-42.86%)
Mutual labels:  cookiecutter
jinja2-git
Jinja2 extension to handle git-specific things
Stars: ✭ 12 (-42.86%)
Mutual labels:  cookiecutter

PTB Django cookiecutter

PTB Django Cookiecutter

A simple cookiecutter to create Python Telegram bots, wrapped with Django.

Latest release Documentation Status Chat on Telegram

All Contributors

Based on this cool projects

What's inside

  • Django app with dev and prod environments.
  • Model to store bot users data.
  • Command to run the bot.
  • Admin web interface to see the bot data.
  • Authentication mechanism.
  • Some example callbacks.
  • Small engine to wrap the bot callbacks.
  • Ready for deployment using Docker via docker-compose.

Quickstart

Install the latest Cookiecutter if you haven't installed it yet:

pip install -U cookiecutter

Create your bot using this cookiecutter:

cookiecutter gh:lugodev/ptb-django-cookiecutter

This will clone the cookiecutter and launch a wizard to help you customize your new bot.

Installation

Bot engine folder structure 🤖

Once you have generated your new bot, you will get this folders structure:

  • src/bot: The bot source code.
    • core:
      • authentication.py: The authentication mechanism.
      • callbacks.py: Your callbacks here.
      • commands.py: Your commands here.
      • constants.py: Your conversation states, defined as constants.
      • conversation.py: Your conversation callbacks.
      • engine.py: The bot engine.
      • messages.py: The message filter callbacks.
      • models.py: Your bot models, defined as Django model classes.
      • renderers.py: Methods to render your messages.

Install your bot dependencies 📦

You have two primary options to install de bot Python dependencies: pip or Poetry. You can also use pipenv, virtualenvwrapper or another package managers. We recommend Poetry.

  1. Install dependencies using Poetry:

    curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
    cd src/bot
    poetry install
    

Tip (optional): Create these aliases on on your .bashrc or .zshrc, like this

```
alias poetry="python3 -m poetry"
alias django="poetry run ./dev.py"
alias djr="django runserver"
alias djm="django makemigrations && django migrate"
alias djmr="djm && djr"
```
  1. Or install your dependencies using pip.

    pip3 install -r requirements.txt
    

Initialize your bot environment variables

Place your env vars to the .env file (never push this file to the repo):

SECRET_KEY=your django random secret key
TELEGRAM_TOKEN=your bot token

Migrate database

This cookiecutter uses the Django ORM. First you must to make the model's migrations and then migrate them to database:

python3 src/bot/dev.py makemigrations
python3 src/bot/dev.py migrate

Start the bot

Start the bot (using the previously suggested alias, optional):

django runbot

Or using Poetry:

python3 -m poetry run src/bot/dev.py runbot

Or using Python:

python3 src/bot/dev.py runbot

Deploy your bot 🚀

Clone your repo to the server, and create this folder structure:

  • codebase: The repo itself, the source code.
  • storage: The place to store the DB and other persistant files.

Create and fill the ./codebase/.env file with the environment vars.

Then, deploy, using docker-compose:

cd codebase
docker-compose up --build -d

Bots created with this cookiecutter

None yet. Want to be the first? Submit your bot if it's open source.

Related videos

Crea tu bot de Telegram usando esta plantilla - PTB  + Django + Cookiecutter

Contributors

Thanks goes to these wonderful people (emoji key):


Carlos Lugones

Reinier Hernández

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].