diff --git a/bot.cfg b/bot.cfg index c8c939d..452dc31 100644 --- a/bot.cfg +++ b/bot.cfg @@ -25,3 +25,4 @@ curseKicker=true botCaller=",.!+?" # People who are allowed to private message the bot separate multiple names with | allowList="" +ignoreList="storm_bot" diff --git a/bot.sh b/bot.sh index ec9dff3..8a5453e 100755 --- a/bot.sh +++ b/bot.sh @@ -9,7 +9,7 @@ fi input=".botinput" close_bot() { - echo -en "QUIT :$quitMessage\r\n" >> "$input" + echo -en "QUIT :${quitMessage}\r\n" | telnet "$server" "$port" rm "$input" exit 0 } @@ -78,6 +78,22 @@ tail -f "$input" | telnet "$server" "$port" | while read -r result ; do set +f fi ;; + # run when a private message is seen + *"PRIVMSG "[[:alnum:]-_]*) + echo "$result" >> "$log" + who="${result%%!*}" + who="${who:1}" + from="${who%!*}" + command="${result#:* PRIVMSG [[:alnum:]_-]*:}" + command="${command//# /}" + will="${command#* }" + command="${command%% *}" + if [[ "$from" =~ $allowList ]]; then + ./modules/say/say.sh "$who" "#$channel" $from really loves me, they sent me a private message saying $command $will + else + reply "$who" "You are not in the allowed list for this bot. If you think this is an error, please contact the bot's administrator." + fi + ;; # run when a message is seen *PRIVMSG*) echo "$result" >> "$log" @@ -110,9 +126,11 @@ tail -f "$input" | telnet "$server" "$port" | while read -r result ; do ./modules/say/say.sh "$who" "$from" "$who: $(shuf -n1 "response/error.txt")" fi else - set -f - ./triggers/keywords/keywords.sh "$who" "$from" "$result" - set +f + if ! [[ "$who" =~ $ignoreList ]]; then + set -f + ./triggers/keywords/keywords.sh "$who" "$from" "$result" + set +f + fi fi ;; *)