Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications? #607

Open
masterjg opened this issue Nov 11, 2024 · 1 comment
Open

Notifications? #607

masterjg opened this issue Nov 11, 2024 · 1 comment

Comments

@masterjg
Copy link

masterjg commented Nov 11, 2024

Is it possible to setup on download and on fail different notifications?

I think I can use Run external program on torrent completion and wire it up to ntfy server with curl. However not sure if this will get triggered even if torrent is not downloaded (failure)?

%N: Torrent name
%L: Category
%F: Content path (same as root path for multifile torrent)
%R: Root path (first torrent subdirectory path)
%D: Save path
%C: Number of files
%Z: Torrent size (bytes)
%I: Info hash

Doesn't look like I can get notification type (success/failure). So this only get's triggered on success then?

@Beersteak
Copy link

Beersteak commented Jan 29, 2025

Hey, i build myself a little script:

#⁠!/bin/bash

#⁠ Telegram Bot Token und Chat ID
TOKEN="XXX"
CHAT_ID="XXX"

#⁠ Eingabe-Parameter
TORRENT_NAME="$1"
CATEGORY="$2"
TORRENT_SIZE_BYTES="$3"

#⁠ Konvertiere Bytes in Gigabyte (mit 2 Nachkommastellen)
TORRENT_SIZE_GB=$(echo "scale=2; $TORRENT_SIZE_BYTES / 1073741824" | bc)
TORRENT_SIZE_MB=$(echo "scale=2; $TORRENT_SIZE_BYTES / 1048576" | bc)

if (( $(echo "$TORRENT_SIZE_GB < 1" | bc -l) )); then
TORRENT_SIZE="${TORRENT_SIZE_MB}MB"
else
TORRENT_SIZE="${TORRENT_SIZE_GB}GB"
fi

#⁠ Nachricht erstellen
TITLE="RDT-Client - Download finished"
MESSAGE="$TORRENT_NAME - $TORRENT_SIZE ($CATEGORY)"

#⁠ Sende die Nachricht an Telegram
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendMessage"
-d chat_id="$CHAT_ID"
-d parse_mode="HTML"
--data-urlencode "text=${TITLE} ${MESSAGE}" > /dev/null

With this, you can always add more stuff to do, like set permissions on files.

My Settings are looking like this:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants