Skip to content

lambdamai/lambda-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.

Sparkline

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)
  • /export_users — bot sends you info about your users in .csv file (admin command)
  • /stats — show basic bot stats
  • /ask_for_location — log user location when received and reverse geocode it to get country, city, etc.

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

Create virtual environment (optional)

python3 -m venv dtb_venv
source dtb_venv/bin/activate

Install all requirements:

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

Create superuser to get access to admin panel:

python manage.py createsuperuser

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 instructions in our Wiki.

Deploy to Production

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


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages