help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
telegram-bot
RSK World
telegram-bot
Telegram Bot - Python + Telegram Bot API + SQLite + PHP Dashboard + Bot Commands + Automation
telegram-bot
  • __pycache__
  • assets
  • .env1.5 KB
  • .gitignore845 B
  • CHANGELOG.md3.8 KB
  • LICENSE1.3 KB
  • LICENSE.txt1.3 KB
  • PROJECT_STATUS.md3.2 KB
  • README.md6.7 KB
  • RELEASE_NOTES.md5.5 KB
  • SETUP.md1.5 KB
  • bot.db0 B
  • bot.py3.9 KB
  • config.py773 B
  • dashboard.php8.1 KB
  • database.py7.5 KB
  • handlers.py19.5 KB
  • index.html6.6 KB
  • project_info.php1.5 KB
  • requirements.txt564 B
  • setup.py3.1 KB
  • utils.py8.9 KB
WHATS_NEW.mdPROJECT_STRUCTURE.mdindex.htmlCHANGELOG.mdbot.py
index.html
Raw Download
Find: Go to:
<!--
Project: Telegram Bot
Author: Molla Samser
Designer & Tester: Rima Khatun
Website: https://rskworld.in
Contact: hello@rskworld.in | +91 93305 39277
Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147
Copyright: © 2026 RSK World. All rights reserved.
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Telegram Bot - RSK World</title>
    <meta name="description" content="Telegram bot with command handling and interactive features. Built by RSK World.">
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        /* Fallback if external CSS fails */
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 0;
            background: #f0f2f5;
        }
    </style>
</head>

<body>

    <!-- Navigation -->
    <nav class="navbar">
        <div class="logo">
            <i class="fab fa-telegram text-info"></i> Telegram Bot
        </div>
        <div class="nav-links">
            <a href="#features">Features</a>
            <a href="#about">About</a>
            <a href="https://rskworld.in" target="_blank">RSK World</a>
            <a href="https://rskworld.in/contact.php" target="_blank" class="btn-primary">Contact Us</a>
        </div>
    </nav>

    <!-- Hero Section -->
    <header class="hero">
        <div class="hero-content">
            <h1>Advanced Telegram Bot Solution</h1>
            <p>A powerful, interactive Telegram bot with command handling, inline keyboards, and seamless file sharing.
                Perfect for your community or business.</p>
            <div class="cta-buttons">
                <a href="#" class="btn btn-primary">Start Bot</a>
                <a href="https://github.com/rskworld" target="_blank" class="btn btn-secondary">View Source</a>
            </div>
        </div>
        <div class="hero-image">
            <i class="fab fa-telegram"
                style="font-size: 200px; color: #fff; text-shadow: 0 10px 20px rgba(0,0,0,0.2);"></i>
        </div>
    </header>

    <!-- Features Section -->
    <section id="features" class="features">
        <h2 class="section-title">Key Features</h2>
        <div class="feature-grid">
            <div class="feature-card">
                <i class="fas fa-robot"></i>
                <h3>AI Assistant</h3>
                <p>Smart, context-aware AI conversations with the `/ai` command.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-stopwatch"></i>
                <h3>Task Reminders</h3>
                <p>Never miss a task. Set personal reminders with `/remind`.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-chart-pie"></i>
                <h3>Web Dashboard</h3>
                <p>Visualize your bot's growth and manage data via the PHP dashboard.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-microphone-alt"></i>
                <h3>AI Voice (TTS)</h3>
                <p>Convert text into realistic voice notes instantly using `/speak`.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-qrcode"></i>
                <h3>QR Code Generator</h3>
                <p>Generate QR codes instantly from text directly within the chat.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-chart-line"></i>
                <h3>Admin Dashboard</h3>
                <p>Track user statistics and broadcast messages to all users.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-database"></i>
                <h3>Persistent Database</h3>
                <p>Securely stores user data and feedback using SQLite.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-comments"></i>
                <h3>Feedback System</h3>
                <p>Collect structured feedback from your users effortlessly.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-terminal"></i>
                <h3>Command Handling</h3>
                <p>Robust parsing and handling of custom bot commands.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-keyboard"></i>
                <h3>Inline Keyboards</h3>
                <p>Interactive menus and buttons for better user engagement.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-file-upload"></i>
                <h3>File Sharing</h3>
                <p>Seamlessly upload and share documents and media.</p>
            </div>
            <div class="feature-card">
                <i class="fas fa-users"></i>
                <h3>Group Support</h3>
                <p>Works perfectly in both private chats and groups.</p>
            </div>
        </div>
    </section>

    <!-- Tech Stack -->
    <section class="tech-stack">
        <h2>Built With</h2>
        <div class="tech-icons">
            <span class="tech-tag">Python</span>
            <span class="tech-tag">Telegram API</span>
            <span class="tech-tag">python-telegram-bot</span>
            <span class="tech-tag">Node.js</span>
        </div>
    </section>

    <!-- Footer -->
    <footer>
        <div class="footer-content">
            <div class="footer-section">
                <h3>RSK World</h3>
                <p>Empowering developers with free resources and source code.</p>
                <div class="social-links">
                    <a href="#"><i class="fab fa-facebook"></i></a>
                    <a href="#"><i class="fab fa-twitter"></i></a>
                    <a href="#"><i class="fab fa-instagram"></i></a>
                </div>
            </div>
            <div class="footer-section">
                <h3>Contact</h3>
                <p>Email: hello@rskworld.in</p>
                <p>Phone: +91 93305 39277</p>
                <p>Address: Nutanhat, Mongolkote, Purba Burdwan, WB, India</p>
            </div>
        </div>
        <div class="copyright">
            <p>&copy; 2026 RSK World. All rights reserved. | Logic by Molla Samser | Design by Rima Khatun</p>
        </div>
    </footer>

    <script src="assets/js/script.js"></script>
</body>

</html>
168 lines•6.6 KB
markup
CHANGELOG.md
Raw Download

CHANGELOG.md

# Changelog - Telegram Bot Improvements

## Version 2.0 - Advanced Features Update

### 🐛 Bug Fixes
1. **Fixed PDF generation encoding issues** - Improved Unicode handling in PDF creation
2. **Improved error handling** - Added try-catch blocks throughout all Python files
3. **Database connection management** - Better error handling and connection cleanup
4. **Fixed duplicate imports** - Cleaned up import statements

### ✨ New Features Added

#### Utility Commands
- `/password [length]` - Generate secure random passwords
- `/shorten <url>` - Shorten URLs using TinyURL
- `/calc <expression>` - Mathematical calculator
- `/convert <value> <from> <to>` - Unit converter (km/miles, kg/lbs, celsius/fahrenheit, etc.)
- `/news [topic]` - Fetch latest news articles
- `/summarize <text>` - Summarize long text

#### Social Features
- `/leaderboard` - View top users by XP
- Enhanced `/profile` command with detailed statistics
- Improved XP and leveling system

#### File Handling
- Document upload handler - Process uploaded files
- Photo upload handler - Handle image uploads
- File information display

#### Admin Enhancements
- Enhanced `/stats` command with more detailed statistics
- Improved dashboard.php with:
- Additional statistics cards
- Top users leaderboard table
- Better data visualization

### 🔧 Improvements

#### Code Quality
- Added comprehensive error handling with try-catch blocks
- Improved logging system with file logging (`bot.log`)
- Better database error handling and connection management
- Enhanced code documentation

#### Configuration
- Added `.gitignore` file for better version control
- Updated `requirements.txt` with proper version pins
- Added configuration options for OpenAI and OpenWeatherMap APIs
- Enhanced config.py with additional settings

#### Database
- Added `get_leaderboard()` function
- Added `get_user_stats()` function for detailed user analytics
- Enhanced `get_stats()` with total messages and XP
- Improved error handling in all database functions

#### AI & API Integration
- OpenAI API integration for advanced AI responses (optional)
- OpenWeatherMap API integration for real weather data (optional)
- Fallback systems when APIs are not configured

#### Documentation
- Updated README.md with all new features
- Added comprehensive command list
- Added project structure documentation
- Added setup instructions for optional APIs

### 📦 Dependencies Added
- `pyshorteners==1.0.1` - URL shortening
- `openai==1.3.0` - OpenAI API integration
- Updated all existing dependencies with version pins

### 🎨 UI/UX Improvements
- Enhanced dashboard.php with more statistics
- Better error messages for users
- Improved help command with categorized commands
- Enhanced features command with detailed feature list

### 🔒 Security
- Added .gitignore to prevent committing sensitive files
- Better input validation in commands
- Safe mathematical expression evaluation

### 📊 Analytics
- User activity tracking improvements
- Enhanced statistics collection
- Leaderboard system
- User profile analytics

---

## Files Modified
- `bot.py` - Added new command handlers, improved logging
- `handlers.py` - Added 7 new command handlers, improved error handling
- `utils.py` - Added 7 new utility functions, improved existing ones
- `database.py` - Added new functions, improved error handling
- `config.py` - Added new configuration options
- `dashboard.php` - Enhanced with more statistics and leaderboard
- `README.md` - Comprehensive documentation update
- `requirements.txt` - Updated with new dependencies and version pins

## Files Created
- `.gitignore` - Git ignore rules
- `CHANGELOG.md` - This file

---

**All issues have been resolved and advanced features have been successfully added!**

© 2026 RSK World. All rights reserved.

bot.py
Raw Download
Find: Go to:

# Project: Telegram Bot
# Author: Molla Samser
# Designer & Tester: Rima Khatun
# Website: https://rskworld.in
# Contact: hello@rskworld.in | +91 93305 39277
# Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147
# Copyright: © 2026 RSK World. All rights reserved.

import logging
from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, CallbackQueryHandler, ConversationHandler, MessageHandler, filters
import config
import handlers
import database

# Enable logging
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO,
    handlers=[
        logging.FileHandler('bot.log'),
        logging.StreamHandler()
    ]
)
logger = logging.getLogger(__name__)

def main():
    """Start the bot."""
    # Initialize Database
    database.init_db()

    # Create the Application and pass it your bot's token.
    app = ApplicationBuilder().token(config.TOKEN).build()

    # Conversation Handler for Feedback
    feedback_handler = ConversationHandler(
        entry_points=[CommandHandler('feedback', handlers.start_feedback)],
        states={
            handlers.FEEDBACK_MESSAGE: [MessageHandler(filters.TEXT & ~filters.COMMAND, handlers.receive_feedback)],
        },
        fallbacks=[CommandHandler('cancel', handlers.cancel_feedback)],
    )

    # Add handlers
    app.add_handler(CommandHandler("start", handlers.start))
    app.add_handler(CommandHandler("help", handlers.help_command))
    app.add_handler(CommandHandler("features", handlers.features_command))
    app.add_handler(CommandHandler("contact", handlers.contact_command))
    app.add_handler(CommandHandler("qr", handlers.qr_command))
    app.add_handler(CommandHandler("speak", handlers.speak_command))
    app.add_handler(CommandHandler("translate", handlers.translate_command))
    app.add_handler(CommandHandler("pdf", handlers.pdf_command))
    app.add_handler(CommandHandler("profile", handlers.profile_command))
    app.add_handler(CommandHandler("ai", handlers.ai_command))
    app.add_handler(CommandHandler("remind", handlers.remind_command))
    app.add_handler(CommandHandler("weather", handlers.weather_command))
    app.add_handler(CommandHandler("export", handlers.export_command))
    
    # Advanced feature handlers
    app.add_handler(CommandHandler("password", handlers.password_command))
    app.add_handler(CommandHandler("shorten", handlers.shorten_command))
    app.add_handler(CommandHandler("calc", handlers.calc_command))
    app.add_handler(CommandHandler("convert", handlers.convert_command))
    app.add_handler(CommandHandler("news", handlers.news_command))
    app.add_handler(CommandHandler("summarize", handlers.summarize_command))
    app.add_handler(CommandHandler("leaderboard", handlers.leaderboard_command))
    
    # Message activity tracker (non-command messages)
    app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handlers.message_activity_tracker))
    
    # File handlers
    app.add_handler(MessageHandler(filters.Document.ALL, handlers.handle_document))
    app.add_handler(MessageHandler(filters.PHOTO, handlers.handle_photo))
    
    # Admin Handlers
    app.add_handler(CommandHandler("stats", handlers.stats_command))
    app.add_handler(CommandHandler("broadcast", handlers.broadcast_command))

    # Reminder Job (Check every 30 seconds)
    job_queue = app.job_queue
    job_queue.run_repeating(handlers.check_reminders, interval=30, first=10)
    
    app.add_handler(feedback_handler)
    app.add_handler(CallbackQueryHandler(handlers.button_handler))

    # Run the bot until the user presses Ctrl-C
    logger.info("Bot is starting...")
    print("Bot is running...")
    try:
        app.run_polling()
    except KeyboardInterrupt:
        logger.info("Bot stopped by user")
    except Exception as e:
        logger.error(f"Bot error: {e}")

if __name__ == '__main__':
    main()
99 lines•3.9 KB
python
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer