Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.83 KB | None | 0 0
  1. ;;;
  2. ;;; Lazy nickname coloring script
  3. ;;;
  4. ;;; Color all nicknames automatically by calculating a numeric hash over the nickname.
  5. ;;; The calculated number is used to pick a (space delimited) color from the %colors variable
  6. ;;;  (set in "on START" event).
  7. ;;; Colors are made configurable because yellow on white is annoying, and you may want to use
  8. ;;;  black or white depending on your background color.
  9. ;;;
  10.  
  11. ;; Initialize
  12.  
  13. on 1:START: {
  14.   .initialize_coloring
  15.   /cnick on
  16. }
  17.  
  18. alias initialize_coloring {
  19.   ; use the following colors only
  20.   .set %colors 3 4 5 6 7 9 10 11 12 13 14 15 29 30 31 32 33 34 38 40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 92 93 94 95 96
  21.  
  22.   ; reset all entries in the clist
  23.   while ($cnick(1)) {
  24.     .uncolor_nick $cnick(1)
  25.   }
  26. }
  27.  
  28. ;; Events
  29.  
  30. ; Parse the /names <channel> response(s)
  31. raw 353:*: {
  32.  
  33.   var %names = $4-  
  34.   var %i = 1
  35.   var %n = $gettok(%names,0,32)
  36.   while (%i <= %n) {
  37.     var %current_nick = $gettok(%names,%i,32)
  38.     var %firstchar = $mid(%current_nick, 1, 1)
  39.     while (%firstchar isin @+%) {
  40.  
  41.       %current_nick = $mid(%current_nick, 2)
  42.       %firstchar = $mid(%current_nick, 1, 1)
  43.     }
  44.     .color_nick %current_nick
  45.  
  46.     inc %i
  47.   }
  48. }
  49.  
  50. ; Handle nick changes/joins/quits
  51. on 1:NICK: {
  52.   .uncolor_nick $nick
  53.   .color_nick $newnick
  54. }
  55.  
  56. on 1:JOIN:*: {
  57.   .color_nick $nick
  58. }
  59.  
  60. on 1:QUIT: {
  61.   .uncolor_nick $nick
  62. }
  63.  
  64. ;; Helper functions
  65.  
  66. ; usage: color_nick <nickname>
  67. alias color_nick {
  68.   if (!%colors) {
  69.     .initialize_coloring
  70.   }
  71.   var %colors_idx = $calc($hash($1, 16) % $numtok(%colors, 32)) + 1
  72.   var %nick_color = $gettok(%colors, %colors_idx, 32)
  73.   .cnick $1 %nick_color
  74. }
  75.  
  76. ; usage: uncolor_nick <nickname>
  77. alias uncolor_nick {
  78.   .cnick -r $1
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement