Update variable name changes
This commit is contained in:
parent
23e09edca5
commit
5787b3f04b
151
rowbot
151
rowbot
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2154
|
||||
|
||||
###
|
||||
# switch toggler
|
||||
|
@ -274,61 +273,61 @@ recv() {
|
|||
###
|
||||
|
||||
on_ERROR() {
|
||||
error "${params[0]}"
|
||||
error "${args[0]}"
|
||||
exit
|
||||
}
|
||||
|
||||
on_JOIN() {
|
||||
info "%s has joined %s" "$from" "${params[0]}"
|
||||
info "%s has joined %s" "$from" "${args[0]}"
|
||||
}
|
||||
|
||||
on_MODE() {
|
||||
if (( ${#params[@]} == 2 )); then
|
||||
info "%s sets mode(s) %s on %s" "$from" "${params[1]}" "${params[0]}"
|
||||
elif (( ${#params[@]} > 2 )); then
|
||||
info "%s: %s sets mode(s) %s" "${params[0]}" "$from" "${params[*]:1}"
|
||||
if (( ${#args[@]} == 2 )); then
|
||||
info "%s sets mode(s) %s on %s" "$from" "${args[1]}" "${args[0]}"
|
||||
elif (( ${#args[@]} > 2 )); then
|
||||
info "%s: %s sets mode(s) %s" "${args[0]}" "$from" "${args[*]:1}"
|
||||
fi
|
||||
}
|
||||
|
||||
on_NICK() {
|
||||
if [[ $from = "$nick" ]]; then
|
||||
nick=${params[0]}
|
||||
nick=${args[0]}
|
||||
fi
|
||||
|
||||
info "%s has changed their name to %s" "$from" "${params[0]}"
|
||||
info "%s has changed their name to %s" "$from" "${args[0]}"
|
||||
}
|
||||
|
||||
on_NOTICE() {
|
||||
info "[%s/%s] %s" "$from" "${params[0]}" "${params[1]}"
|
||||
info "[%s/%s] %s" "$from" "${args[0]}" "${args[1]}"
|
||||
}
|
||||
|
||||
on_PART() {
|
||||
if (( ${#params[@]} > 1 )); then
|
||||
info "%s has left %s: %s" "$from" "${params[0]}" "${params[1]}"
|
||||
if (( ${#args[@]} > 1 )); then
|
||||
info "%s has left %s: %s" "$from" "${args[0]}" "${args[1]}"
|
||||
else
|
||||
info "%s has left %s" "$from" "${params[0]}"
|
||||
info "%s has left %s" "$from" "${args[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
on_PING() {
|
||||
pong "${params[1]}"
|
||||
debug "received ping: %s" "${params[0]}"
|
||||
pong "${args[1]}"
|
||||
debug "received ping: %s" "${args[0]}"
|
||||
}
|
||||
|
||||
on_PONG() {
|
||||
debug "received pong: %s" "${params[1]}"
|
||||
debug "received pong: %s" "${args[1]}"
|
||||
}
|
||||
|
||||
on_PRIVMSG() {
|
||||
info "<%s/%s> %s" "$from" "${params[0]}" "${params[1]}"
|
||||
info "<%s/%s> %s" "$from" "${args[0]}" "${args[1]}"
|
||||
}
|
||||
|
||||
on_QUIT() {
|
||||
info "%s has disconnected: %s" "$from" "${params[0]}"
|
||||
info "%s has disconnected: %s" "$from" "${args[0]}"
|
||||
}
|
||||
|
||||
on_001() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
|
||||
if [[ $chan ]]; then
|
||||
join "$chan"
|
||||
|
@ -344,21 +343,21 @@ on_001() {
|
|||
} &
|
||||
|
||||
alarm_pid=$!
|
||||
nick=${params[0]}
|
||||
nick=${args[0]}
|
||||
registered=yes
|
||||
who "$nick" %%uht,42
|
||||
}
|
||||
|
||||
on_002() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_003() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_004() {
|
||||
debug "%s " "${params[@]:1}"
|
||||
debug "%s " "${args[@]:1}"
|
||||
}
|
||||
|
||||
declare -A isupport
|
||||
|
@ -366,7 +365,7 @@ declare -A isupport
|
|||
on_005() {
|
||||
local param key value
|
||||
|
||||
for param in "${params[@]:1:${#params[@]}-2}"; do
|
||||
for param in "${args[@]:1:${#args[@]}-2}"; do
|
||||
# This is a valid assignment, not a comparison.
|
||||
# shellcheck disable=SC1097
|
||||
IFS== read -r key value <<< "$param"
|
||||
|
@ -379,81 +378,81 @@ on_005() {
|
|||
}
|
||||
|
||||
on_250() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_251() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_252() {
|
||||
info "There are %d operators online" "${params[1]}"
|
||||
info "There are %d operators online" "${args[1]}"
|
||||
}
|
||||
|
||||
on_253() {
|
||||
info "There are %d unknown connections" "${params[1]}"
|
||||
info "There are %d unknown connections" "${args[1]}"
|
||||
}
|
||||
|
||||
on_254() {
|
||||
info "There are %d channels formed" "${params[1]}"
|
||||
info "There are %d channels formed" "${args[1]}"
|
||||
}
|
||||
|
||||
on_255() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_265() {
|
||||
info %s "${params[3]}"
|
||||
info %s "${args[3]}"
|
||||
}
|
||||
|
||||
on_266() {
|
||||
info %s "${params[3]}"
|
||||
info %s "${args[3]}"
|
||||
}
|
||||
|
||||
on_315() {
|
||||
debug "end of WHO for %s" "${params[1]}"
|
||||
debug "end of WHO for %s" "${args[1]}"
|
||||
}
|
||||
|
||||
on_332() {
|
||||
info "topic for %s is %s" "${params[1]}" "${params[2]}"
|
||||
info "topic for %s is %s" "${args[1]}" "${args[2]}"
|
||||
}
|
||||
|
||||
on_333() {
|
||||
local date
|
||||
printf -v date '%(%c)T' "${params[3]}"
|
||||
info "topic for %s set by %s at %s" "${params[1]}" "${params[2]}" "$date"
|
||||
printf -v date '%(%c)T' "${args[3]}"
|
||||
info "topic for %s set by %s at %s" "${args[1]}" "${args[2]}" "$date"
|
||||
}
|
||||
|
||||
on_353() {
|
||||
info "members of %s: %s" "${params[2]}" "${params[3]}"
|
||||
info "members of %s: %s" "${args[2]}" "${args[3]}"
|
||||
}
|
||||
|
||||
on_354() {
|
||||
if (( params[1] == 42 )); then
|
||||
if (( args[1] == 42 )); then
|
||||
debug "received the identifying who"
|
||||
ident=${params[2]} host=${params[3]}
|
||||
ident=${args[2]} host=${args[3]}
|
||||
debug "ident=%s host=%s" "$ident" "$host"
|
||||
fi
|
||||
}
|
||||
|
||||
on_366() {
|
||||
debug "%s: end of NAMES list" "${params[1]}"
|
||||
debug "%s: end of NAMES list" "${args[1]}"
|
||||
}
|
||||
|
||||
on_372() {
|
||||
info %s "${params[1]}"
|
||||
info %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_375() {
|
||||
debug %s "${params[1]}"
|
||||
debug %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_376() {
|
||||
debug %s "${params[1]}"
|
||||
debug %s "${args[1]}"
|
||||
}
|
||||
|
||||
on_433() {
|
||||
info "somebody is already using %s" "${params[1]}"
|
||||
info "somebody is already using %s" "${args[1]}"
|
||||
|
||||
if [[ $registered = no ]]; then
|
||||
nick "${nick}_"
|
||||
|
@ -461,7 +460,7 @@ on_433() {
|
|||
}
|
||||
|
||||
on_473() {
|
||||
error "%s: %s" "${params[1]}" "${params[2]}"
|
||||
error "%s: %s" "${args[1]}" "${args[2]}"
|
||||
}
|
||||
|
||||
###
|
||||
|
@ -553,24 +552,24 @@ who() {
|
|||
##
|
||||
|
||||
hook_pre_PRIVMSG_CTCP() {
|
||||
if [[ ${params[1]} != $'\x01'*$'\x01' ]]; then
|
||||
if [[ ${args[1]} != $'\x01'*$'\x01' ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local cmd msg
|
||||
cmd=${params[1]#$'\x01'} cmd=${cmd%% *}
|
||||
msg=${params[1]#* } msg=${msg%$'\x01'}
|
||||
cmd=${args[1]#$'\x01'} cmd=${cmd%% *}
|
||||
msg=${args[1]#* } msg=${msg%$'\x01'}
|
||||
|
||||
if [[ ${cmd^^} = ACTION ]]; then
|
||||
if [[ ${params[0]:0:1} = \# ]]; then
|
||||
info "ctcp: %s: %s %s" "${params[0]}" "$from" "$msg"
|
||||
if [[ ${args[0]:0:1} = \# ]]; then
|
||||
info "ctcp: %s: %s %s" "${args[0]}" "$from" "$msg"
|
||||
else
|
||||
info "privately, %s %s" "$from" "$msg"
|
||||
fi
|
||||
|
||||
return 1
|
||||
elif [[ ${params[0]:0:1} = \# ]]; then
|
||||
info "ctcp: %s has requested %s in %s" "$from" "${cmd^^}" "${params[0]}"
|
||||
elif [[ ${args[0]:0:1} = \# ]]; then
|
||||
info "ctcp: %s has requested %s in %s" "$from" "${cmd^^}" "${args[0]}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -582,7 +581,7 @@ hook_pre_PRIVMSG_CTCP() {
|
|||
;;
|
||||
PING)
|
||||
local msg
|
||||
msg=${params[1]#* } msg=${msg%$'\x01'}
|
||||
msg=${args[1]#* } msg=${msg%$'\x01'}
|
||||
notice "$from" $'\x01'"PING $msg"$'\x01'
|
||||
;;
|
||||
SOURCE)
|
||||
|
@ -599,12 +598,12 @@ hook_pre_PRIVMSG_CTCP() {
|
|||
}
|
||||
|
||||
hook_post_PRIVMSG_factoids() {
|
||||
if [[ ${params[0]:0:1} != \# && $from != shikhin ]]; then
|
||||
if [[ ${args[0]:0:1} != \# && $from != shikhin ]]; then
|
||||
return 0
|
||||
elif [[ ${words[0]} = "$trigger"* ]]; then
|
||||
local to=${params[0]}
|
||||
local to=${args[0]}
|
||||
|
||||
if [[ ${params[0]:0:1} != \# ]]; then
|
||||
if [[ ${args[0]:0:1} != \# ]]; then
|
||||
to=$from
|
||||
fi
|
||||
|
||||
|
@ -615,13 +614,13 @@ hook_post_PRIVMSG_factoids() {
|
|||
fi
|
||||
|
||||
local key val
|
||||
key=${params[1]#*"$trigger"is} key=${key# }
|
||||
key=${args[1]#*"$trigger"is} key=${key# }
|
||||
val=${key#* } key=${key%% *}
|
||||
|
||||
info "%s said in %s to remember %s as %s" "$from" "${params[0]}" "$key" "$val"
|
||||
info "%s said in %s to remember %s as %s" "$from" "${args[0]}" "$key" "$val"
|
||||
privmsg "$to" "I'm sure I'll remember that."
|
||||
mkdir -p "$fact_root"/"${params[0]}"
|
||||
printf %s "$val" > "$fact_root"/"${params[0]}"/"$key"
|
||||
mkdir -p "$fact_root"/"${args[0]}"
|
||||
printf %s "$val" > "$fact_root"/"${args[0]}"/"$key"
|
||||
;;
|
||||
isnt)
|
||||
if (( ${#words[@]} < 2 )); then
|
||||
|
@ -629,28 +628,28 @@ hook_post_PRIVMSG_factoids() {
|
|||
fi
|
||||
|
||||
local key
|
||||
key=${params[1]#*"$trigger"isnt} key=${key# }
|
||||
key=${args[1]#*"$trigger"isnt} key=${key# }
|
||||
|
||||
if [[ -f $fact_root/${params[0]}/$key ]]; then
|
||||
info "%s said in %s to delete %s" "$from" "${params[0]}" "$key"
|
||||
if [[ -f $fact_root/${args[0]}/$key ]]; then
|
||||
info "%s said in %s to delete %s" "$from" "${args[0]}" "$key"
|
||||
privmsg "$to" "I forgot what that was anyways."
|
||||
rm -f "$fact_root"/"${params[0]}"/"$key"
|
||||
rm -f "$fact_root"/"${args[0]}"/"$key"
|
||||
fi
|
||||
;;
|
||||
ls)
|
||||
local facts=( "$fact_root"/"${params[0]}"/* )
|
||||
local facts=( "$fact_root"/"${args[0]}"/* )
|
||||
privmsg "$to" "${facts[*]##*/}"
|
||||
;;
|
||||
*)
|
||||
local key=${words[0]:${#trigger}}
|
||||
|
||||
if [[ -f $fact_root/${params[0]}/$key ]]; then
|
||||
if [[ -f $fact_root/${args[0]}/$key ]]; then
|
||||
local msg
|
||||
msg=$(<"$fact_root"/"${params[0]}"/"$key")
|
||||
msg=$(<"$fact_root"/"${args[0]}"/"$key")
|
||||
|
||||
if (( ${#words[@]} > 1 )) && [[ ${words[1]} = \> ]]; then
|
||||
local target
|
||||
target=${params[1]#*\>} target=${target# } target=${target% }
|
||||
target=${args[1]#*\>} target=${target# } target=${target% }
|
||||
privmsg "$to" "$target: $msg"
|
||||
else
|
||||
privmsg "$to" "$from: $msg"
|
||||
|
@ -666,16 +665,16 @@ hook_post_PRIVMSG_control_panel() {
|
|||
return 0
|
||||
fi
|
||||
|
||||
local to=${params[0]}
|
||||
local to=${args[0]}
|
||||
|
||||
if [[ ${params[0]:0:1} != \# ]]; then
|
||||
if [[ ${args[0]:0:1} != \# ]]; then
|
||||
to=$from
|
||||
fi
|
||||
|
||||
case ${words[0]:${#trigger}} in
|
||||
raw)
|
||||
local cmd
|
||||
cmd=${params[1]#"$trigger"raw} cmd=${cmd# }
|
||||
cmd=${args[1]#"$trigger"raw} cmd=${cmd# }
|
||||
info "%s is executing command: %s" "$from" "$cmd"
|
||||
send "$cmd"
|
||||
;;
|
||||
|
@ -741,13 +740,13 @@ hook_post_PRIVMSG_control_panel() {
|
|||
|
||||
hook_post_433_alternick() {
|
||||
if [[ -z $desired_nick && $registered = no ]]; then
|
||||
desired_nick=${params[1]}
|
||||
desired_nick=${args[1]}
|
||||
keep_trying=yes
|
||||
fi
|
||||
}
|
||||
|
||||
hook_post_NICK_alternick() {
|
||||
if [[ ${params[0]} = "$desired_nick" ]]; then
|
||||
if [[ ${args[0]} = "$desired_nick" ]]; then
|
||||
keep_trying=no
|
||||
info "obtained nick %s" "$desired_nick"
|
||||
fi
|
||||
|
@ -773,8 +772,8 @@ fi
|
|||
# - cmd: IRC command or numeric
|
||||
# - args: array of arguments to the command
|
||||
|
||||
# Available if the last parameter starts with ":"
|
||||
# - words: array of words, split by whitespace, of the last parameter
|
||||
# Available if the last argument starts with ":"
|
||||
# - words: array of words, split by whitespace, of the last argument
|
||||
|
||||
# Available if `cmd` is set to "privmsg":
|
||||
# - to: location to send the message back to
|
||||
|
@ -830,7 +829,7 @@ while recv line; do
|
|||
|
||||
if [[ $last = "$trigger"* ]]; then
|
||||
action=${last#"$trigger"} action=${action## *}
|
||||
action_line=${last#"$trigger$action" }
|
||||
action_line=${last#"$trigger$action"* }
|
||||
# shellcheck disable=SC2034
|
||||
read -ra action_args <<< "$action_line"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue