56 lines
1.4 KiB
Bash
56 lines
1.4 KiB
Bash
#!/usr/bin/env ash
|
|
|
|
. /home/zgrep/offtopiabday/happybot/common.sh
|
|
|
|
irc | while read -r n m; do
|
|
if hreg '^happybot[:,]\s+[STst][lL]=' "$m"; then
|
|
continue
|
|
fi
|
|
m=$(var "$m" | sed 's/[^][A-Za-z0-9\\{}^|_` -]//g');
|
|
var "$m";
|
|
if reg '^(?:[hH][aA][pP][pP][yY]|[hH][aA][tT][eE])[bB][oO][tT] (\S+) (\S+)$' "$m" && ! grep -Fxq -- "$(m 1 | tr 'A-Z' 'a-z')" happybot/act-ignore.txt; then
|
|
echo "$n requested that I do '$(m 1)' to '$(m 2)'.";
|
|
who="$n"
|
|
a="$(m 1)"
|
|
fa=$(var "$a" | tr 'A-Z' 'a-z' | sed 's/[^a-z0-9 ]//g')
|
|
if [ -z "$fa" ]; then
|
|
var "$n: That's not how I work. :(" | zwsp | say;
|
|
else
|
|
case "$(m 2)" in
|
|
"happybot" | "hatebot" | "yourself" | "you" | "thyself" )
|
|
if [ -e /home/zgrep/offtopiabday/hateweekfile ]; then
|
|
n="hatebot";
|
|
else
|
|
n="happybot";
|
|
fi
|
|
;;
|
|
"me")
|
|
# Same person.
|
|
;;
|
|
"someone" | "anyone" | "anybody" | "somebody")
|
|
n="$(person)";
|
|
;;
|
|
"everybody" | "everyone" | "all")
|
|
n="$chan"
|
|
;;
|
|
*)
|
|
n="$(m 2)";
|
|
;;
|
|
esac;
|
|
f="happybot/msgs/$fa.sh";
|
|
if [ -e "$f" ]; then
|
|
sh happybot/msgs/$fa.sh "$n" "$chan" "$serv" > /tmp/tmpact.txt;
|
|
f="/tmp/tmpact.txt";
|
|
else
|
|
f="happybot/msgs/$fa.txt";
|
|
if [ ! -e "$f" ]; then
|
|
f="happybot/msgs/_.txt";
|
|
fi;
|
|
fi;
|
|
N=$(var "$n" | tr 'a-z' 'A-Z');
|
|
m=$(rand "$f"); m='var "'"$m"'"'; m=$(eval "$m");
|
|
var "$m" | zwsp | say;
|
|
fi;
|
|
fi;
|
|
done;
|