Posted to tcl by aspect at Mon Jul 03 12:47:07 GMT 2023view raw

  1. Index: apps/ijbridge/ijbridge.tcl
  2. ==================================================================
  3. --- apps/ijbridge/ijbridge.tcl
  4. +++ apps/ijbridge/ijbridge.tcl
  5. @@ -1086,12 +1086,28 @@
  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. +
  14. + # avoid piling up afters
  15. + after cancel [list cmd-send "NICK $preferred_nick"]
  16. +
  17. + set preferred_nick $::ijchain::Options(IrcUser)
  18. + # $::client::nick is our current nick - or, during intial handshake, the nick we are trying to assume.
  19. +
  20. + if {[lindex [additional] 0] eq $::client_nick} {
  21. +
  22. + # we are still trying to set an initial nick
  23. +
  24. + set fallback_nick "$preferred_nick[string range [expr rand()] end-2 end]"
  25. + cmd-send "NICK $fallback_nick"
  26. + set $::client::nick $fallback_nick
  27. + }
  28. +
  29. + if {$::client::nick ne $preferred_nick} {
  30. + after 20000 [list cmd-send "NICK $preferred_nick"]
  31. }
  32. }
  33.  
  34. $cn registerevent 353 {
  35. # RPL_NAMEREPLY
  36.  
  37.