Fix various bugs as well as add targeted facts
This commit is contained in:
parent
70f5e21437
commit
af1ca52c9f
1 changed files with 45 additions and 9 deletions
54
rowbot
54
rowbot
|
@ -134,14 +134,15 @@ cleanup() {
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
###
|
###
|
||||||
# net/reload code
|
# reload code
|
||||||
###
|
###
|
||||||
|
|
||||||
if [[ $reload = yes ]]; then
|
if [[ $reload = yes ]]; then
|
||||||
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
|
trigger=$TRIGGER dev=$DEV level=$LOG_LEVEL
|
||||||
|
|
||||||
|
debug "doing a reload. pid is %d" "$$"
|
||||||
|
|
||||||
if [[ $tls = yes ]]; then
|
if [[ $tls = yes ]]; then
|
||||||
sock_dir=$SOCK_DIR
|
sock_dir=$SOCK_DIR
|
||||||
tls_pid=$tls_pid
|
tls_pid=$tls_pid
|
||||||
|
@ -156,7 +157,13 @@ if [[ $reload = yes ]]; then
|
||||||
if [[ -v HOST ]]; then
|
if [[ -v HOST ]]; then
|
||||||
host=$HOST
|
host=$HOST
|
||||||
fi
|
fi
|
||||||
elif [[ $tls = yes ]]; then
|
fi
|
||||||
|
|
||||||
|
###
|
||||||
|
# net code
|
||||||
|
###
|
||||||
|
|
||||||
|
if [[ $reload = no && $tls = yes ]]; then
|
||||||
sock_dir=$(mktemp -d)
|
sock_dir=$(mktemp -d)
|
||||||
mkfifo "$sock_dir"/rb{in,out}
|
mkfifo "$sock_dir"/rb{in,out}
|
||||||
|
|
||||||
|
@ -175,7 +182,7 @@ elif [[ $tls = yes ]]; then
|
||||||
tls_pid=$!
|
tls_pid=$!
|
||||||
debug "created tls connection (pid %d)" "$tls_pid"
|
debug "created tls connection (pid %d)" "$tls_pid"
|
||||||
exec {out_sock}>"$sock_dir"/rbin {in_sock}<"$sock_dir"/rbout
|
exec {out_sock}>"$sock_dir"/rbin {in_sock}<"$sock_dir"/rbout
|
||||||
else
|
elif [[ $reload = no ]]; then
|
||||||
exec {sock}<>/dev/tcp/"$server"/"$port"
|
exec {sock}<>/dev/tcp/"$server"/"$port"
|
||||||
in_sock=$sock out_sock=$sock
|
in_sock=$sock out_sock=$sock
|
||||||
debug "created plaintext connection"
|
debug "created plaintext connection"
|
||||||
|
@ -261,7 +268,7 @@ on_001() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
ping "row your bot gently down the stream"
|
kill -ALRM "$$"
|
||||||
sleep 10
|
sleep 10
|
||||||
done &
|
done &
|
||||||
|
|
||||||
|
@ -456,6 +463,16 @@ who() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
# keepalive code
|
||||||
|
###
|
||||||
|
|
||||||
|
ping-handler() {
|
||||||
|
ping "row your bot gently down the stream"
|
||||||
|
}
|
||||||
|
|
||||||
|
trap ping-handler ALRM
|
||||||
|
|
||||||
###
|
###
|
||||||
# app hooks
|
# app hooks
|
||||||
##
|
##
|
||||||
|
@ -544,10 +561,18 @@ hook_post_PRIVMSG_factoids() {
|
||||||
privmsg "${params[0]}" "${facts[*]##*/}"
|
privmsg "${params[0]}" "${facts[*]##*/}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local key=${params[1]:${#trigger}}
|
local key=${words[0]:${#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")"
|
local msg=$(<"$fact_root"/"${params[0]}"/"$key")
|
||||||
|
|
||||||
|
if (( ${#words[@]} > 1 )) && [[ ${words[1]} = \> ]]; then
|
||||||
|
local target
|
||||||
|
target=${params[1]#*\>} target=${target# } target=${target% }
|
||||||
|
privmsg "${params[0]}" "$target: $msg"
|
||||||
|
else
|
||||||
|
privmsg "${params[0]}" "$from: $msg"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -624,8 +649,17 @@ hook_post_PRIVMSG_control_panel() {
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
msg)
|
msg)
|
||||||
privmsg "${words[1]}" "${words[*]:2}"
|
if (( ${words[@]} > 2 )); then
|
||||||
privmsg "$to" "sent message to ${words[1]}"
|
privmsg "${words[1]}" "${words[*]:2}"
|
||||||
|
privmsg "$to" "sent message to ${words[1]}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
cycle)
|
||||||
|
if [[ ${to:0:1} = \# ]]; then
|
||||||
|
privmsg "$to" "cycling channel $to"
|
||||||
|
part "$to" "be back soon!"
|
||||||
|
join "$to"
|
||||||
|
fi
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -634,6 +668,8 @@ hook_post_PRIVMSG_control_panel() {
|
||||||
# driver
|
# driver
|
||||||
###
|
###
|
||||||
|
|
||||||
|
trap ping-handler ALRM
|
||||||
|
|
||||||
if [[ $reload = yes ]]; then
|
if [[ $reload = yes ]]; then
|
||||||
privmsg "$RELOAD_TO" done.
|
privmsg "$RELOAD_TO" done.
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue