Properly index the last element of the array
This commit is contained in:
parent
21c8d58459
commit
190c1534ed
18
rowbot
18
rowbot
|
@ -412,7 +412,7 @@ on_JOIN() {
|
||||||
|
|
||||||
on_KICK() {
|
on_KICK() {
|
||||||
if (( ${#args[@]} == 3 )); then
|
if (( ${#args[@]} == 3 )); then
|
||||||
info "%s has kicked %s from %s: %s" "$from" "${args[1]}" "${args[0]}" "${args[@]:(-1)}"
|
info "%s has kicked %s from %s: %s" "$from" "${args[1]}" "${args[0]}" "${args[-1]}"
|
||||||
else
|
else
|
||||||
info "%s has kicked %s from %s" "$from" "${args[1]}" "${args[0]}"
|
info "%s has kicked %s from %s" "$from" "${args[1]}" "${args[0]}"
|
||||||
fi
|
fi
|
||||||
|
@ -601,9 +601,7 @@ on_433() {
|
||||||
}
|
}
|
||||||
|
|
||||||
on_438() {
|
on_438() {
|
||||||
# The result will always be a string, since its the last index of the array.
|
error "${args[1]} couldn't change their nick to ${args[2]}: ${args[-1]}"
|
||||||
# shellcheck disable=SC2145
|
|
||||||
error "${args[1]} couldn't change their nick to ${args[2]}: ${args[@]:(-1)}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
on_473() {
|
on_473() {
|
||||||
|
@ -700,7 +698,7 @@ who() {
|
||||||
|
|
||||||
hook_pre_PRIVMSG_nolog() {
|
hook_pre_PRIVMSG_nolog() {
|
||||||
local words
|
local words
|
||||||
read -ra words <<< "${args[@]:(-1)}"
|
read -ra words <<< "${args[-1]}"
|
||||||
|
|
||||||
if [[ ${words[0]} = "[nolog]" || ${words[0]} = nolog: ]]; then
|
if [[ ${words[0]} = "[nolog]" || ${words[0]} = nolog: ]]; then
|
||||||
info "this message was redacted"
|
info "this message was redacted"
|
||||||
|
@ -864,10 +862,7 @@ hook_cmd_factoids() {
|
||||||
msg=$(<"$fact_root"/"$to"/"$action")
|
msg=$(<"$fact_root"/"$to"/"$action")
|
||||||
|
|
||||||
if [[ ${action_args[0]} = \> ]] && (( ${#action_args[@]} > 1 )); then
|
if [[ ${action_args[0]} = \> ]] && (( ${#action_args[@]} > 1 )); then
|
||||||
# Since it is assigning the last index of the array, it will always be a
|
privmsg "$to" "${action_args[-1]}: $msg"
|
||||||
# single string.
|
|
||||||
# shellcheck disable=SC2145
|
|
||||||
privmsg "$to" "${action_args[@]:(-1)}: $msg"
|
|
||||||
else
|
else
|
||||||
privmsg "$to" "$from: $msg"
|
privmsg "$to" "$from: $msg"
|
||||||
fi
|
fi
|
||||||
|
@ -1055,10 +1050,7 @@ while recv line; do
|
||||||
is_action=no
|
is_action=no
|
||||||
|
|
||||||
if [[ ${cmd^^} = PRIVMSG ]]; then
|
if [[ ${cmd^^} = PRIVMSG ]]; then
|
||||||
# Since it is assigning the last index of the array, it will always be a
|
to=${args[0]} last=${args[-1]}
|
||||||
# single string.
|
|
||||||
# shellcheck disable=SC2124
|
|
||||||
to=${args[0]} last=${args[@]:(-1)}
|
|
||||||
|
|
||||||
if [[ ${to:0:1} != \# ]]; then
|
if [[ ${to:0:1} != \# ]]; then
|
||||||
to=$from
|
to=$from
|
||||||
|
|
Loading…
Reference in New Issue