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
For the bot to work, you first need the following things:
- ImageMagick (for cropping the screenshot using the
convert
tool and comparing the screenshots usingcompare
) capture-website-cli
to take the screenshots
- Clone the repository:
git clone https://github.com/iComputerfreak/NotifierBot
- Change into the telegram bot source code directory:
cd NotifierBot/NotifierBot
- Build the code:
swift build -c release
- Copy the executable into the main directory:
cp .build/release/Notifier ..
- Switch to the parent directory:
cd ..
- Download the telegram.sh script:
wget -O tools/telegram.sh https://raw.githubusercontent.com/fabianonline/telegram.sh/master/telegram
- Make the telegram script executable:
chmod +x tools/telegram.sh
- Repeat steps 2 - 5 for the urlwatcher script:
cd urlwatcher
swift build -c release
cp .build/release/urlwatcher .
cd ..
- Install the latest version of ImageMagick (version
7.1.1-36
or newer) by downloading the AppImage from ImageMagick.org - Move the downloaded
magick
file intotools
. - You may have to install FUSE to run the AppImage. (see here)
If you completed all the steps above, your install directory should look like this:
$ tree -L 2
.
├── LICENSE
├── Notifier
├── NotifierBot
│ ├── Package.resolved
│ ├── Package.swift
│ ├── Sources
│ └── Tests
├── README.md
├── Shared
│ ├── Package.swift
│ ├── README.md
│ ├── Sources
│ └── Tests
├── tools
│ ├── magick
│ ├── screenshot.sh
│ └── telegram.sh
└── urlwatcher
├── Package.swift
├── Sources
└── urlwatcher
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, use0 * * * *
(every time the minute is zero). - Save the 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
- 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.
- 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
- Start the service:
sudo service notifier start
- Optional: Enable automatic start on boot:
sudo service notifier enable