Raspberry Pi Telegram Bot
Remotely control your Raspberry Pi using Telegram, with support for GPIO, system commands, custom modules, and real-time interaction.
Raspberry Pi Telegram Bot
A versatile Telegram bot that runs on a Raspberry Pi, allowing you to control your Pi and interact with it remotely via Telegram. This project is designed to help you automate tasks, gather system information, and manage your Raspberry Pi from anywhere.
Table of Contents
- Features
- Installation
- Configuration
- Usage
- Commands
- File Structure
- Contributing
- License
- Acknowledgements
Features
- Remote Access: Control your Raspberry Pi remotely via Telegram.
- System Monitoring: Fetch real-time system information such as CPU usage, memory stats, and disk space.
- Automation: Set up custom commands to automate various tasks.
- Modular Design: Easily extend functionality by adding new modules to the bot.
- Secure: Uses Telegram's secure API for bot communication, with customizable access controls.
Installation
Prerequisites
- A Raspberry Pi running a Debian-based OS (e.g., Raspbian).
- Python 3.11 installed.
- A Telegram account to create a bot.
Steps
Clone the Repository:
git clone https://github.com/GraveEaterMadison/Raspberry_pi_telegram_bot.git cd Raspberry_pi_telegram_botInstall Required Dependencies:
pip install -r requirements.txtCreate a Telegram Bot:
- Message @BotFather on Telegram.
- Use the
/newbotcommand to create your bot and get the API token.
Configure the Bot:
- Copy the
config.pyand add your bot token and other configuration details.
- Copy the
Run the Bot:
python main.py
Configuration
Edit the config.py file to set your bot's configuration. Here's a breakdown of the essential settings:
- TOKEN: Your Telegram bot token provided by BotFather.
- AUTHORIZED_USERS: A list of Telegram user IDs allowed to interact with the bot.
TOKEN = 'YOUR_TELEGRAM_BOT_TOKEN'
AUTHORIZED_USERS = [123456789, 987654321]
Usage
Once the bot is up and running, you can start sending commands via Telegram. The bot will respond with the requested information or perform the specified task.
Commands
You can add more commands by modifying the main.py file and defining new functions to handle those commands.
Example Commands
Here are some example commands you can use:
Start the bot:
/startList all available command:
/helpReboot the Raspberry Pi:
/rebootShutdown the Raspberry Pi:
/shutdownexecute command remotely:
/execCheck CPU usage:
/cpuCheck ram usage:
/ramCheck disk space:
/diskTurn on an LED connected to GPIO pin:
/gpio onTurn off an LED connected to GPIO pin:
/gpio oFF
File Structure
Raspberry_pi_telegram_bot/
│
├── handlers
├── utils
├── main.py # Main bot script
├── config.py # Sample configuration file
├── requirements.txt # Python dependencies
├── README.md # This README file
└── LICENSE # License file
Contributing
Contributions are welcome! Please fork this repository and submit a pull request with your improvements or bug fixes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
This project was inspired by various online resources and tutorials that guide the creation of Raspberry Pi-based Telegram bots.
You can add custom commands by creating new handlers in the handlers/ directory.
Developed with ❤️ by GraveEaterMadison
You can copy and paste this content into your `README.md` file under the relevant sections. Let me know if you need further adjustments!