diff options
author | xkey <xkey@krebsco.de> | 2023-03-21 13:06:35 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2023-03-21 13:25:25 +0100 |
commit | 0061b8ac50e8b63a3cf1d741548ad1620a150fe5 (patch) | |
tree | 7429a50a2d7337c222f6c7762290ce6b67a54da0 /bin/ircsink | |
parent | bf5bf60e73b97d25a07818acfd7c345d8004659e (diff) |
ircsink: add support for NOTICE1.4.0
Diffstat (limited to 'bin/ircsink')
-rwxr-xr-x | bin/ircsink | 21 |
1 files 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 |