marvvin

IRC bot
Log | Files | Refs | README | LICENSE

commit ec1cadc772b6d5e6987ea22c7b69fbb721bd85a2
parent eb9854faa41e3a544e9dabb827f4d62cced8348c
Author: Hayden Hamilton <hayden@haydenvh.com>
Date:   Sat, 10 Apr 2021 23:58:01 +0100

functions.sh: add piped versions of send_*

Diffstat:
Mfunctions.sh | 35+++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+), 0 deletions(-)

diff --git a/functions.sh b/functions.sh @@ -36,6 +36,14 @@ send_raw(){ printf '%s\r\n' "$(echo "$@" | tr '\n\r' ' ')" >> $input } +# | psend_raw(void) +psend_raw(){ + while IFS= read -r pline + do + printf '%s\r\n' "$(echo "$pline" | tr '\n\r' ' ')" >> $input + done +} + # match_msg(regex, command...) match_msg(){ regex="$1" && shift @@ -61,12 +69,30 @@ send_msg(){ printf "PRIVMSG %s :%s\r\n" "$dest" "$sline" >> $input } +# | psend_msg(dest) +psend_msg(){ + dest=$(echo "$1" | tr -d '\r\n') + while IFS= read -r pline + do + printf "PRIVMSG %s :%s\r\n" "$dest" "$pline" >> $input + done +} + # repl_msg(line) repl_msg(){ sline=$(echo "$@" | tr -d '\r\n') printf "PRIVMSG %s :%s\r\n" "$REPL" "$sline" >> $input } +# | prepl_msg(void) +prepl_msg(){ + while IFS= read -r pline + do + sline=$(echo "$pline" | tr -d '\r\n') + printf "PRIVMSG %s :%s\r\n" "$REPL" "$sline" >> $input + done +} + # match_action(regex, command...) match_action(){ regex="$1" && shift @@ -92,6 +118,15 @@ repl_action(){ printf "PRIVMSG %s :ACTION %s\r\n" "$REPL" "$sline" >> $input } +# | prepl_action(void) +prepl_action(){ + while IFS= read -r pline + do + sline=$(echo "$pline" | tr -d '\r\n') + printf "PRIVMSG %s :ACTION %s\r\n" "$REPL" "$sline" >> $input + done +} + # match_motd(command...) match_motd(){ echo "$LINE" | grep '^[^ ]* 376' >/dev/null && {