Project

General

Profile

[script] Random Nick Color message » Random Nick Color message v0.4.ini

Mr. BS, 04/11/2014 04:51 PM

 
1
; http://dev.adiirc.com/boards/5/topics/163
2
; outputs same nick random color for the message
3
; v0.4 by pereba
4

    
5
; Script
6

    
7
on 1:LOAD: {
8
  UserConf
9
  setPrefixColors
10
  UserIni
11
}
12

    
13
; to update vars when reload the script
14
on 1:START: {
15
  UserIni
16
}
17

    
18
on 1:UNLOAD: {
19
  unset %RColor.*
20
}
21
;$readini(config.ini, Tips, UseTips) tips: $readini(config.ini, Tips, Tips)
22
alias -l UserIni {
23
  set %RColor.nickConfig $strip($readini(config.ini, Messages, prefixuser),c)
24
  set %RColor.actionConfig $strip($readini(config.ini, Messages, prefixemote),c)
25
  set %RColor.TipTimes $readini(config.ini, Tips, TipTimes)
26
  set %RColor.isntFocusedTips $readini(config.ini, Tips, FocusedTips)
27
  set %RColor.msgTips $left($readini(config.ini, Tips, Tips),1)
28
}
29

    
30
alias -l UserConf {
31
  set %RColor.Enabled 1
32
  set %RColor.Timestamp.Enabled 1
33
  set %RColor.Action.Enabled 1
34
  set %RColor.prefixColored 1
35
}
36

    
37
alias -l setPrefixColors {
38
  set %RColor.prefixColorAdmin 4
39
  set %RColor.prefixColorOwner 4    
40
  set %RColor.prefixColorProtect 9
41
  set %RColor.prefixColorOp 7
42
  set %RColor.prefixColorHalfOp 11
43
  set %RColor.prefixColorVoice 13
44
}
45

    
46
;channel
47
on ^*:TEXT:*:#: {
48
  if (%RColor.Enabled == 1) {
49
    ; znc playback
50
    if ($nick == ***) && (Buffer Playback... isin $1-) {
51
      set -e %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] 1
52
      echo $EchoMode # $nickFormated $1-
53
    }
54
    if ($znc.playback) && ($nick != ***) {
55
      echo $TheColor -rlmbf # $iif(%RColor.Timestamp.Enabled == 1,$1) $nickFormated $2-
56
    }
57
    if ($nick == ***) && (Playback Complete. isin $1-) {
58
      unset %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ]
59
      echo $EchoMode # $nickFormated $1-
60
      halt
61
    }
62
    ; normal messages
63
    if (!$znc.playback) {
64
      echo $TheColor $EchoMode # $nickFormated $1-
65
      if ($tips) && (%RColor.msgTips == 1) { 
66
        if ($appactive) && (%RColor.isntFocusedTips == true) { halt }
67
        noop $tip(messages,Channel Message $network,$nick on # says $+ : $strip($1-),%RColor.TipTimes)
68
      }
69
    }
70
    halt
71
  }
72
}
73

    
74
;action
75
on ^*:ACTION:*:#: {
76
  if ($znc.playback) {
77
    echo $iif(%RColor.Action.Enabled == 1, $TheColor) $EchoMode # $actionFormated $2-
78
  halt
79
  }
80
  if (%RColor.Action.Enabled == 1) {
81
    echo $TheColor $EchoMode # $actionFormated $1-
82
    if ($tips) && (%RColor.msgTips == 1) { 
83
      if ($appactive) && (%RColor.isntFocusedTips == true) { halt }
84
      noop $tip(messages,Channel Action $network,$nick on # $+ : $strip($1-),%RColor.TipTimes)
85
    }
86
    halt
87
  }
88
}
89

    
90
alias -l TheColor {
91
  if ($nick(#,$nick).color > 0) {
92
    return $nick(#,$nick).color
93
  }
94
}
95

    
96
alias -l EchoMode {
97
  if (%RColor.Timestamp.Enabled == 1) {
98
    return -trlmbf
99
  }
100
  return -rlmbf  
101
}
102

    
103
alias -l actionFormated { var %nc $replace(%RColor.actionConfig, $!pnick, $iif($nick == ***, ***, $nick($chan,$nick).pnick), $!status, $left($nick(#,$nick,a,r).pnick,1), $!nick, $nick) | return $prefixReplace(%nc) }
104
alias -l nickFormated { var %nc $replace(%RColor.nickConfig, $!pnick, $iif($nick == ***, ***, $left($nick(#,$nick,a,r).pnick,1) $+ $nick), $!status, $left($nick(#,$nick,a,r).pnick,1), $!nick, $nick) | return $prefixReplace(%nc) }
105
alias -l prefixReplace {
106
  var %prefix $left($nick(#,$nick,a,r).pnick,1)
107
  if ($regex(%prefix,/([!~&@%+])/)) && (%RColor.prefixColored == 1) {
108
    ; ! = $chr(33) ~ = $chr(126) & = $chr(38) @ $chr(64) % = $chr(37) + = $chr(43)
109
    return $replace($1, $chr(33), $+($chr(3),%RColor.prefixColorAdmin,$chr(126),$chr(3)), $chr(126), $+($chr(3),%RColor.prefixColorOwner,$chr(126),$chr(3)), $chr(38), $+($chr(3),%RColor.prefixColorProtect,$chr(38),$chr(3)), $chr(64), $+($chr(3),%RColor.prefixColorOp,$chr(64),$chr(3)), $chr(37), $+($chr(3),%RColor.prefixColorHalfOp,$chr(37),$chr(3)), $chr(43), $+($chr(3),%RColor.prefixColorVoice,$chr(43),$chr(3)))
110
  }
111
  return $1
112
}
113
alias -l znc.playback { return %RColor.znc.playback. [ $+ [ $cid ] $+ . $+ [ $chan ] ] }
114

    
115
alias RColorPreview {
116
  echo -ag $+( $chr(3), %RColor.prefixColorAdmin, $chr(2), $chr(33), $chr(2), $chr(3), Admin, $chr(160) $chr(3), %RColor.prefixColorOwner, $chr(2), $chr(126), $chr(2), $chr(3), Owner, $chr(160) $chr(3), %RColor.prefixColorProtect, $chr(2), $chr(38), $chr(2), $chr(3), Protect, $chr(160) $chr(3), %RColor.prefixColorOp, $chr(2), $chr(64), $chr(2), $chr(3), Op, $chr(160) $chr(3), %RColor.prefixColorHalfOp, $chr(2), $chr(37), $chr(2), $chr(3), HalfOp, $chr(160) $chr(3), %RColor.prefixColorVoice, $chr(2), $chr(43), $chr(2), $chr(3), Voice)
117
}
118

    
119
menu menubar {
120
  -
121
  $iif(%RColor.Enabled == 1, $style(1),) 🎨 RColor Messages
122
  .$iif(%RColor.Enabled == 1, Disable, Enable) : $iif(%RColor.Enabled == 1, unset %RColor.Enabled, set %RColor.Enabled 1)
123
  .$iif(%RColor.Timestamp.Enabled == 1, $style(1),) Use timestamp : $iif(%RColor.Timestamp.Enabled == 1, unset %RColor.Timestamp.Enabled, set %RColor.Timestamp.Enabled 1)
124
  .$iif(%RColor.Action.Enabled == 1, $style(1),) Apply for action : $iif(%RColor.Action.Enabled == 1, unset %RColor.Action.Enabled, set %RColor.Action.Enabled 1)
125
  .$iif(%RColor.prefixColored == 1, $style(1),) Color prefix
126
  ..$iif(%RColor.prefixColored == 1, Disable, Enable):$iif(%RColor.prefixColored == 1, unset %RColor.prefixColored, set %RColor.prefixColored 1)
127
  ..-
128
  ..$style(2)Set Colors $+ $chr(65306)
129
  ..$chr(33) $+ Admin            %RColor.prefixColorAdmin:$setColorInput($chr(33), Admin)
130
  ..$chr(126) $+ Owner          %RColor.prefixColorOwner:$setColorInput($chr(126), Owner)
131
  ..$chr(38) $+ $chr(38) $+ Protect        %RColor.prefixColorProtect:$setColorInput($chr(38), Protect)
132
  ..$chr(64) $+ Op                      %RColor.prefixColorOp:$setColorInput($chr(64), Op)
133
  ..$chr(37) $+ HalfOp       %RColor.prefixColorHalfOp:$setColorInput($chr(37), HalfOp)
134
  ..$chr(43) $+ Voice               %RColor.prefixColorVoice:$setColorInput($chr(43), Voice)
135
  ..-
136
  ..Preview:RColorPreview
137
  ..Reset:if ($$?!="Reset prefix colors to default?") { setPrefixColors }
138
  .-
139
  .About:run http://dev.adiirc.com/boards/5/topics/163
140
  -
141
}
142

    
143
alias -l setColorInput {
144
  var %c $replace($$?"Prefix $1 $+ $2 Color.      Hint: press ctrl+k to open the color picker.", $chr(3),) | if (%c isnum 0-15) { set %RColor.prefixColor $+ $2 %c | echo -ag $+($chr(3),%c,$chr(2),$1,$chr(2),$chr(3),$2) prefix color changed. }
145
}
(6-6/6)