• 돌아가기
  • 아래로
  • 위로
  • 목록
  • 댓글
기타

docker로 큐빗토렌트 돌리는데 텔레그램 알림 받는거 설정법을 알수있을까요?

쑥GOD 186

0

5

기존에 클리앙에서 게시글이 있었는데

이번에 클리앙사태 벌어지면서 글 삭제하신거 같더라구요 ㅠ

curl -d 이런 문구로 시작해서 텔레그램 봇 이용해서 알림 받는방법이 있었는데

 

구글을 아무리 뒤져봐도 못찾겠습니다 ㅠ

image.png.jpg

 

혹시 아시는분 계실까요.....?

 

신고공유스크랩
5
1등
일회용아이 2024.04.12. 12:55
저같은 경우에는 스샷처럼 외부 프로그램으로
그냥 sh 만들어서 텔래그램 알림 시키고 있네요.
2등
WeetLies 2024.04.12. 13:01
https://www.appletong.com/entry/curl-%EB%AA%85%EB%A0%B9%EC%96%B4%EB%A5%BC-%ED%86%B5%ED%95%B4-telegram-bot%EC%97%90-%EB%A9%94%EC%84%B8%EC%A7%80-%EC%A0%84%EC%86%A1
이부분 중간에 curl -k api주소 부분 참고하시면 될꺼같네엽
profile image 3등
TryK 2024.04.12. 13:03
윗분 말처럼 텔레그램 봇으로 메세지 쏴줄수 있는 스크립트 파일을 만드셔서
매개변수 넘겨주시면 될거 같습니다
나린이2 2024.04.12. 17:09
트랜스미션 사용중입니다.
아래 스크립트를 토렌트다운 완료시 실행시켜 시드 삭제와 텔레그램 전송받고 있습니다.

#!/bin/sh
SERVER="9091 --auth 트랜스미션아이디:트랜스미션비밀번호"
TORRENTLIST=`transmission-remote $SERVER --list | sed -e '1d;$d;s/^ *//' | cut --only-delimited --delimiter=" " --fields=1`
########################################################
#telegram 설정
KEY="텔레그램키입력"
CHATID="텔레그램 챗아이디입력"
TEXT="$TR_TORRENT_NAME 다운완료 - 텔레그램으로 전송될 메시지입니다."
########################################################
#완료된 시드 삭제
for TORRENTID in $TORRENTLIST
do
DL_COMPLETED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "Percent Done: 100%"`
STATE_STOPPED=`transmission-remote $SERVER --torrent $TORRENTID --info | grep "State: Seeding\|Stopped\|Finished\|Idle"`
if [ "$DL_COMPLETED" ] && [ "$STATE_STOPPED" ]; then
transmission-remote $SERVER --torrent $TORRENTID --remove
fi
done
########################################################
#telegram 설정
/usr/bin/curl -d "chat_id=$CHATID&text=$TEXT" https://api.telegram.org/bot$KEY/sendMessage
########################################################
장난치다가 2024.04.13. 08:30

제가 쓰는 스크립트 공유드립니다.
qBittorrent에서 사용 중이고 알람보낼 것을 선택해서 하는 것으로 만들어봤습니다.
스크립트로 저장하셔서
"토렌트 완료 시 외부 프로그램 실행" 체크
sh /scripts/qbittorrent_postprocess.sh "%N" "%I" "%J"
처럼 위치를 지정해주셔서 매개변수도 넣어주시면 됩니다.
해당 스크립트는 완료 시 해당 토렌트 삭제되며, Plex때문에 권한 설정까지 되는 스크립트입니다.
저는 도커로 qBittorrent를 돌리고 있어서 리스트 삭제도 도커 내부에서 처리되어 도커를 사용하지 않으실 경우는 URL 변경이 필요할 수 있습니다.

 

 

image.png.jpg

 

#!/bin/bash

# select sender
SENDER="discord" # all, telegram, discord # 여기에 all 또는 telegram 또는 discode 에 따라 알람을 설정할 수 있습니다.

# Bot token
BOT_TOKEN="telegram bot token" # 텔레그램 봇의 토큰을 넣어주세요

# Get variables from qbittorrent
TORRENT_NAME="$1"

send_telegram_notification() {
# Your chat id
local CHAT_ID="telegram chat id" # 텔레그램에 전송할 Chat id를 넣어주세요

local URL="https://api.telegram.org/bot${BOT_TOKEN}"
local MSG_URL="${URL}/sendMessage?chat_id=${CHAT_ID}&"

# Prepares the request payload
chat_id=${CHAT_ID}&text=${MESSAGE}&parse_mode=HTML"

curl --data-urlencode "text=${MESSAGE}" --data "&parse_mode=HTML" ${MSG_URL}

}

print_consol() {
# Prints a info message in the console
echo "[$2] Download completed. $1 notification sent."
}

DISCORD_URL="Discord -> Create channel -> Edit channel -> Integrations -> New Webhook -> Copy Webhook URL -> paste Webhook URL"

send_discord_notification() {
local message=$1

local payload=$(cat <<EOF
{
"embeds": [{
"title": "Download completed",
"author": {
"name": "qBittorrent",
"icon_url": "https://i.imgur.com/6LTKLgZ.jpg"
},
"color": "7506394",
"description": "${message}"
}]
}
EOF
)

curl -H "Content-Type: application/json" -X POST -d "${payload}" ${DISCORD_URL}
}

if [[ ${SENDER} == "all" ]]; then

send_telegram_notification "${TORRENT_NAME}"
sleep 1s
send_discord_notification "${TORRENT_NAME}"
print_consol "Telegram & Discord" "${TORRENT_NAME}"

elif [[ ${SENDER} == "telegram" ]]; then

send_telegram_notification "${TORRENT_NAME}"
print_consol "Telegram" "${TORRENT_NAME}"

elif [[ ${SENDER} == "discord" ]]; then

send_discord_notification "${TORRENT_NAME}"
print_consol "Discord" "${TORRENT_NAME}"

else

echo "${TORRENT_NAME} download completed."

fi

sleep 1s

# 다운로드 완료 시 토렌트 리스트에서 지움
URL=127.0.0.1:8080
USER=ID # qbittorent 로그인 ID
PASS=password # qbittorrent 로그인 비밀번호
HASHv1="$2"
HASHv2="$3"

COOKIE=$(curl --silent --anyauth --output /dev/null --cookie-jar - --header 'Referer: http://'${URL} \
--data 'username='${USER}'&password='${PASS} \
http://${URL}/api/v2/auth/login \
| grep HttpOnly | sed 's/.*0\t//g' | sed 's/\t/=/g')

API_INFO="/api/v2/torrents/info"
API_DELETE="/api/v2/torrents/delete"

#DL_COMPLETED=curl http://${URL}${API_INFO} --cookie ${COOKIE} -d 'filter=completed'
curl http://${URL}${API_DELETE} --cookie ${COOKIE} -d 'hashes='${HASHv1} -d 'deleteFiles=false'

sleep 1s

# 다운로드 완료된 폴더에 plex에서 볼 수 있는 권한 설정 "/downloads/" 디렉터리는 환경에 맞게 수정 필요
chmod o+rwx -R /downloads/

댓글 쓰기 권한이 없습니다. 로그인

취소 댓글 등록

cmt alert

신고

"님의 댓글"

이 댓글을 신고하시겠습니까?

댓글 삭제

"님의 댓글"

삭제하시겠습니까?


목록

공유

facebooktwitterpinterestbandkakao story