IDENA Node Watcher is a Telegram bot created by Telegram user @endogen for the IDENA community. The bot can monitor one or more IDENA nodes for you and notify you if one of them goes down.
The bot is build around the python-telegram-bot module and is polling based. Webhook mode is implemented but untested.
- Every command is a plugin
- Every plugin can be updated by sending the plugin file to the bot
- Restart or shutdown the bot via command
- Bot can be administered by more then one user
- Commands to backup the bot or view latest logs are available
- Add one or more nodes to be watched by the bot
- List all your watched node and verify that they are being watched
- Remove nodes that you don't want to watch anymore
- Change type of notification
- Telegram
Before starting up the bot you have to take care of some settings and add a Telegram API token. The configuration file and token file are located in the config
folder.
This file holds the configuration for the bot. You have to at least edit the value of ids. Everything else is optional.
- admin - ids: This is a list of Telegram user IDs that will be able to control the bot. You can also add multiple users if you want. If you don't know your Telegram user ID, get in a conversation with Telegram bot @userinfobot and if you write him (anything) he will return you your user ID.
- admin - notify_on_error: If set to
true
then all user IDs in the admin - ids list will be notified if some error comes up. - telegram - read_timeout: Read timeout in seconds as integer. Usually this value doesn't have to be changed.
- telegram - connect_timeout: Connect timeout in seconds as integer. Usually this value doesn't have to be changed.
- use_webhook: If
true
then webhook settings will be applied. Iffalse
then polling will be used. - webhook - listen: Required only for webhook mode. IP to listen to.
- webhook - port: Required only for webhook mode. Port to listen on.
- webhook - privkey_path: Required only for webhook mode. Path to private key (.pem file).
- webhook - cert_path: Required only for webhook mode. Path to certificate (.pem file).
- webhook - url: Required only for webhook mode. URL under which the bot is hosted.
This file holds the Telegram bot token. You have to provide one and you will get it in a conversation with Telegram bot @BotFather while registering your bot.
If you don't want to provide the token in a file then you have two other options:
- Provide it as a command line argument while starting your bot:
-tkn <your token>
- Provide it as an command line input (MOST SECURE):
--input-tkn
In order to run the bot you need to execute it with the Python interpreter. If you don't have any idea where to host the bot, take a look at Where to host Telegram Bots. Services like Heroku (free) will work fine. You can also run the script locally on your own computer for testing purposes.
This guide is assuming that you want to run the bot on a Unix based system (Linux or macOS).
You have to use at least Python 3.7 to execute the scripts. Everything else is not supported.
Install all needed Python modules
pip3 install -r requirements.txt
- First you have to make the script
run.sh
executable with
chmod +x run.sh
- Then you need to start the script with
./run.sh & exit
The recommended way to stop the bot is by using the bot command /shutdown
. If you don't want or can't use this, you can shut the bot down with:
pkill python3.7
which will kill every Python 3.7 process that is currently running.
/about - Show info about the bot
/backup - Backup whole bot folder
/help - Show all available commands
/log - Download current logfile
/restart - Restart the bot
/shutdown - Shutdown the bot
/watch - Add new node to watch
/list - Show all your watched nodes
/notify - Set or change notification settings
If you want to autocomplete available commands as you type in the chat with the bot, open a chat with Telegram bot @BotFather and execute the command /setcommands
. Then choose the bot you want to activate the autocomplete function for and after that send the list of commands with their descriptions. Something like this:
about - Show info about the bot
backup - Backup whole bot folder
help - Show all available commands
log - Download current logfile
restart - Restart the bot
shutdown - Shutdown the bot
watch - Add new node to watch
list - Show all your watched nodes
notify - Change notification settings