I often run heavy computations that take some time — usually couple of hours. I want to know when computation finishes as soon as possible. And I also use Telegram on daily basis. That's why I've created notify-tg:
./long-running-something && notify-tg 'Calculation successfull' || notify-tg 'Calculation failed'— receive notification about calculation status- from python — same as previous, but include constants in message:
subprocess.run(['notify-tg', 'calc finished for <pre>' + constants_prettified + '</pre>'])ExecStopPost=notify-tg 'Service "beautiful-service-name" failed!' in unit file
- Create file
notify-tg.tomlin your "config" directory (on Linux:$HOME/.config/), copy-paste contents ofexample-config.tomlthere - Create bot with @BotFather. Put token in the config
- Write something to your bot (
/start), so it can answer back later - Find out your
chat_id(you can do that with @showjsonbot) - Put this
idinto config - You can set
prefix— this line will be prepended to all your messages - Optionally, set/remove proxy (note on SOCKS in Features section)
- Do
cargo install --git https://github.com/Mr-Andersen/notify-tg && notify-tg "notify-tg has been successfully installed!" - When installation finishes, bot will send a message to you. Now when you can send message to yourself with
notify-tg "Message"
- Validate your config and connection to Telegram servers with running
notify-tgwithout arguments. On success it will show yougetMeresponse — basic info about your bot, such as its@username. -i|--include <FILE>flag for sending file captioned withMSG- Messages are html
- Literally, a feature: if you need your bot to support SOCKS proxy, compile it with corresponding feature