MRPYWEB

Website, Web Application & Business Systems Development
Back to Portfolios
فوروارد بات - سامانه مدیریت پیام‌های تلگرام

Forward Bot - Telegram Message Management System

Forward Bot is a comprehensive Telegram message management system built with Django 5.2 framework and aiogram library. This project enables broadcasting messages to Telegram users and groups, managing channel links, aut…

Overview

About the Project

Forward Bot is a comprehensive Telegram message management system built with Django 5.2 framework and aiogram library. This project enables broadcasting messages to Telegram users and groups, managing channel links, automatically saving user information on bot start, and managing Telegram user profiles. The system features a dedicated admin panel with two-factor authentication (2FA) and customer relationship management (CRM). The Telegram bot runs simultaneously with the Django server in a separate thread, and messages are sent with specific time intervals to avoid Telegram restrictions.

Case Study

Project Case Study

Challenges, solutions, outcomes, technical highlights, architecture, and project scale.

⚡

Challenges

- Need to broadcast messages to many Telegram users without bot being blocked
- Managing Telegram message rate limits
- Running Telegram bot and Django server simultaneously in one project
- Automatically saving user information on bot start
- Need for two-factor authentication for admin panel
- Dynamic management of channel and group links
- Sending image and text simultaneously to users and groups
- Integrating CRM system with Telegram bot

💡

Solutions

- Using aiogram for async Telegram bot management
- Running bot in a separate thread with AppsConfig.ready()
- Saving chat_id and username in Users_link model with get_or_create
- Implementing background sending with asyncio and threading
- Using 5-second intervals between sends to avoid rate limits
- Implementing 2FA with pyotp for enhanced security
- Using custom CustomUser to store Telegram info
- Implementing admin panel with simple HTML forms
- Using persiantools for Jalali date display

📚

Outcomes

- Complete Telegram message management system
- Broadcasting to users and groups with rate limit management
- Automatic user saving on first bot interaction
- Secure admin panel with 2FA
- Successful integration of Telegram bot with Django
- Support for image and text sending
- Complete CRM system for user management

🔧

Technical Highlights

- Django 5.2.6 and Python 3
- MySQL database with pymysql
- aiogram 3.28 for Telegram bot (async)
- python-telegram-bot 22.3 as backup
- Django REST Framework 3.16 for API
- django-filter for data filtering
- django-environ and python-decouple for settings management
- pyotp for two-factor authentication
- persiantools for Jalali date
- Running bot in separate thread with AppsConfig
- Managing Telegram rate limits with 5-second intervals
- Custom CustomUser for storing telegram_id and chat_id
- Implementing 2FA with TOTP

🏗️

Architecture

Forward Bot is built on Django's MVT (Model-View-Template) architecture and consists of two main applications:

1. crm: Responsible for user management, links, and admin panel
- CustomUser model with telegram_id, telegram_username, phone_number
- Chanel_link model for storing channel links
- Users_link model for storing user chat_id
- login_view, sendmassage, sendgroupmessage views
- group_links, users_link views for link management

2. telegram_bot: Responsible for running Telegram bot
- bot.py file with aiogram Dispatcher
- AppsConfig.ready() to run bot in separate thread
- BroadcastMessage model for storing broadcast messages
- TrainingVideo model for training videos
- /start handler for automatic user saving

The project runs in DEBUG mode and uses SQLite for development and MySQL for production.

📐

Project Scale

- 2 main applications (crm, telegram_bot)
- 5 main data models
- Telegram bot system with aiogram
- Dedicated admin panel
- 2FA system
- Broadcasting to users and groups
- Channel link management
- Custom CustomUser
- Async/threading integration

Stack

Technologies

Django HTML/CSS JavaScript Python
Categories

Categories

Office Automation CRM System
Industry

Industry

Information Technology & Communication
Scope

Scope

Telegram Bot & CRM System Development
Statistics

Project Statistics

11
👁️ Views
0
❤️ Likes
0
⬇️ Downloads
0
⭐ Rating
Metrics

Custom Metrics

Key performance indicators of the project

5 Data Models
2 Applications
Team

Project Team

People who collaborated on this project

حسن کاظمی
Hasan Kazemi
Full Stack Developer

Have a similar project in mind?

If you need collaboration for developing a website, CRM, ERP, or a custom system, I'd be happy to discuss your project.

Start a Project