summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/irc-announce/default.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2021-09-28 22:48:17 +0200
committertv <tv@krebsco.de>2021-09-28 22:48:17 +0200
commited2c6bd9792afbc433ae4eb23f40e17b90420f99 (patch)
tree289de32dd7f58f46accf7ad25ed184db5aa45198 /krebs/5pkgs/simple/irc-announce/default.nix
parent20e358043546482acfa8c6134f095c1a64ef144d (diff)
parente151cfd3298120ec541987d4beb155e18335a0d8 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/5pkgs/simple/irc-announce/default.nix')
-rw-r--r--krebs/5pkgs/simple/irc-announce/default.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/krebs/5pkgs/simple/irc-announce/default.nix b/krebs/5pkgs/simple/irc-announce/default.nix
index 52cf12862..5797b3667 100644
--- a/krebs/5pkgs/simple/irc-announce/default.nix
+++ b/krebs/5pkgs/simple/irc-announce/default.nix
@@ -17,7 +17,8 @@ pkgs.writeDashBin "irc-announce" ''
IRC_PORT=$2
IRC_NICK=$3_$$
IRC_CHANNEL=$4
- message=$5
+ IRC_TLS=$5
+ message=$6
export IRC_CHANNEL # for privmsg_cat
@@ -34,6 +35,8 @@ pkgs.writeDashBin "irc-announce" ''
# privmsg_cat transforms stdin to a privmsg
privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; }
+ tls_flag() { if [ "$IRC_TLS" -eq 1 ]; then echo "-c"; fi }
+
# ircin is used to feed the output of netcat back to the "irc client"
# so we can implement expect-like behavior with sed^_^
# XXX mkselfdestructingtmpfifo would be nice instead of this cruft
@@ -51,6 +54,8 @@ pkgs.writeDashBin "irc-announce" ''
echo2 "USER $LOGNAME 0 * :$LOGNAME@$(hostname)"
echo2 "NICK $IRC_NICK"
+ awk 'match($0, /PING(.*)/, m) {print "PONG", m[1]; exit}'
+
# wait for MODE message
sed -n '/^:[^ ]* MODE /q'
@@ -67,5 +72,5 @@ pkgs.writeDashBin "irc-announce" ''
echo2 'QUIT :Gone to have lunch'
} < ircin \
- | nc "$IRC_SERVER" "$IRC_PORT" | tee -a ircin
+ | nc $(tls_flag) "$IRC_SERVER" "$IRC_PORT" | tee -a ircin
''