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
  • 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
bot.py
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

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