Skip to content

Telegram is a bot store written in Python with Django + Aiogram frameworks. There is a Django Admin Panel with the ability to create, edit, delete categories, subcategories, products. The bot itself has admin and client commands. There is an authentication system and many more different commands.

Notifications You must be signed in to change notification settings

ddosmukhambetov/ecommerce-telegram-bot

Repository files navigation

About the project:

The Telegram bot store is written in Python using frameworks such as Django and Aiogram. It features a Django admin panel that allows creating/editing/deleting categories, subcategories, products, and users. The bot itself includes a registration system, login functionality, and a password reset option. User passwords are hashed and cannot be modified. The administrator will not be able to change a user's username or password; only the user can reset and change their password to a new one. After logging in, the user will have access to commands such as help, description, and catalog. When the catalog command is selected, an inline keyboard with product categories will appear, and after choosing a category, another inline keyboard with subcategories will show up. Then, the user will see the products. There are also commands for the administrator, such as broadcasting messages to users of the Telegram bot. Additionally, handlers for unknown or unclear commands and messages have been created for the bot. PostgreSQL is used as the database.


Installation instructions

1. Clone the repository

Copy the repository: git clone https://github.com/ddosmukhambetov/ecommerce-telegram-bot

2. Update keys, tokens and other settings

Rename the file: .env.example to .env Modify the variables in the .env file

3. Run the project

To start the project, you can use the following commands from the Makefile:

  • make all - Starts both the database and the application containers. It builds and runs them in detached mode (-d).
  • make create-superuser - Creates a superuser for the Django admin panel by running python manage.py createsuperuser
  • make app-logs - Shows the logs for the application container (app) in real-time.

4. Available commands

Here is a list of the available commands from the Makefile. Each command can be run manually or through make:

  • make all - Starts both the database and the application containers. It builds and runs them in detached mode (-d).
  • make all-down - Stops and removes both the database and the application containers.
  • make app - Builds and starts the application container (app) with Docker Compose.
  • make app-down - Stops and removes the application container (app), including orphaned containers.
  • make app-exec - Accesses the application container and opens a bash shell inside it.
  • make create-superuser - Creates a superuser for the Django admin panel by running python manage.py createsuperuser inside the application container.
  • make make-migrations - Creates migrations for the Django application by running python manage.py makemigrations inside the application container.
  • make migrate - Applies the migrations to the database by running python manage.py migrate inside the application container.
  • make collectstatic - Collects static files for the Django application by running python manage.py collectstatic --noinput inside the application container.
  • make run-bot - Starts the Telegram bot by running python manage.py bot inside the application container.
  • make app-logs - Shows the logs for the application container (app) in real-time.
  • make db - Builds and starts the database container (postgres) with Docker Compose.
  • make db-down - Stops and removes the database container (postgres), including orphaned containers.
  • make db-exec - Accesses the database container and opens a bash shell inside it.
  • make db-logs - Shows the logs for the database container (postgres) in real-time.

Telegram Bot Functionality

  • The bot has commands such as Sign Up, Sign In, Forgot Password, Help, Description, Catalog, Admin Menu, etc. Below is an example of how the bot works ⬇️

1. Authorization Commands (Sign Up, Sign In, Forgot Password)

authentification

This section implements a registration and login system. It also includes a "Forgot Password" function. When creating a password, it is hashed. The user can only create one profile, as their user ID will be assigned to the profile during registration. The "Sign Up" command first asks for a username, then checks if that username is already taken by another user. If it is, the bot will ask for a new, unique username. If the username is available, the bot proceeds to the password creation step. The password must contain at least one digit and only consist of Latin characters. If the user creates an incorrect password, they will be informed about the required password format. Once the password is successfully created, it is hashed, and the user is saved in the database, appearing in the Django admin panel. The administrator does not have the ability to edit user data.

2. Catalog Command (Categories, Subcategories, Products)

view products

The "Catalog" command is responsible for displaying categories, subcategories, and products. This command is only accessible once the user has logged in (authenticated). The image shows how this command works. There may be cases where a category or subcategory has no products; in such cases, the bot will inform the user that there are no products in that category/subcategory. Categories, subcategories, and products are sorted in the order they were added. These objects can be added, edited, and deleted in the Django admin panel. Additionally, the category model can be easily modified and made recursive, allowing for the creation of multiple subcategories under each category. This makes it flexible and scalable for organizing products in a hierarchical structure.

3. Default Commands (Help, Description, Admin -> Broadcast)

default commands

The "Default" commands section includes commands such as "Help," which provides assistance regarding the bot. There is also the "Description" command, which gives an overview of the Telegram store/bot. Additionally, there is an interesting command called "Admin." To use this command, the user must be on the list of Telegram administrators. Once the "Admin" button is pressed, the user is redirected to the admin menu. Currently, this menu contains one command: "Broadcast," along with buttons for "Home" and "Help." The "Help" button provides instructions for the administrator, including available commands and their descriptions. The "Home" button simply returns the user to the main menu. Thanks to the " Broadcast" command, the administrator can send messages to all registered users of the Telegram bot.


Django Admin Panel:

  • The project uses Django to handle models, the admin panel, relationships between models, and more.

1. Simple Home Page

simple main page

The simplest home page (HTML + Bootstrap). with a brief description of the project.


2. Admin Panel:

admin panel


3. Products in the Admin Panel:

creating_product

products_list

The product accepts a photo, title, description, price, whether it is published, as well as category and subcategory. The subcategory is linked to the category. All created products are displayed in the Django admin panel.


4. Categories in the Admin Panel:

creating_category

categories_list

The category accepts a name and description. All created categories are displayed in the Django admin panel.


5. SubCategories in the Admin Panel:

creating_subcategory

subcategories_list

The subcategory accepts the subcategory name, description, and also the category. All created subcategories are displayed in the Django admin panel.


6. Telegram Bot Users in the Admin Panel:

user

users_list

The user accepts the user ID, login, password, and whether they are registered. Users are created within the Telegram bot, and their data, such as the user ID and registration status, are automatically obtained. All users registered in the Telegram bot are displayed in the Django admin panel. The administrator does not have the ability to edit user data. User passwords are hashed.


Python Version Aiogram Version Django Version


About

Telegram is a bot store written in Python with Django + Aiogram frameworks. There is a Django Admin Panel with the ability to create, edit, delete categories, subcategories, products. The bot itself has admin and client commands. There is an authentication system and many more different commands.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published