This bot monitors websites and notifies you via Telegram, when they visually change.
The bot supports the following commands: /help Lists all commands and their descriptions /start Lists all commands and their descriptions /list Lists all entries including their areas /listurls Lists all entries including their websites /info <name> Shows more information about a specific entry /myid Returns your User ID /add <name> <URL> [x y width height] Adds a new website with an optional screenshot area to the list /remove <name> Removes an entry from the list /update <name> <x> <y> <width> <height> Updates the screenshot area of an entry /setdelay <name> <delay> Specifies a delay in seconds to wait after the website has been loaded /setcaptureelement <name> [html element] Specifies which HTML element to capture /setclickelement <name> [html element] Specifies which HTML element to click before taking the screenshot /setwaitelement <name> [html element] Specifies which HTML element to wait for before taking the screenshot /fetch <name> Takes a screenshot with the stored settings and sends it into this chat /fetchurl <URL> [x y width height] Takes a screenshot of the given website and settings and sends it into this chat /diff <name> Shows a picture highlighting the differences of the last website change, including extended information about the normalized cross correlation /mute <name> <hours> Prevents change notifications for the given entry and duration /unmute <name> Resumes notifications for the given entry /listall Lists all entries from all chats /check Performs a manual check if any monitored website changed /getpermissions [id] Returns the permission level of the author of the message, replied to or the user id provided /setpermissions <level> [id] Sets the permission level of the author of the message, replied to or the user id provided
Installation (Linux)
Prerequisites
For the bot to work, you first need the following things:
ImageMagick (for cropping the screenshot using the convert tool and comparing the screenshots using compare)
For the urlwatch script to be periodically executed, you have to create a cronjob for it.
Edit the crontab file: crontab -e
Add the following line at the end: */30 * * * * /path/to/your/install/directory/urlwatcher/urlwatcher This executes the script every 30 minutes. To execute it e.g. every hour, use 0 * * * * (every time the minute is zero).
Save the file
Setup
Create the BOT_TOKEN file
For the scripts and the bot to work, you have to put your bot token in a file called BOT_TOKEN in your installation directory.
cd to your installation directory
Create the file: echo YOUR_BOT_TOKEN > BOT_TOKEN
Give yourself admin permissions
Start the bot
Run the command /myid to retrieve your ID
Stop the bot
Add your ID to the permissions file: echo "YOUR_ID: admin" > /path/to/your/install/directory/NotifierBot/permissions.txt
Start the bot again and make sure, it worked by checking your permissions with the bot: /getpermissions YOUR_ID
If the bot returned your permission level as admin, everything worked and you now have admin permissions
Note: Modifying the permissions file requires a restart of the bot, but using /setpermissions <level> <userid> does not.
(Optional) Create a systemd service for the bot
Create the unit file: sudo nano /etc/systemd/system/notifier.service
Paste the following content (replace YOUR_USER_ACCOUNT with your linux user account name):
```
[Unit]
Description=Telegram Notifier Bot
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=YOUR_USER_ACCOUNT
WorkingDirectory=/path/to/your/install/directory/NotifierBot
ExecStart=/path/to/your/install/directory/NotifierBot/Notifier
[Install]
WantedBy=multi-user.target
3. Start the service: `sudo service notifier start`
4. Optional: Enable automatic start on boot: `sudo service notifier enable`
Notifier Telegram Bot
This bot monitors websites and notifies you via Telegram, when they visually change.
The bot supports the following commands:
/help
Lists all commands and their descriptions
/start
Lists all commands and their descriptions
/list
Lists all entries including their areas
/listurls
Lists all entries including their websites
/info <name>
Shows more information about a specific entry
/myid
Returns your User ID
/add <name> <URL> [x y width height]
Adds a new website with an optional screenshot area to the list
/remove <name>
Removes an entry from the list
/update <name> <x> <y> <width> <height>
Updates the screenshot area of an entry
/setdelay <name> <delay>
Specifies a delay in seconds to wait after the website has been loaded
/setcaptureelement <name> [html element]
Specifies which HTML element to capture
/setclickelement <name> [html element]
Specifies which HTML element to click before taking the screenshot
/setwaitelement <name> [html element]
Specifies which HTML element to wait for before taking the screenshot
/fetch <name>
Takes a screenshot with the stored settings and sends it into this chat
/fetchurl <URL> [x y width height]
Takes a screenshot of the given website and settings and sends it into this chat
/diff <name>
Shows a picture highlighting the differences of the last website change, including extended information about the normalized cross correlation
/mute <name> <hours>
Prevents change notifications for the given entry and duration
/unmute <name>
Resumes notifications for the given entry
/listall
Lists all entries from all chats
/check
Performs a manual check if any monitored website changed
/getpermissions [id]
Returns the permission level of the author of the message, replied to or the user id provided
/setpermissions <level> [id]
Sets the permission level of the author of the message, replied to or the user id provided
Installation (Linux)
Prerequisites
For the bot to work, you first need the following things:
convert
tool and comparing the screenshots usingcompare
)capture-website-cli
to take the screenshotsgit clone https://github.com/iComputerfreak/NotifierBot
cd NotifierBot/NotifierBot
swift build -c release
cp .build/release/Notifier ..
cd ..
wget -O tools/telegram.sh https://raw.githubusercontent.com/fabianonline/telegram.sh/master/telegram
chmod +x tools/telegram.sh
If you completed all the steps above, your install directory should look like this:
Adding the urlwatch script to crontab
For the urlwatch script to be periodically executed, you have to create a cronjob for it.
crontab -e
*/30 * * * * /path/to/your/install/directory/urlwatcher/urlwatcher
This executes the script every 30 minutes. To execute it e.g. every hour, use
0 * * * *
(every time the minute is zero).Setup
Create the BOT_TOKEN file
For the scripts and the bot to work, you have to put your bot token in a file called BOT_TOKEN in your installation directory.
cd
to your installation directoryecho YOUR_BOT_TOKEN > BOT_TOKEN
Give yourself admin permissions
/myid
to retrieve your IDecho "YOUR_ID: admin" > /path/to/your/install/directory/NotifierBot/permissions.txt
/getpermissions YOUR_ID
Note: Modifying the permissions file requires a restart of the bot, but using
/setpermissions <level> <userid>
does not.(Optional) Create a systemd service for the bot
sudo nano /etc/systemd/system/notifier.service
YOUR_USER_ACCOUNT
with your linux user account name): ``` [Unit] Description=Telegram Notifier Bot After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=YOUR_USER_ACCOUNT WorkingDirectory=/path/to/your/install/directory/NotifierBot ExecStart=/path/to/your/install/directory/NotifierBot/Notifier[Install] WantedBy=multi-user.target