marvvin

IRC bot
Log | Files | Refs | README | LICENSE

commit 27fac546a865b6602fae7fcea3b664ff8a7c64e6
parent 60ec1b61829937dbde773c4db4d9b981a124673a
Author: Hayden Hamilton <hayden@haydenvh.com>
Date:   Fri,  9 Apr 2021 18:54:37 +0100

functions.sh: only match once per message

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

diff --git a/functions.sh b/functions.sh @@ -22,6 +22,7 @@ match_raw(){ echo "$LINE" | grep -E "$1" >/dev/null && { shift echo "$LINE" | $@ + undefine_match } } @@ -47,6 +48,7 @@ match_msg(){ echo "$3" | grep '^[#!&]' >/dev/null && REPL="$3" || REPL="$NICK" export REPL echo "$line" | $cmd + undefine_match } } } @@ -78,6 +80,7 @@ match_action(){ echo "$3" | grep '^[#!&]' >/dev/null && REPL="$3" || REPL="$NICK" export REPL echo "$line" | $cmd + undefine_match } } } @@ -93,6 +96,7 @@ repl_action(){ match_motd(){ echo "$LINE" | grep '^[^ ]* 376' >/dev/null && { $@ + undefine_match } } @@ -107,6 +111,7 @@ match_join(){ echo "$NICK" | grep -E "$nick_regex" >/dev/null && { export CHANNEL=$channel $cmd + undefine_match } } } @@ -116,6 +121,15 @@ send_join(){ printf 'JOIN %s\r\n' "$(echo "$1" | tr -d '\r\n')" >> $input } +# undefine_match(void) +# map match_* functions to stubs +undefine_match(){ + match_raw(){ true; } + match_msg(){ true; } + match_action(){ true; } + match_motd(){ true; } +} + # filter(line) filter(){ export LINE="$1"