Properly detect enabled markov chains
This commit is contained in:
parent
ea5617e61e
commit
d05d0e7cb6
1 changed files with 6 additions and 2 deletions
8
rowbot
8
rowbot
|
@ -188,6 +188,8 @@ fi
|
|||
|
||||
if [[ $markov_seed ]]; then
|
||||
if [[ -f $markov_seed ]]; then
|
||||
debug "loading markov seed file"
|
||||
|
||||
declare -A markov_chains enabled
|
||||
read -ra words < "$markov_seed"
|
||||
|
||||
|
@ -200,6 +202,8 @@ if [[ $markov_seed ]]; then
|
|||
markov_chains[$key]+=" ${words[$idx + 2]}"
|
||||
fi
|
||||
done
|
||||
|
||||
debug "markov seeds: %s" "${!markov_chains[*]}"
|
||||
else
|
||||
die "seed file does not exist: %s" "$markov_seed"
|
||||
fi
|
||||
|
@ -677,7 +681,7 @@ hook_pre_PRIVMSG_CTCP() {
|
|||
}
|
||||
|
||||
hook_post_PRIVMSG_markov() {
|
||||
if [[ ! ${markov_chains@A} ]]; then
|
||||
if [[ ! -v markov_chains[@] ]]; then
|
||||
return 0
|
||||
elif [[ ${to:0:1} = \# && ${enabled[$to]} != yes ]]; then
|
||||
return 0
|
||||
|
@ -701,7 +705,7 @@ hook_post_PRIVMSG_markov() {
|
|||
hook_cmd_markov() {
|
||||
local keys idx key str chains next vals val_idx
|
||||
|
||||
if [[ ! ${markov_chains@A} ]]; then
|
||||
if [[ ! -v markov_chains[@] ]]; then
|
||||
if [[ $action = markov ]]; then
|
||||
privmsg "$to" "markov chains are not enabled"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue