his.js

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

commit 5b581554ddd130ce83fc2763090d4f1bb0431074
parent afa66baccce41c233f19c77c45df718edddad251
Author: Daniel <23189912+danyisill@users.noreply.github.com>
Date:   Thu, 30 Jul 2020 00:14:12 +0300

Merge pull request #1 from Demonstrandum/master

Add start and stop scripts.
Diffstat:
A.gitignore | 2++
Mhis.js | 5++++-
Astart.sh | 7+++++++
Astop.sh | 8++++++++
4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +# JSON Store +posted.json diff --git a/his.js b/his.js @@ -1,5 +1,6 @@ var https = require('https'), posted = require('./posted.json'); -https.get('https://a.4cdn.org/his/threads.json', res => { + +const update = () => https.get('https://a.4cdn.org/his/threads.json', res => { var j = '' res.on('data', c => j += c) res.on('end', () => { @@ -15,3 +16,5 @@ https.get('https://a.4cdn.org/his/threads.json', res => { } }) }) + +setInterval(update, 300_000) // 5 min. diff --git a/start.sh b/start.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +node his.js & +echo "$!" > ./.pid + +echo "Bot started." + diff --git a/stop.sh b/stop.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +[ ! -f ./.pid ] && { echo "No PID file found."; exit 1; } + +PID="$(cat ./.pid)" +kill "$PID" + +echo "Bot killed ($PID)."