From 4c8609d7c7a0ce7c86c58ed56a8e8b0a08c88f2a Mon Sep 17 00:00:00 2001 From: zgrep Date: Sat, 8 May 2021 07:11:19 -0400 Subject: [PATCH] But if you wish to be spammed, nobody but you should be able to unspam yourself. --- grouper/groups.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grouper/groups.sh b/grouper/groups.sh index bce2ff1..7fc1a29 100644 --- a/grouper/groups.sh +++ b/grouper/groups.sh @@ -12,7 +12,7 @@ irc | while read -r n m; do if [ "$(m 1)" == "add" ]; then if [ ! -e "$file" ]; then touch "$file" - elif grep -F -i -e "$n" "$file"; then + elif grep -x -F -i -e "$n" "$file"; then var "$n: You're already part of @$group." | zwsp | say continue fi @@ -26,7 +26,7 @@ irc | while read -r n m; do fi else if [ -e "$file" ]; then - new="$(grep -F -i -v -e "$n" "$file")" + new="$(grep -x -F -i -v -e "$n" "$file")" if [ -z "$new" ]; then rm "$file" else @@ -42,12 +42,13 @@ irc | while read -r n m; do elif hreg '^happybot[:,] groups?(?:$| .*$)' "$m"; then var "$n: Usage: groups add|del|list @[a-z0-9][a-z0-9_-]*" | zwsp | say elif reg ' cc ([^ ,]+(?:, ?[^ ,]+)*)' "$m"; then - grep='grep -o -F -i '"$(ls -1 "$base" | sed "s/^/-e '@/;s/\$/'/" | tr '\n' ' ')" - groups="$(var "$(m 1)" | sed 's/,/ /g;s/ / /g' | tr ' ' '\n' | eval "$grep" | sed 's/^@//')" + grep='grep -o -F -i -x '"$(ls -1 "$base" | sed "s/^/-e '@/;s/\$/'/" | tr '\n' ' ')" + groups="$(m 1 | sed 's/[^a-zA-Z0-9\-_]*$//')" + groups="$(var "$groups" | sed 's/,/ /g;s/ / /g' | tr ' ' '\n' | eval "$grep" | sed 's/^@//')" if [ ! -z "$groups" ]; then new="$m" for group in $groups; do - people="$(cat "$base/$group" | grep -v -F -e "$n" | tr '\n' ',' | sed 's/,$//;s/,/, /g')" + people="$(cat "$base/$group" | grep -v -F -e -x "$n" | tr '\n' ',' | sed 's/,$//;s/,/, /g')" if [ ! -z "$people" ]; then new="$(var "$new" | sed 's/ cc \(.*\)@'"$group"'/ cc \1'"$people"'/')" fi