commit 27021dd302f8db2a1207bf92c9e03751f5f9120d
parent 27fac546a865b6602fae7fcea3b664ff8a7c64e6
Author: Hayden Hamilton <hayden@haydenvh.com>
Date: Fri, 9 Apr 2021 19:21:18 +0100
functions.sh: fix related bugs
Diffstat:
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/functions.sh b/functions.sh
@@ -33,7 +33,7 @@ debug(){
# send_raw(line)
send_raw(){
- printf '%s\r\n' "$(echo "$@" | tr '\n' ' ')" >> $input
+ printf '%s\r\n' "$(echo "$@" | tr '\n\r' ' ')" >> $input
}
# match_msg(regex, command...)
@@ -43,11 +43,11 @@ match_msg(){
set -- $LINE
[ "$2" = "PRIVMSG" ] && {
- line=$(echo "$@" | sed 's/:[^:]*://' | tr -d '\r')
- echo "$line" | grep -Ei "$regex" >/dev/null && {
+ sline=$(echo "$@" | sed 's/:[^:]*://' | tr -d '\r')
+ echo "$sline" | grep -Ei "$regex" >/dev/null && {
echo "$3" | grep '^[#!&]' >/dev/null && REPL="$3" || REPL="$NICK"
export REPL
- echo "$line" | $cmd
+ echo "$sline" | $cmd
undefine_match
}
}
@@ -57,14 +57,14 @@ match_msg(){
send_msg(){
dest=$(echo "$1" | tr -d '\r\n')
shift
- line=$(echo "$@" | tr -d '\r\n')
- printf "PRIVMSG %s :%s\r\n" "$dest" "$line" >> $input
+ sline=$(echo "$@" | tr -d '\r\n')
+ printf "PRIVMSG %s :%s\r\n" "$dest" "$sline" >> $input
}
# repl_msg(line)
repl_msg(){
- line=$(echo "$@" | tr -d '\r\n')
- printf "PRIVMSG %s :%s\r\n" "$REPL" "$line" >> $input
+ sline=$(echo "$@" | tr -d '\r\n')
+ printf "PRIVMSG %s :%s\r\n" "$REPL" "$sline" >> $input
}
# match_action(regex, command...)
@@ -74,12 +74,12 @@ match_action(){
set -- $LINE
[ "$2" = "PRIVMSG" ] && {
- echo "$line" | grep 'ACTION.*' >/dev/null && {
- line=$(echo "$@" | sed 's/:[^:]*:ACTION//' | tr -d '\r')
- echo "$line" | grep -Ei "$regex" >/dev/null && {
+ echo "$@" | grep 'ACTION.*' >/dev/null && {
+ sline=$(echo "$@" | sed 's/:[^:]*:ACTION//;s///g' | tr -d '\r')
+ echo "$sline" | grep -Ei "$regex" >/dev/null && {
echo "$3" | grep '^[#!&]' >/dev/null && REPL="$3" || REPL="$NICK"
export REPL
- echo "$line" | $cmd
+ echo "$sline" | $cmd
undefine_match
}
}
@@ -88,15 +88,14 @@ match_action(){
# repl_action(line)
repl_action(){
- line=$(echo "$@" | tr -d '\r\n')
- printf "PRIVMSG %s :ACTION %s\r\n" "$REPL" "$line" >> $input
+ sline=$(echo "$@" | tr -d '\r\n')
+ printf "PRIVMSG %s :ACTION %s\r\n" "$REPL" "$sline" >> $input
}
# match_motd(command...)
match_motd(){
echo "$LINE" | grep '^[^ ]* 376' >/dev/null && {
$@
- undefine_match
}
}
@@ -127,7 +126,6 @@ undefine_match(){
match_raw(){ true; }
match_msg(){ true; }
match_action(){ true; }
- match_motd(){ true; }
}
# filter(line)