A shell command to notify you via Telegram for Linux, Mac and Windows
A shell function that notifies you via a Telegram bot.
It's useful when you need to compile a big project (like Qt 5.6) and want to get a notification when it finishes, but it can also be used to send messages through your bot!
First of all, if you haven't got a token (for example because you have never made a Telegram Bot) ask BotFather, just send /newbot and follow the procedure. Finally take the string after "Use this token to access the HTTP API:", it should appear similar to this:
318682111:AAFouzmHLujO17LY3VJUfhnp4yn8qLIo9Uw
If you don't know your Telegram's chat_id talk to @GiveChatId_bot and send to him /chatid, it will write your chat_id, so put it on the configuration instead of your_chat_id.
Or you could send a message to your own bot and then use this link. You should see then that your message has been received by your bot and is listed. Traversing the json you should find a chat key with an id key inside which value is exactly your chat_id.
Now the procedure differs based on which OS you're using.
You can either:
bash notify.sh
$ touch ~/.bashrc
) to call it without bash
first.If you're using Linux restart the terminal or run this to apply the changes:
source ~/.bashrc
If you're using MacOS edit (or create) a ~/.bash_profile and repeat the same procedure but replace all occurrencies of ~/.bashrc with ~/.bash_profile in the previous commands.
You can try these commands:
notify
sleep 3; notify "This is a test!"
the first command should send to you the default_message ("notify!"), the second will send you "This is a test!" after 3 seconds.
If you're using Windows you actually have three options:
.\notify.ps1 -c
This will load data from the default configuration file, the one you just created!.\notify.ps1 <chat_id> <bot_token>
A third argument could be provided to change message textIf you want to report something you could either: