irc-rss-listener

IRC bot to post RSS updates for garbash
git clone git://git.alexkarle.com.com/irc-rss-listener
Log | Files | Refs | README

commit 22b08b005b84af5244fd9eeca8ed6f656b901977 (patch)
parent 2d02e5a2cdfd0be716d627227cbb734049af7e6f
Author: alex <alex@garbash.com>
Date:   Thu,  6 Oct 2022 23:12:08 -0400

Add working irl.sh script!

Diffstat:
MREADME | 10++++++++++
Airl.sh | 40++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)

diff --git 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 @@ -0,0 +1,40 @@ +#!/bin/sh +# irl -- irc-rss-listener +set -e + +die() { + echo "$*" 1>&2 + exit 1 +} + +notify() { + nc localhost 6667 <<EOM >/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"