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
|
||||
|
||||
###
|
||||
# net/reload code
|
||||
# reload code
|
||||
###
|
||||
|
||||
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
|
||||
|
||||
debug "doing a reload. pid is %d" "$$"
|
||||
|
||||
if [[ $tls = yes ]]; then
|
||||
sock_dir=$SOCK_DIR
|
||||
tls_pid=$tls_pid
|
||||
|
@ -156,7 +157,13 @@ if [[ $reload = yes ]]; then
|
|||
if [[ -v HOST ]]; then
|
||||
host=$HOST
|
||||
fi
|
||||
elif [[ $tls = yes ]]; then
|
||||
fi
|
||||
|
||||
###
|
||||
# net code
|
||||
###
|
||||
|
||||
if [[ $reload = no && $tls = yes ]]; then
|
||||
sock_dir=$(mktemp -d)
|
||||
mkfifo "$sock_dir"/rb{in,out}
|
||||
|
||||
|
@ -175,7 +182,7 @@ elif [[ $tls = yes ]]; then
|
|||
tls_pid=$!
|
||||
debug "created tls connection (pid %d)" "$tls_pid"
|
||||
exec {out_sock}>"$sock_dir"/rbin {in_sock}<"$sock_dir"/rbout
|
||||
else
|
||||
elif [[ $reload = no ]]; then
|
||||
exec {sock}<>/dev/tcp/"$server"/"$port"
|
||||
in_sock=$sock out_sock=$sock
|
||||
debug "created plaintext connection"
|
||||
|
@ -261,7 +268,7 @@ on_001() {
|
|||
fi
|
||||
|
||||
while true; do
|
||||
ping "row your bot gently down the stream"
|
||||
kill -ALRM "$$"
|
||||
sleep 10
|
||||
done &
|
||||
|
||||
|
@ -456,6 +463,16 @@ who() {
|
|||
fi
|
||||
}
|
||||
|
||||
###
|
||||
# keepalive code
|
||||
###
|
||||
|
||||
ping-handler() {
|
||||
ping "row your bot gently down the stream"
|
||||
}
|
||||
|
||||
trap ping-handler ALRM
|
||||
|
||||
###
|
||||
# app hooks
|
||||
##
|
||||
|
@ -544,10 +561,18 @@ hook_post_PRIVMSG_factoids() {
|
|||
privmsg "${params[0]}" "${facts[*]##*/}"
|
||||
;;
|
||||
*)
|
||||
local key=${params[1]:${#trigger}}
|
||||
local key=${words[0]:${#trigger}}
|
||||
|
||||
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
|
||||
esac
|
||||
fi
|
||||
|
@ -624,8 +649,17 @@ hook_post_PRIVMSG_control_panel() {
|
|||
fi
|
||||
;;
|
||||
msg)
|
||||
privmsg "${words[1]}" "${words[*]:2}"
|
||||
privmsg "$to" "sent message to ${words[1]}"
|
||||
if (( ${words[@]} > 2 )); then
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
@ -634,6 +668,8 @@ hook_post_PRIVMSG_control_panel() {
|
|||
# driver
|
||||
###
|
||||
|
||||
trap ping-handler ALRM
|
||||
|
||||
if [[ $reload = yes ]]; then
|
||||
privmsg "$RELOAD_TO" done.
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue