From 22b08b005b84af5244fd9eeca8ed6f656b901977 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 6 Oct 2022 23:12:08 -0400 Subject: [PATCH] Add working irl.sh script! --- README | 10 ++++++++++ irl.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 irl.sh diff --git a/README b/README index ed64632..2b4f2e8 100644 --- a/README +++ b/README @@ -2,3 +2,13 @@ irc-rss-listener ---------------- Ping IRC on updates to RSS feeds. + +Meant to be run in cron, irl.sh will read all the URLs +in /etc/irl/feeds and use sfeed(1) to parse them and +awk(1) to determine which ones are new. It then uses +nc(1) to connect to the IRC server running on localhost:6667 +(which happens to be the case for our garbash tilde). + +TODO: + +* Use getopt(1) to allow passing the server/channel to notify diff --git a/irl.sh b/irl.sh new file mode 100755 index 0000000..7f82c5b --- /dev/null +++ b/irl.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# irl -- irc-rss-listener +set -e + +die() { + echo "$*" 1>&2 + exit 1 +} + +notify() { + nc localhost 6667 </dev/null +NICK rssbot +USER rssbot rssbot localhost :rssbot +PRIVMSG #garbash :New post '$1' here: $2 +QUIT +EOM +} + +feeds=/etc/irl/feeds +ts=/tmp/irl.ts + +[ ! -e $feeds ] && die "Create $feeds to begin!" +command -v sfeed >/dev/null || die "sfeed not installed" + +if [ ! -e "$ts" ]; then + date "+%s" >"$ts" +fi + +last_run=$(cat $ts) + +for feed in $(cat "$feeds"); do + curl -sS "$feed" | sfeed | \ + awk -F' ' "\$1 > $last_run { print \$3, \$2 }" | + while read url subj; do + notify "$subj" "$url" + done +done + +# Update +date "+%s" >"$ts" -- libgit2 1.1.1