From 20ada66e5478fd0b06191903181cec5ed2462cf4 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sun, 18 Jul 2021 20:56:30 -0500 Subject: [PATCH] Add alternick support --- rowbot | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/rowbot b/rowbot index 86c5e69..e1d8dbb 100755 --- a/rowbot +++ b/rowbot @@ -410,6 +410,7 @@ on_sys_exit_998_net() { annoyatron900() { irc_ping "row your bot gently down the stream" + run_callbacks annoyatron900_ } on_sys_before_999_annoyatron900() { @@ -884,6 +885,45 @@ on_init_sysfacts() { plugin_reg sysfact get_sysfact } +# alternick tracking + +on_init_alternick() { + get_option registered no +} + +on_register_alternick() { + config[registered]=yes +} + +on_msg_433_alternick() { + if [[ ${config[registered]} = yes ]]; then + log_debug "somebody is already using ${config[nick/]}" + return 1 + fi +} + +on_late_msg_433_alternick() { + if [[ ${config[registered]} = no ]]; then + log_info "using nick ${config[nick]}_" + irc_nick "${config[nick]}_" + desired_nick=${config[nick]} + fi +} + +annoyatron900_alternick() { + if [[ $desired_nick ]]; then + irc_nick "$desired_nick" + fi +} + +on_late_msg_NICK_alternick() { + if [[ ${msg[from]} = "${config[nick]}" ]]; then + desired_nick= + log_info "got desired nick!" + config[nick]=${msg_args[-1]} + fi +} + ### # cleanup ### -- 2.45.1