We all know that "compile" time can be used for fun purposes:
Sometimes, however, you'd like to actually go and do something else while your code is compiling...
Like terminal bells, often used to notify when commands complete executing: bellbot notifies you using Telegram, to your phone!
- Create a bot and write down your token.
- Start a chat with your bot (you can find it in the search after it is created)
- Get your chat ID using
python-telegram-bot
as mentioned here, or if you're lazy use the following:curl https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates | python -c 'import json, sys; print(json.load(sys.stdin)["result"][0]["message"]["from"]["id"])'
. echo YOUR_TOKEN > ~/.config/bellbot; echo CHAT_ID >> ~/.config/bellbot
.cp bellbot.py ~/bin/bellbot
or any other directory in yourPATH
.
To test it, run run bellbot sleep 2
and you should get a message within a few seconds.
To make the file fully self-contained, you can store the token and chat ID in globals like this:
$ echo 'TOKEN = "YOUR_TOKEN"' >> bellbot.py $ echo 'CHAT_ID = "CHAT_ID"' >> bellbot.py
The script will use those variables, if found.