Fix reconnection issue and too fast connection issue. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit 436330de81145ff63ed5f457ec9c4f042ef96bc2 DIR parent 8023bf1fc3c9f261f05b8692cbedbd84601e82af HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Tue, 14 Mar 2023 13:49:14 +0100 Fix reconnection issue and too fast connection issue. Diffstat: M annna-start-main | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) --- DIR diff --git a/annna-start-main b/annna-start-main @@ -15,6 +15,7 @@ maxtries=10 maxnicktries=5 { nicktries=0 + iipid=0 while [ -f ${cfgbase}/running ]; do # Connect @@ -48,8 +49,12 @@ maxnicktries=5 #ii -s "${server}"${ircpassparam}${ircuserparam}${tlsparam} \ # -f "${fullname}" -p ${port} & + [ $iipid -gt 0 ] && kill -KILL $iipid >/dev/null 2>&1 + ii -s "${server}"${ircpassparam}${ircuserparam}${tlsparam} \ -f "${fullname}" -p ${port} 2>&1 >/dev/null & + #ii -s "${server}"${ircpassparam}${ircuserparam}${tlsparam} \ + # -f "${fullname}" -p ${port} iipid=$! sleep 5 @@ -60,22 +65,19 @@ maxnicktries=5 do kill -0 $iipid >/dev/null 2>&1 || exit 1 [ ! -f ${cfgbase}/running ] && exit 1 - set -x tries=$(($tries + 1)) [ $tries -gt $maxtries ] && break sleep 4 done [ $tries -gt $maxtries ] && continue - set +x # 433: Nickname is already in use. - if [ $(grep " 433 " ${ircbase}/${server}/out) ]; + if [ -n "$(grep " 433 " ${ircbase}/${server}/out)" ]; then - set -x nicktries=$(($nicktries + 1)) [ $nicktries -gt $maxnicktries ] && exit 3 sleep 30 - set +x + continue fi tries=0 @@ -83,12 +85,17 @@ maxnicktries=5 while [ -z "$(grep " 376 " ${ircbase}/${server}/out)" ]; do [ ! -f ${cfgbase}/running ] && exit 1 - set -x + # Sometimes the connection is too fast and the ii USER + # and NICK is slurped. + printf "USER %s\r\nUSER %s localhost %s :%s" \ + "${ircuser}" "${ircuser}" "$(hostname)" \ + "${fullname}" \ + > "${ircbase}/${server}/in" + tries=$(($tries + 1)) [ $tries -gt $maxtries ] && break sleep 2 done [ $tries -gt $maxtries ] && continue - set +x { annna-join-channels "${server}" "${channels}"