Posted to tcl by aspect at Mon Jul 03 12:11:50 GMT 2023view raw

  1. Index: apps/ijbridge/ijbridge.tcl
  2. ==================================================================
  3. --- apps/ijbridge/ijbridge.tcl
  4. +++ apps/ijbridge/ijbridge.tcl
  5. @@ -1086,12 +1086,29 @@
  6. cmd-join $::client::channel
  7. }
  8.  
  9. $cn registerevent 433 {
  10. # ERR_NICKNAMEINUSE
  11. - if { [lindex [additional] 0] == $::client::nick } {
  12. - cmd-send "NICK [string trimright $::client::nick 0123456789][string range [expr rand()] end-2 end]"
  13. + set requested_nick [lindex [additional 0]]
  14. + set preferred_nick $::ijchain::Options(IrcUser)
  15. + set current_nick $::client::nick
  16. +
  17. + if {$requested_nick == $current_nick} {
  18. +
  19. + # initial nick selection failed - choose a fallback, and schedule a retry
  20. + cmd-send "NICK $preferred_nick[string range [expr rand()] end-2 end]"
  21. + after 20000 [list cmd-send "NICK $preferred_nick"]
  22. +
  23. + } elseif {$requested_nick ne $preferred_nick} {
  24. +
  25. + # fallback nick selection failed - choose another. A retry is already scheduled.
  26. + cmd-send "NICK $preferred_nick[string range [expr rand()] end-2 end]"
  27. +
  28. + } elseif {$requested_nick == $preferred_nick} {
  29. +
  30. + # trying to regain preferred nick failed. Keep our current fallback nick, but schedule another retry.
  31. + after 20000 [list cmd-send "NICK $preferred_nick"]
  32. }
  33. }
  34.  
  35. $cn registerevent 353 {
  36. # RPL_NAMEREPLY
  37.  
  38.