Miscellanious bug fixes and control panel enhancements

This commit is contained in:
Nick Chambers 2021-06-15 20:19:00 -05:00 committed by Nick Chambers
parent 923591bbb3
commit 60fbfe55d7
1 changed files with 24 additions and 5 deletions

27
rowbot
View File

@ -117,9 +117,11 @@ fi
### ###
cleanup() { cleanup() {
if [[ -v $tls_pid || $tls = no ]]; then
exec {in_sock}>&- {out_sock}>&- {log}>&- exec {in_sock}>&- {out_sock}>&- {log}>&-
fi
if [[ $tls = yes ]]; then if [[ -v $tls_pid ]]; then
kill "$tls_pid" kill "$tls_pid"
rm -rf "$sock_dir" rm -rf "$sock_dir"
fi fi
@ -138,6 +140,7 @@ trap cleanup EXIT
if [[ $reload = yes ]]; then if [[ $reload = yes ]]; then
debug "starting reload. pid is %d" "$$" debug "starting reload. pid is %d" "$$"
in_sock=$IN_SOCK out_sock=$OUT_SOCK in_sock=$IN_SOCK out_sock=$OUT_SOCK
trigger=$TRIGGER dev=$DEV level=$LOG_LEVEL
if [[ $tls = yes ]]; then if [[ $tls = yes ]]; then
sock_dir=$SOCK_DIR sock_dir=$SOCK_DIR
@ -152,6 +155,11 @@ elif [[ $tls = yes ]]; then
mkfifo "$sock_dir"/rb{in,out} mkfifo "$sock_dir"/rb{in,out}
if [[ -v client_cert ]]; then if [[ -v client_cert ]]; then
if [[ ! -f $client_cert ]]; then
error "client certificate not found: %s" "$client_cert"
exit 1
fi
conn_args=OPENSSL:$server:$port,cert=$client_cert conn_args=OPENSSL:$server:$port,cert=$client_cert
else else
conn_args=OPENSSL:$server:$port conn_args=OPENSSL:$server:$port
@ -480,7 +488,7 @@ hook_post_PRIVMSG_factoids() {
privmsg "${params[0]}" "${facts[*]##*/}" privmsg "${params[0]}" "${facts[*]##*/}"
;; ;;
*) *)
local key=${params[1]:1} local key=${params[1]:${#trigger}}
if [[ -f $fact_root/${params[0]}/$key ]]; then if [[ -f $fact_root/${params[0]}/$key ]]; then
privmsg "${params[0]}" "$from: $(<"$fact_root"/"${params[0]}"/"$key")" privmsg "${params[0]}" "$from: $(<"$fact_root"/"${params[0]}"/"$key")"
@ -513,8 +521,8 @@ hook_post_PRIVMSG_control_panel() {
privmsg "$to" "joined ${words[1]}" privmsg "$to" "joined ${words[1]}"
;; ;;
reload) reload)
export IN_SOCK=$in_sock OUT_SOCK=$out_sock LOG_FD=$log export IN_SOCK=$in_sock OUT_SOCK=$out_sock LOG_FD=$log DEV=$dev
export RELOAD_TO=$to export RELOAD_TO=$to TRIGGER=$trigger LOG_LEVEL=$level
if [[ $tls = yes ]]; then if [[ $tls = yes ]]; then
export SOCK_DIR=$sock_dir export SOCK_DIR=$sock_dir
@ -541,11 +549,22 @@ hook_post_PRIVMSG_control_panel() {
privmsg "$to" "developer status enabled" privmsg "$to" "developer status enabled"
fi fi
;; ;;
dev\?)
if [[ $dev = yes ]]; then
privmsg "$to" "developer status is enabled"
else
privmsg "$to" "developer status is disabled"
fi
;;
trigger) trigger)
if (( ${#words[@]} > 1 )); then if (( ${#words[@]} > 1 )); then
trigger=${words[1]} trigger=${words[1]}
privmsg "$to" "trigger is now $trigger" privmsg "$to" "trigger is now $trigger"
fi fi
;;
msg)
privmsg "${words[1]}" "${words[*]:2}"
privmsg "$to" "sent message to ${words[1]}"
esac esac
fi fi
} }