Allow the bot to keep trying for the desired nick

This commit is contained in:
Nick Chambers 2021-06-19 01:35:33 -05:00
parent 89068edf10
commit 0afef8ef68
1 changed files with 29 additions and 0 deletions

29
rowbot
View File

@ -274,6 +274,7 @@ on_001() {
ping_pid=$!
nick=${params[0]}
registered=yes
who "$nick" %%uht,42
}
@ -375,6 +376,14 @@ on_376() {
debug %s "${params[1]}"
}
on_433() {
info "somebody is already using %s" "${params[1]}"
if [[ $registered = no ]]; then
nick "${nick}_"
fi
}
on_473() {
error "%s: %s" "${params[1]}" "${params[2]}"
}
@ -469,6 +478,11 @@ who() {
ping-handler() {
ping "row your bot gently down the stream"
if [[ $keep_trying = yes ]]; then
info "trying for %s again" "$desired_nick"
nick "$desired_nick"
fi
}
trap ping-handler ALRM
@ -664,6 +678,20 @@ hook_post_PRIVMSG_control_panel() {
fi
}
hook_post_433_alternick() {
if [[ -z $desired_nick && $registered = no ]]; then
desired_nick=${params[1]}
keep_trying=yes
fi
}
hook_post_NICK_alternick() {
if [[ ${params[0]} = $desired_nick ]]; then
keep_trying=no
info "obtained nick %s" "$desired_nick"
fi
}
###
# driver
###
@ -673,6 +701,7 @@ trap ping-handler ALRM
if [[ $reload = yes ]]; then
privmsg "$RELOAD_TO" done.
else
registered=no
nick "$nick"
user "$ident" "$realname"
fi