Jarvis is a Python-based Telegram bot that can:
- Receive commands from Telegram
- Execute system commands on your Raspberry Pi
- Interact with existing applications
- Send responses back to Telegram
- Get your bot token:
- Message @BotFather on Telegram
- Create a new bot with
/newbot - Save the token
- Get your user ID:
- Message @userinfobot on Telegram to get your user ID
- Install and configure:
-
Install required python packages:
conda activate python311 pip3 install python-telegram-bot psutil
-
Set env variables:
export TELEGRAM_BOT_TOKEN=YOUR_TOKEN export AUTHORIZED_USERS="USER_IDs" export LOG_FILE="/home/rrocha/logs/jarvis.log"
-
Create logs directory:
mkdir -p /home/rrocha/logs
-
Test run
python3 jarvis.py start
-
Set up as systemd service:
-
Set up .env: Copy .env.example as .env and edit it for your values.
# Set secure permissions chmod 600 /home/rrocha/jarvis/.env chown rrocha:rrocha /home/rrocha/jarvis/.env # Make sure it's not tracked by git echo ".env" >> /home/rrocha/jarvis/.gitignore
-
Copy service file to systemd:
sudo cp /home/rrocha/jarvis/jarvis-wrapper.service /etc/systemd/system/jarvis-bot.service
-
Enable and start the service:
# Reload systemd configuration sudo systemctl daemon-reload # Enable service to start at boot sudo systemctl enable jarvis-bot # Start the service sudo systemctl start jarvis-bot
-
Service Management Commands Once set up, you can control your service with:
# Start the service sudo systemctl start jarvis-bot # Stop the service sudo systemctl stop jarvis-bot # Restart the service sudo systemctl restart jarvis-bot # Reload configuration (if the service supports it) sudo systemctl reload jarvis-bot # Check status sudo systemctl status jarvis-bot # View logs sudo journalctl -u jarvis-bot -f # View recent logs sudo journalctl -u jarvis-bot --since "1 hour ago"