This is a very simple Telegram bot that sends any argument passed from the command line to a designated chat using the Telegram API. It uses the teloxide
library.
It is intended to be used inside an already existing Alpine container without modifying the image, so it's statically compiled with target musl.
The bot is designed to be used for receiving notifications on Telegram for backups generated by the fantastic piece of software Restic, as Restic does not natively support Telegram as a notification medium.
To send a message using the bot, use the following command:
TOKEN=<your-telegram-bot-token> CHAT_ID=<your-chat-id> ./target/release/<your-bot-executable> "Your message here"
Replace <your-telegram-bot-token>
with your actual bot token and <your-chat-id>
with the ID of the chat you want to send messages to. Replace <your-bot-executable>
with the name of the executable file generated by Cargo.
For example:
TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11 CHAT_ID=000000000 ./target/release/telegram_bot "Test message from Restic."
TOKEN
: The token for your Telegram bot.CHAT_ID
: The ID of the chat where the bot will send messages.
This bot is ideal for use with backup notifications from Restic, personally I use Backrest as web-ui for managing and configuring Restic. since Backrest is deployed as a container, I needed to create a dependency-free executable that I could mount so that after the backups are finished, Restic can invoke it passing the result as argument.
This project is licensed under the MIT License. See the LICENSE file for more details.