Skip to content

My sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template

License

Notifications You must be signed in to change notification settings

JaimeTR/django-telegram-bot

 
 

Repository files navigation

django-telegram-bot

Sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template. Production-realy Telegram bot with database, admin panel and a bunch of useful built-in methods.

Check the example bot that uses the code from Main branch: t.me/djangotelegrambot

Features

Built-in Telegram bot methods:

  • /broadcast - send message to all users (admin command)
  • /stats - show basic bot stats
  • /ask_for_location - log user location when received and reverse geocode it to get country, city, etc.
  • Log users clicks to understand their behaviour

Check out our Wiki for more info.

How to run

Quickstart: Pooling & SQLite

The fastest way to run the bot is to run it in pooling mode using SQLite database without all Celery workers for background jobs. This should be enough for quickstart:

git clone https://github.com/ohld/django-telegram-bot
cd django-telegram-bot
pip install -r requirements.txt

Create .env file in root directory and copy-paste this:

DJANGO_DEBUG=True
DATABASE_URL=sqlite:///db.sqlite3
TELEGRAM_TOKEN=<ENTER YOUR TELEGRAM TOKEN HERE>

Run migrations to setup SQLite database:

python manage.py migrate

Run bot in pooling mode:

python run_pooling.py 

If you want to open Django admin panel which will be located on http://localhost:8000/tgadmin/:

python manage.py runserver

Run locally using docker-compose

If you like docker-compose you can check full instuctions in our Wiki.

Deploy to Production

Read Wiki page on how to deploy production-ready scalable Telegram bot using Dokku.


About

My sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.8%
  • Other 1.2%