From 0061b8ac50e8b63a3cf1d741548ad1620a150fe5 Mon Sep 17 00:00:00 2001 From: xkey Date: Tue, 21 Mar 2023 13:06:35 +0100 Subject: ircsink: add support for NOTICE --- bin/ircsink | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/ircsink b/bin/ircsink index 3d1b0df..478be89 100755 --- a/bin/ircsink +++ b/bin/ircsink @@ -11,6 +11,9 @@ # DESCRIPTION # ircsink sends lines from standard input to the specified IRC target. # +# --command=NOTICE (default: PRIVMSG) +# Whether a PRIVMSG or NOTICE is sent. +# # --help # # --nick=NICK (default: the system's host name) @@ -39,7 +42,7 @@ # --server=SERVER # # --target=TARGET -# The target for receiving PRIVMSGs. +# The target for receiving messages. # Can be either a channel's or a user's name. # @@ -50,11 +53,12 @@ main() {( exec 3<&0 _args=$(getopt -n "$0" -s sh \ - -l help,nick:,port:,sasl:,sasl-pass:,sasl-user:,secure,server:,target: \ + -l command:,help,nick:,port:,sasl:,sasl-pass:,sasl-user:,secure,server:,target: \ -- "$0" "$@") eval set -- "$_args" unset _args + command= help= nick= port= @@ -66,6 +70,7 @@ main() {( target= while :; do case $1 in + --command) command=$2; shift 2;; --help) help=1; shift;; --nick) nick=$2; shift 2;; --port) port=$2; shift 2;; @@ -105,6 +110,10 @@ main() {( exit 1 fi + if test -z "$command"; then + command=PRIVMSG + fi + if test -z "$nick"; then nick=$(hostname) fi @@ -156,9 +165,9 @@ main() {( }' } - # privmsg_cat transforms stdin to a privmsg - privmsg_cat() { - awk -v target="$target" '{ print "PRIVMSG "target" :"$0 }' + # command_cat transforms stdin to a privmsg or notice + command_cat() { + awk -v command="$command" -v target="$target" '{ print command" "target" :"$0 }' } ircat() { @@ -218,7 +227,7 @@ main() {( echo2 "JOIN $target" fi - privmsg_cat <&3 \ + command_cat <&3 \ | cat2 if is_channel "$target"; then -- cgit v1.2.3