No description
- Python 100%
Raspberry Pi control bot
Telegram bot for controlling a Raspberry Pi from a private admin chat.
Configuration
Create .env from .env.example:
BOT_TOKEN=123456:replace-me
ADMIN_TELEGRAM_IDS=100000001,100000002
Only users listed in ADMIN_TELEGRAM_IDS can use the bot. Handlers also require a private chat.
Actions
Volume up->wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+Volume down->wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-Mute->wpctl set-mute @DEFAULT_AUDIO_SINK@ togglePoweroff->sudo -n /usr/bin/systemctl poweroffReboot->sudo -n /usr/bin/systemctl reboot
The bot registers slash commands for private chats and shows a two-row reply keyboard:
Volume up,Volume down,MutePoweroff,Reboot
Run
uv run python main.py
Raspberry Pi permissions
Power actions require non-interactive root privileges. Add a sudoers rule for the user that runs the bot:
botuser ALL=(root) NOPASSWD: /usr/bin/systemctl poweroff, /usr/bin/systemctl reboot
Replace botuser with the actual service user. The bot uses sudo -n, so it will fail fast instead of waiting for a password prompt.