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