his.js

Telegram bot for /his/ threads.
git clone git://git.knutsen.co/his.js
Log | Files | Refs | LICENSE

commit e31b19fd44e7fc0f51968ddfc0ae87e8afcbb707
parent dcb70728ab17ca947d5785b58302a8830c601bb3
Author: danyisill <danyisill@users.noreply.github.com>
Date:   Mon,  3 Aug 2020 01:39:56 +0300

lit

Diffstat:
Mhis.sh | 13+++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/his.sh b/his.sh @@ -1,24 +1,24 @@ #!/usr/bin/bash [ -z "$HIS_BOT_TOKEN" ] && { echo "No API token in ENV!"; exit 1; } -[ ! -f ./posted ] && touch posted update () { - curl -s 'https://a.4cdn.org/his/threads.json' \ + [ ! -f ./"$1.posted" ] && touch "$1.posted" + curl -s "https://a.4cdn.org/$1/threads.json" \ | tr n '\n' \ | tr -cd '1234567890:\n' \ | sed 1d \ | while read -r thread; do if [[ "$(cut -d : -f 4 <<< "$thread")" -gt 50 ]]; then echo "--- Checking if thread already exists... ---" - if grep -q "$(cut -d : -f 2 <<< "$thread")" posted; then + if grep -q "$(cut -d : -f 2 <<< "$thread")" "$1.posted"; then echo " -> Exists, not posting." continue else echo " -> Posting new message!" cut -d : -f 2 <<< "$thread" \ - | tee -a posted \ - | xargs -I {} curl -s "https://api.telegram.org/bot$HIS_BOT_TOKEN/sendMessage?chat_id=@his50replies&text=https://boards.4channel.org/his/thread/{}" >/dev/null + | tee -a "$1.posted" \ + | xargs -I {} curl -s "https://api.telegram.org/bot$HIS_BOT_TOKEN/sendMessage?chat_id=@$2&text=https://boards.4channel.org/$1/thread/{}" >/dev/null fi sleep 0.25 fi @@ -27,7 +27,8 @@ update () { for (( ; ; )); do echo "=== Checking. ===" - update + update his his50replies + update lit lit50replies sleep 300 # 5 min. done