mIRC Homepage
Posted By: eahm Nick colors "switch" randomly while chatting - 30/07/21 09:11 PM
I have this set:

I noticed some nicks randomly switch color during a chat, I have to restart mIRC to show the same colors again. Not sure it's a bug or whatever, just wanted Khaled to know about it.

I noticed maybe 3-4 times in months, it happens if I keep mIRC opened enough time.
I think the color is based on a hash calculation against $address($nick,something), so if the nick identifies after joining the channel, then their address appears to change, and there's a good chance their color would also change.
Eew. I would ask that Khaled consider associating random nick coloring to $ial().id which is a unique value associated to that user/connection for as long as mIRC sees them in at least one channel. If their address changes via `CAP chghost` their $ial().id remains the same. And only changes if the user /quits or /parts all channels in common with you.
I think your issue is actually more related to mIRC discovering a person's user@host only after they speak at least once, because the server you are using does not support `CAP userhost-in-names` and so the colorization is initially based on their nickname only, but not their nickname!user@host. After time goes on and you learn more and more of their user@hosts across multiple channels they share in common with you, the act of parting-and-rejoining the channels, by either you or them, will cause you to see them wearing a different color.

Rather than restarting mIRC, you can use the command `/ialclear` or `/ialclear <nickname>` then rejoin those channels to reset the colors to be based in the user's nickname-only.

If you used `/ialfill <channel>` in all channels you're in, that would populate each chatter's nickname!user@host into your IAL and then rejoining a channel you have in common with multiple users will cause those individuals to retain the nickname!user@host in the IAL cache, giving them different colors.

So, it's a tricky business. Maybe Khaled should let us choose how randomized nickname coloring is hashed. By nickname-only, by nickname!user@host, or by Session ID via $ial().id
Originally Posted by maroon
I think the color is based on a hash calculation against $address($nick,something), so if the nick identifies after joining the channel, then their address appears to change, and there's a good chance their color would also change.

No nick or address changes, ever. These are people that have been using the same nick and host for years, you can see the conversation for hours then the color randomly switches to a different one.
What network/channel? Can we idle in it?
The address always changes. It changes from $null to buttercup@ip. behind the scenes the first time they speak. The color doesn't update immediately, only after they part and rejoin, or you part and rejoin, or whatnot.
No dude, I'm telling you, there is one dude that has been using the same vps/znc for 10+ years, at one point, while he's talking, the nick goes from for example green to white, after 1-2hrs of being there even, and it stays white until mIRC restarts then it's green again. znc here too so, no parts and no rejoining.

I noticed with other nicks too, they've had the same host for years.
Could custom schemes be causing the issue?

eahm is using "BlackStuffBlue" that was posted here: https://forums.mirc.com/ubbthreads.php/topics/264467


I'm using the stock mIRC classic scheme and I cannot replicate it or maybe I've not been in the channel long enough.
n0=mIRC Classic,0,6,4,5,2,3,3,3,3,3,3,1,5,7,6,1,3,2,3,5,1,0,1,0,1,14,6,0,0,1,97

It's happening on EFnet, no chghost/vhost/spoof/whatever.

eahm said the bug happened again while I was inside the channel. The channel ops nick was green then turned white on his screen. I did not see any change on mine.

I have had a /debug window opened for a few days and the persons nick!~ident@host has not changed.

We are both using znc.
I noticed that the nick colors change if I open the Themes Dialog (Alt + k) and they stick to the new colors until I restart mIRC.

I don't need to change any theme, just by opening the dialog the nick colors just change.

Now, I'm not sure this was the reason it was doing it when I opened this thread but I'm pretty sure that was it, I just noticed this week.
Can you confirm what you're doing in the Alt+K dialog? Are you just looking in there and saving no changes? Or, has the background color changed to something else?

If you're changing the background color's RGB, that can cause colors to change. The number of colors used in the random-nick color palette depends on the RGB of the background, because the number of colors depends on how many other colors there are in the color list who have sufficient contrast against the background. And, if the number of colors in the palette changes, this causes everyone's color to change, for the same reason it changes everyone's color in the earlier MD5 script when you add/remove a color in the script's list-of-colors. More details on how the color palette is possibly chosen is at:


... where I'm finding that there are multiple combos - at least for background black - where the threshhold of contrast for allowing a color into the nick palette is lower than it should be. There are some shades of blue which are allowed to be for a nick against a black background, and while you can discern them from each other when your eye is right next to the screen, the contrast disappears at a normal eye distance from the monitor.

And I backtrack my earlier guess about the address being used for coloring the nick. It appears that a case-sensitive version of the nick is used for the color, as I see the same color used for the same string at 2 networks where their address details are different, and the nicks are continued to be colored identically regardless whether or not I've used /who to even discover what their address and/or account info is.
No changes and no theme change, just open the dialog and ...this is the thing I don't remember, I'm not sure if I tried to just open the dialog and hit Cancel or open the dialog browse 1-2-3 themes and hit Cancel but I think I tried the first option too just to see, ALT+k>Cancel and the nick colors change on the new lines of chat.

All these tests are done on a ZNC also but I don't see why it would be any different with a normal session.
I tested again, ALT+k > Ok = nick colors change. ALT+k > Cancel = nick colors change. Just by opening that panel the nick colors will change. If you restart mIRC all the colors are normal again.
I can't reproduce this. For the time when this happens again, I'm interested in the output of these command when the colors are normal and again when the colors have changed:

1. Be in enough channels so that your $ial is large enough that there's a good chance that all colors in the random palette will be assigned to at least 1 nick. Probably minimum 500 should be sufficient, based on this estimate:
//echo -a $calc(100*(1-(63/64)^500)) $+ %
2. Save the output of this command when colors are normal:

//var %ch $chan(0) , %a | while (%ch) { var %chan $chan(%ch), %i $nick(%chan,0) | while (%i) { var %a $addtok(%a,$nick(%chan,%i).color,32) | dec %i } | dec %ch } | echo -ag nicks: $ial(*,0) palettesize: $numtok(%a,32) $regsubex(background: $color(background) : $sorttok(%a,32,n),/(\d+)/g,\t $+ : $+ $base($color(\t),10,16,6))

3. Repeat #2 when colors have changed.

4. If you have any other color rules in 'nick colors', and if the random color rule is not the topmost one, this shows which other colors in the above palette list might be in the palette due to a different rule, so it helps to see the result from this:

//var %i 1 , %a | while (%i <= $cnick(0)) { var %a %a $cnick(%i).color $cnick(%i).auto | inc %i } | echo -a %a

The outputs are useless unless there's a pair of outputs from when colors are normal vs when they've changed, so don't send unless you have a pair from when colors are normal/changed.

I'm curious if the palette is staying the same but colors for each nick are changing, or whether the palette is changing to have a different group of colors.
1st test:
nicks: 609 palettesize: 4 background: 1:000000 : 3:009300 7:007FFC 15:D2D2D2 52:0000FF

After Alt+k+Cancel
nicks: 609 palettesize: 4 background: 1:000000 : 3:009300 7:007FFC 15:D2D2D2 52:0000FF
Colors HAVE changed.

After Alt+k+Ok
nicks: 609 palettesize: 4 background: 1:000000 : 3:009300 7:007FFC 15:D2D2D2 52:0000FF
Colors HAVE changed.

2nd test:
7 $false 15 $true 2 $false 54 $false 6 $false 52 $false 7 $false 3 $false

My rules:
According to these results, your random colors consists of only 4 different colors? Either this is true, or my alias is somehow picking up the wrong values. Not only that, but the 4 colors showing up as being in the palette are obviously coming from other rules down below, and none of the colors listed in the palette are coming from the random colors.

Can you confirm which mIRC version you're using?

And can you confirm that you're seeing more colors than just the 4 in your debug message?

Even if you edited your color scheme to have all the colors 0-15 being identical, there should be lots of other colors in the 16-98 range showing up in your colorized nicks.
The only way I see that this should be happening is if you have a script using /cline to change the color of these nicks away from the random colors, but something like that shouldn't be triggered by opening the colors dialog.
Yeah not sure why it says 4, I see more colors for sure.

I always use the latest version or Beta when available, using and testing on Beta 7.67.5285 right now.

I'm not sure, if that's the debug message I guess it shows 4? I can send my settings if you'd like to test it.

The theme I'm using is this:

And the only scripts I have loaded are these:

Thanks for checking all this man.
Thanks for looking into this. It looks like the colors are not being updated immediately in some situations. I have made a change that should resolve this in the beta.
I connected today since that last msg/check and I'm testing it, it seems to be working fine now thanks. Will keep testing.
They still change, tested on 2 big chans with 200+ users, no znc, they change almost instantly just by opening ctrl+k.
While it can be fun to blame problems on znc, this issue does not appear to be related to that. At first, your issue was making it sound like the nick colors were being randomly stirred again, but your reply to my debug commands showed that the 'new' colors were simply those defined by other settings if the random colors option hadn't been enabled. If you go back into nick colors and click to edit+save that rule again, do the random colors automagically come back again?

I managed to trigger this happening 1 time, but couldn't get it to happen again. I had only the 1 rule defined in nick colors. I opened the alt+K window, but closed it without doing anything. I didn't notice anything happening then, but when I later alt-tab'ed back the nicklist was back to being plain vanilla, and clicking the rule open again and saving it again didn't help. But after I deleted the rule and unchecked nick colors, then re-created the rule again and re-checked nick colors, everything was working again.

I wasn't able to get this to happen again, so I didn't have a chance to see if only 1 of those 2 actions would have been sufficient. But when I had eahm try doing those actions it didn't re-enable the random colors.

Tried few more times with maroon on Libera and I found out that it happens INSTANTLY as soon as you click ALT+K (all the nicklist colors change instantly) IF there are other settings with the Auto coloring for all nicks, if that's the only option they don't change.
Tried few more times with maroon on Libera and I found out that it happens INSTANTLY as soon as you click ALT+K (all the nicklist colors change instantly) IF there are other settings with the Auto coloring for all nicks, if that's the only option they don't change.

Thanks unfortunately I have still not been able to reproduce this.

If you install a clean, portable copy of mIRC in a new empty folder, with no scripts/addons/etc., and then describe the exact steps you take to reproduce the issue, that could help me track it down.
Loaded a copy just with:



Click Address Book > Nick Colors > [Enable nick colors] > Add:

1) $me = Orange (Messages and Listbox)
2) [Auto-color based on nick] (Messages and Listbox) (Just for testing, I usually do just Messages on this one)


/server irc.rizon.net (not even SSL, not relevant for this test)

/join a big chan

Press Alt+K > see the nicklist colors all change immediately.

NOTE that they only change ONCE for every mIRC start so you will have to press ALT+K AFTER you join the chan, if you press it before joining the new set or colors will already be defined and mIRC will need to be restarted.
Thanks, I was able to reproduce the issue. It should be fixed in the next beta.
Awesome, it seems to be working with the latest beta. Thank you.
© mIRC Discussion Forums