/telegram-python-command-bot

Telegram Command Bot using Python to execute command remotely

Primary LanguagePythonMIT LicenseMIT

Telegram Command Bot

Overview

A simple Telegram bot that allows authorized users to execute predefined shell commands remotely.

Setup

  1. Install dependencies:
    pip install -r requirements.txt
  2. Copy config.example.py to config.py and update the values:
    cp config.example.py config.py
    • Set APP_NAME to your bot's name.
    • Replace BOT_TOKEN with your Telegram bot token.
    • Update ALLOWED_USERS with Telegram user IDs allowed to use the bot.

Usage

  • The bot listens for text messages from authorized users.
  • Allowed commands: ls, uptime, df, top, whoami
  • Unauthorized users will be denied access.
  • Output is truncated if it exceeds 4000 characters.

Running the Bot

python bot.py

Security Considerations

  • Only predefined commands can be executed.
  • User authentication is enforced through ALLOWED_USERS.
  • Do not allow unrestricted command execution to prevent security risks.

Disclaimer

Use this bot at your own risk. The author provides no warranty or liability for any potential issues or misuse. This project is intended for demo purposes only.

License

This project is licensed under the MIT License.