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 1dde19b099be318b5e03ff7782cf7a31bc4ee76b (patch)
parent 00d849e516d237161c4962bacbd5b2aae109bec9
Author: alex <alex@garbash.com>
Date:   Fri,  7 Oct 2022 21:31:25 -0400

Use getopt(1) to allow specifying channel to ping

Diffstat:
MREADME | 4----
Mirl.sh | 36+++++++++++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/README b/README @@ -9,7 +9,3 @@ diff(1) to determine which ones are new (since the last run). 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 @@ -7,11 +7,41 @@ die() { exit 1 } +usage() { + die 'Usage: irl.sh -c CHANNEL [-h HOST] [-p PORT]' +} + +port=6667 +host=localhost + +args=$(getopt c:h:p: $*) +if [ $? -ne 0 ]; then + usage +fi + +set -- $args +while [ $# -ne 0 ]; do + case "$1" + in + -c) + channel="$2"; shift; shift;; + -h) + host="$2"; shift; shift;; + -p) + port="$2"; shift; shift;; + --) + shift; break;; + esac +done + +[ -z "$channel" ] && usage + + notify() { - nc localhost 6667 <<EOM >/dev/null + nc $host $port <<EOM >/dev/null NICK rssbot -USER rssbot rssbot localhost :rssbot -PRIVMSG #garbash :New post '$1' here: $2 +USER rssbot rssbot $host :rssbot +PRIVMSG #$channel :New post '$1' here: $2 QUIT EOM }