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.
- Features
- Installation
- Configuration
- Usage
- Commands
- File Structure
- Contributing
- License
- Acknowledgements
- 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.
- A Raspberry Pi running a Debian-based OS (e.g., Raspbian).
- Python 3.11 installed.
- A Telegram account to create a bot.
-
Clone the Repository:
git clone https://github.com/GraveEaterMadison/Raspberry_pi_telegram_bot.git cd Raspberry_pi_telegram_bot
-
Install Required Dependencies:
pip install -r requirements.txt
-
Create a Telegram Bot:
- Message @BotFather on Telegram.
- Use the
/newbot
command to create your bot and get the API token.
-
Configure the Bot:
- Copy the
config.py
and add your bot token and other configuration details.
- Copy the
-
Run the Bot:
python main.py
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]
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.
You can add more commands by modifying the main.py file and defining new functions to handle those commands.
Here are some example commands you can use:
-
Start the bot:
/start
-
List all available command:
/help
-
Reboot the Raspberry Pi:
/reboot
-
Shutdown the Raspberry Pi:
/shutdown
-
execute command remotely:
/exec
-
Check CPU usage:
/cpu
-
Check ram usage:
/ram
-
Check disk space:
/disk
-
Turn on an LED connected to GPIO pin:
/gpio on
-
Turn off an LED connected to GPIO pin:
/gpio oFF
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
Contributions are welcome! Please fork this repository and submit a pull request with your improvements or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.
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!