forked from zgrep/happybot
But if you wish to be spammed, nobody but you should be able to unspam yourself.
This commit is contained in:
parent
402cbbaadd
commit
4c8609d7c7
1 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue