Podpowiedź Events Notifications: Telegram Bot - Easy Guide Step-by-Step

Status
Brak możliwości dodawania odpowiedzi.

Silas Mariusz

rm -rf /
Help us, GOD!
5 Kwiecień 2008
10 318
33
2 634
153
40
Nowy Sącz
forum.qnap.net.pl
QNAP
TS-x77
Ethernet
1 GbE
  1. Open Telegram app and find @BotFather
    1644780000816.png

  2. Type /start and then /newbot to create new bot. Enter unique name for the bot.

  3. Once you do that, bot should respond to you with token ID. Ctrl+C this token.
    1644780138748.png

  4. Now create new channel on Telegram.
    1644780209375.png


    Find a name and hit Create
    1644780237964.png


  5. Edit channel and create discussion group for that channel:
    1644780330033.png

    Assign some name for that group and hit Create.
    1644780386035.png


  6. Now you have to return to @BotFather bot and set /setjoingroups enabled for your Bot.
    1644780497744.png

  7. Go back once to your Bot and edit his settings. Tell him to join your group.
    1644780581458.png

    Select group chat:
    1644780619150.png


  8. Open link: https://api.telegram.org/bot<YOUR-BOT-TOKEN>/getUpdates but replace it with your BOT Token.
    Find the chat id now. It's the one just around your chat group name:
    1644780846114.png

    NOTE: My one starts with minus at the begining and thats correct.

  9. Open FAQ SSH to your NAS and test Bot:
    curl 'https://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=<CHAT_ID>&text=test123'
    eg.
    Bash:
    curl 'https://api.telegram.org/bot1234567890:ABCDEFGH/sendMessage?chat_id=-1001756444567&text=test123'

  10. Now you should receive on telegram message from your Bot:
    1644781068807.png

    This mean your bot seems to be working correctly.

  11. Open Rdownload share and find script directory.

  12. Create new empty file telegram.sh and open it in Notepad.

  13. Ctrl+C and Ctrl+V to notepad this code snippet.
    (Make sure to replace your TOKEN and CHAT_ID variables)
    Bash:
    #!/usr/bin/rtorrent/bin/bash
    
    TOKEN=1234567890:ABCDEFGHIJ
    CHAT_ID=-0000111122223333
    
    cd `dirname $0`
    event_name=$(basename `pwd`)
    
    echo "${event_name}: $@"
    
    CMD_CURL=/usr/bin/rtorrent/bin/curl
    
    EVENT_TYPE=$1
    EVENT_HASH=$2
    EVENT_NAME=$3
    EVENT_PATH=$4
    EVENT_LABEL=
    [ "$5" == "" ] || EVENT_LABEL="${5}: "
    
    $CMD_CURL "https://api.telegram.org/bot${TOKEN}/sendMessage?chat_id=${CHAT_ID}&text=$EVENT_LABEL ${EVENT_TYPE}: $EVENT_NAME"
    
    exit 0

  14. Assign executable permission for telegram.sh. So from FAQ SSH run chmod +x on that script.
    Bash:
    chmod +x /share/Rdownload/scripts/telegram_bot.sh

    You can test from FAQ SSH telegram bot before:
    Bash:
    /share/Rdownload/scripts/telegram_bot.sh finished 0123456 Windows.12.Pro.Beta-ISO /share/Rdownload/complete/software software

    Result:
    1644781945482.png


  15. Now the last step is to decide what types of notification you want to receive. So move and place that file in any category you want, eg. event.download.finished:
    1644782133220.png


  16. That's all.
    Voila!
 
Status
Brak możliwości dodawania odpowiedzi.

Użytkownicy znaleźli tą stronę używając tych słów:

  1. TELEGRAM
  2. notification telegram