https://github.com/kingarthurwashere/django-telegram-bot
Telegram bot for this ecommerce django app
https://github.com/kingarthurwashere/django-telegram-bot
django-rest-framework docker-compose telegram-bot-api
Last synced: 2 months ago
JSON representation
Telegram bot for this ecommerce django app
- Host: GitHub
- URL: https://github.com/kingarthurwashere/django-telegram-bot
- Owner: kingarthurwashere
- License: apache-2.0
- Created: 2022-09-23T14:18:38.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-23T14:21:48.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T10:42:22.597Z (over 1 year ago)
- Topics: django-rest-framework, docker-compose, telegram-bot-api
- Language: Python
- Homepage:
- Size: 246 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# django-telegram-bot
Sexy Django + python-telegram-bot + Celery + Redis + Postgres + Dokku + GitHub Actions template. Production-ready Telegram bot with database, admin panel and a bunch of useful built-in methods.
[](https://stars.medv.io/ohld/django-telegram-bot)
### Check the example bot that uses the code from Main branch: [t.me/djangotelegrambot](https://t.me/djangotelegrambot)
## Features
* Database: Postgres, Sqlite3, MySQL - you decide!
* Admin panel (thanks to [Django](https://docs.djangoproject.com/en/3.1/intro/tutorial01/))
* Background jobs using [Celery](https://docs.celeryproject.org/en/stable/)
* [Production-ready](https://github.com/ohld/django-telegram-bot/wiki/Production-Deployment-using-Dokku) deployment using [Dokku](https://dokku.com)
* Telegram API usage in polling or [webhook mode](https://core.telegram.org/bots/api#setwebhook)
* Reverse geocode of user via [ArcGis](https://www.arcgis.com/)
* Export all users in `.csv`
* Native telegram [commands in menu](https://github.com/ohld/django-telegram-bot/blob/main/.github/imgs/bot_commands_example.jpg)
* In order to edit or delete these commands you'll need to use `set_my_commands` bot's method just like in [tgbot.dispatcher.setup_my_commands](https://github.com/ohld/django-telegram-bot/blob/main/tgbot/dispatcher.py#L150-L156)
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](https://github.com/kingarthurwashere/django-telegram-bot/wiki) for more info.
# How to run
## Quickstart: Polling & SQLite
The fastest way to run the bot is to run it in polling mode using SQLite database without all Celery workers for background jobs. This should be enough for quickstart:
``` bash
git clone https://github.com/kingarthurwashere/django-telegram-bot
cd django-telegram-bot
```
Create virtual environment (optional)
``` bash
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:
``` bash
DJANGO_DEBUG=True
DATABASE_URL=sqlite:///db.sqlite3
TELEGRAM_TOKEN=
```
Run migrations to setup SQLite database:
``` bash
python manage.py migrate
```
Create superuser to get access to admin panel:
``` bash
python manage.py createsuperuser
```
Run bot in polling mode:
``` bash
python run_polling.py
```
If you want to open Django admin panel which will be located on http://localhost:8000/tgadmin/:
``` bash
python manage.py runserver
```
## Run locally using docker-compose
If you like docker-compose you can check [full instructions in our Wiki](https://github.com/ohld/django-telegram-bot/wiki/Run-locally-using-Docker-compose).
## Deploy to Production
Read Wiki page on how to [deploy production-ready](https://github.com/ohld/django-telegram-bot/wiki/Production-Deployment-using-Dokku) scalable Telegram bot using Dokku.
----