mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2016
Posts: 1
E
Mostly harmless
OP Offline
Mostly harmless
E
Joined: Apr 2016
Posts: 1
Hello,

I like to have to usernames in chat randomly colored, especially in large chat rooms, as it makes reading and separating lines easier for me. Other IRC clients seem to have this feature, but I always end up returning to mIRC, where I've never found this ability.
I know I can manually color names, but in active rooms with dozens of people or more this isn't practical. So far the only way I've found is by using a script such as:

Code:
on ^*:text:*:#:{
if ($cnick($nick).color == $color(normal text)) { 
  .cnick $nick $gettok(%colors,$calc(%currentcolor),32)
  if (%currentcolor == $gettok(%colors,0,32)) { 
    set %currentcolor 1
  }
  else {
    inc %currentcolor
  }
}
}


The downside is this will add the nickname and its now permanently assigned color to mirc.ini. This is a problem because when mirc.ini gets above a few KB, it greatly increases mIRC's loading speed. I've had the filesize get to 5 MB before, and right now it's back to 2.5 MB. This results in an mIRC loading time of a few minutes instead of a few seconds. Using ProcMon I can see mIRC repeatedly reading from mIRC during this time which further confirms the long load is mIRC trying to fully read the mIRC.ini file.

Does anyone know of a better way of doing this, or an easy button I've missed somewhere?

Joined: Nov 2013
Posts: 22
Ameglian cow
Offline
Ameglian cow
Joined: Nov 2013
Posts: 22
would you be OK with only colorizing the nicks the chat.. but not the nick list? something like this could work..

Code:
on ^*:TEXT:*:# { 
  var %col $base($left($md5($nick),1),16,10)
  ; if you are using a white background.. change the below '1' to '0'
  if ( %col = 1 ) inc %col
  echo -t $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Last edited by funfare; 07/04/16 07:39 AM.
Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Posting this for archival purposes, it's a variation of funfare' script but it randomizes colors between 2 and 15, skipping 0 and 1 (white and black).

Modified by maroon for me on ##mirc freenode.

Code:
on ^*:TEXT:*:# { 
  var %col $calc(($base($left($md5($nick),13),16,10) % 14) +2)
  echo -t $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
One more, to make it flash when flashing is enabled, thanks maroon again.

Code:
on ^*:TEXT:*:# { 
  var %col $calc(($base($left($md5($nick),13),16,10) % 14) +2)
  echo -tl $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This thread came up in channel, and wasn't ready for primetime. The MOD 14 returns 0-13, so adding 2 changes the colors to be color index 2-15. This excludes both white and black, one of which is pretty much guaranteed to be a good color and the other one bad. But it also includes colors that may not contrast well against blackgrounds and whitegrounds unless you edit your color palette. i.e. 8=yellow vs 0-white or 2-navy vs 1-black.

This modified code instead lets you choose a list of colors that work well against the background. With the newer mIRC versions you can use colors 0-98, but for older versions you'd need to stick with the old 0-15 range. However many numbers you list, that's the number you replace the '16' with.

I also changed from MD5 to CRC, which is a faster algorithm, and avoids the need to use $left(). This should be sufficient to diversify similar strings among various colors, and would be slightly quicker, since this is executing for each message in channel.

The 'secret' is optional, and can be changed later if you want to stir the colors so some people no longer share a color.

If you want the color to follow someone as they change nick, replace $nick with $address. The color can change if they reconnect with a different IP address or if their identd state changes. Using $site would put clones as the same color, including all *@staff.network addresses.

Code:
on ^*:TEXT:*:# { 
var %col $gettok(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,$calc(1+$base($crc(secret $nick,0),16,10) % 16),32)
echo -tl $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}



To get fancier, you can make the coloring change every 24 hours, using the $randnow2 alias at https://mircscripts.net/j6hi0 to replace the 'var' line with:

Code:
var %col $gettok(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,$randnow2(1,1,16,16,86400,secret $nick),32)



Both 16's need to change to the count of numbers in your number list. 86400 is the number of seconds in a day, so change it if you want it to change weekly or otherwise.

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Thank you maroon, just saw this reply and its damn awesome, testing later tonight.

Joined: Jun 2019
Posts: 1
E
Mostly harmless
Offline
Mostly harmless
E
Joined: Jun 2019
Posts: 1
Thanks maroon, I've switch to this script. Works as good as my old one but handles colors a bit better.

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Added some colors, posting for archival, as always:

Code
var %col $gettok(2 3 4 5 6 7 8 9 10 11 12 13 14 15 40 41 42 43 44 45 46 47 49 50 51 52 53 59 61 72,$calc(1+$base($crc(secret $nick,0),16,10) % 30),32)

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
One more, better to avoid grays for the "GrEvents" themes/color schemes:

Also I removed the 7 because I keep my nick always orange.

Code
var %col $gettok(2 3 4 5 6 8 9 10 11 12 13 40 41 42 43 44 45 46 47 49 50 51 52 59 61 72,$calc(1+$base($crc(secret $nick,0),16,10) % 26),32)

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Posting for archival purposes, the timestamp issue is fixed, thanks again maroon on freenode.

md5:
Code
on ^*:TEXT:*:# { 
  var %col $calc(($base($left($md5($nick),13),16,10) % 14) +2)
  echo -lt $+ $msgstamp $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

crc (faster, better colors):
Code
on ^*:TEXT:*:# { 
  var %col $gettok(2 3 4 5 6 8 9 10 11 12 13 40 41 42 43 44 45 46 47 49 50 51 52 59 61 72,$calc(1+$base($crc(secret $nick,0),16,10) % 26),32)
  ;var %col $gettok(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15,$calc(1+$base($crc(secret $nick,0),16,10) % 16),32)
  echo -lt $+ $msgstamp $chan < $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ > $1- 
  halt
}

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Thanks for the nick coloring feature Khaled, tested for 20 mins but it seems to be working wonderfully.

Joined: May 2018
Posts: 221
Fjord artisan
Offline
Fjord artisan
Joined: May 2018
Posts: 221
Guys, I modified this line to make the nicks in bold "echo -lt $+ $msgstamp $chan < $+ $chr(2) $+ $chr(3) $+ %col $+ $nick($chan,$nick).pnick $+ $chr(3) $+ $chr(2) $+ > $1-", not sure if it's 100% correct but it works fine but I just noticed it doesn't color the query nicks, is there a way to add that?
Thanks.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This is an update to eahm's archival post. Even though random colors has been added so that you no longer need a script to give everyone a random color based on their nick/address/whatever, some people may still be scripting the random nick colors for reasons I mentioned in this other thread.

https://forums.mirc.com/ubbthreads.php/topics/266171/automatically-colourize-nicknames

The choice of nick colors configured into the above script's palette needs to choose colors with 3 competing constraints.

* #1 Palette needs to have a high-enough group of colors to offer a decent chance that nicks will be randomly assigned different colors.

* #2 Colors need to contrast well against the background, and the built-in palette allows some low-contrast blue-on-black combos which may appear to contrast 'well enough' when your eyes are close to the monitor, the contrast deteriorates when eyes are at an arms-length distance.

* #3 Colors need to be contrasting against each other, so that nicks assigned to different colors look different-enough from each other.

These 3 goals are hard to achieve with the blues when using a blackground. The default color scheme has color indexes 2, 10, 11, 12 which are basically 4 shades of blue. When black is your background color only 11 - and to some degree 10 - contrast against black. While you can edit the RGB shade for index 2 and 12, it's hard to find color settings where 2 and 12 are hard to tell apart from 11 and 10 while still being able to be seen against the black.

--

In my earlier post, I'd suggested using $crc because it should be much faster than $md5 due to being a simpler calculation, so there's less overhead calculating a $crc on each channel message instead of doing the same with $md5.

However, in another thread I'd actually benchmarked $crc against $md5, and it had turned out that $crc was actually no faster than $md5.

However, along with $crc64 being added, $crc has now been sped-up so that it's several hundred percent faster than it formerly was. The new $crc64 has similar speed to the 32-bit $crc, faster than $md5, but it also fills the "seeded RNG" role of $crc in a way which produces 2^64 outcomes instead of 2^32.

$crc and $crc64 are NOT appropriate as a random number generator when the outcome needs to be unpredictable, such as scripting a card game. They're used here specifically to create a situation where the same nick is always colored the same way every time, just being colored (hopefully) different than most other nicks. And the optional 'secret string' is intended to make it harder for other people to intentionally choose nicks that they know will all be colored the same way by your script.

Because $calc has accuracy only to 53 bits, the above usage of $md5 was using only 13 digits of the MD5 string. In order to use $crc64 in the role currently performed by $crc, it will need to do the same thing, using 13 of the 16 hex digits of the 64-bit CRC.

In the above using of $crc, it has a color palette containing 26 different numbers, so the script using "% 26" is how it's choosing which of the 26 colors to use. If you change your palette to have fewer/more colors than 26, you MUST edit the 26 to be the new color-count. Leaving the number too small causes some of your colors to never be chosen. Leaving the number too large causes some nicks to not be colored at all. In addition to editing the 'secret' string, changing the number of colors in your color palette will also affect the color chosen for most nicks.

Your best color palette depends on your choice of background color, so having a black background means you have good color constrast against 8=yellow 9=light-green etc. If you have a white background, those 2 colors contrast poorly, so you would instead choose colors like 2 and 12 blues, which in exchange contrast poorly against black.

If your current script contains a line like:

var %col $gettok(2 3 4 5 6 8 9 10 11 12 13 40 41 42 43 44 45 46 47 49 50 51 52 59 61 72,$calc(1+$base($crc(secret $nick,0),16,10) % 26),32)

Using $crc64 should change it to look like:

var %col $gettok(2 3 4 5 6 8 9 10 11 12 13 40 41 42 43 44 45 46 47 49 50 51 52 59 61 72,$calc(1+$base($left($crc(secret $nick,0),13),16,10) % 26),32)

It doesn't matter whether you use $left or $mid or $right, just as long as you're using <= 13 of 16 hex digits, since 13*4= 52 bits.


Link Copied to Clipboard