Hello I need help with below snippet. This snippet will color/bold/highlight Background, Text, Punctuation, Capitals, Nicknames to different colors when I type something and press enter. This snippet will automatically check nickname from a channel list and change the color of the nick ONLY if detected in the text.
Only Background has the option to be disabled. How can I add option to disable Text, Punctuation, Capitals, Nicknames? Problem is lot of users have custom color code and black or other color chat background. If I choose black text, it blends in with their background and they can't see what I am writing. I need to have an option for "transparent color" for Text, Punctuation, Capitals, Nicknames so that the text I type will display whatever color setting they have. Is it possible? If so, whats the code?
Currently nickname can be ONLY colored. Is it possible to color & UNDERLINE nickname ONLY automatically as I type a text? If so, what would be the code for that?
Please see example below, I chose nickname color purple:
imgur.com/DbQUNs1
; -------------------------------------------------
; --------- Gummo's Colour Script v4.6.2 ------------
; -------------------------------------------------
#gum.colour on
on *:input:*: {
; Don't try to do anything if user typed a command or pasted a lot of text (or pressed ctrl+enter, see below)
if (/* iswm $1) || ($inpaste) return
elseif ($ctrlenter) {
; Allow easy setting of modes (if enabled). +/- modes with ctrl+enter will set them in a channel. Arguments allowed.
if (%gum.colour.easymodes) && ($me ison $target) && ($regex($1-,/^(?:[+-][a-z]+)+/i)) {
mode $target $1-
haltdef
}
return
}
; Don't colour messages in certain rooms to avoid annoying people and/or to your preference. This line is optional.
if ($istok(#Staff #Oper #Opers #Services #Services-Log #Log #Support #Appeals #Abuse,$target,32)) return
; Stop the script if the channel blocks coloured messages (channel mode +c)
; Note the $gettok since 'c' can exist in one of the arguments. I've had trouble with that previously.
if (c isincs $gettok($chan($target).mode,1,32)) return
; Point of no return! We've stopped mIRC's default actions now, so we have to send the message.
haltdef
; Don't edit the following three lines. They create temporary variables from the permanent ones for simplicity.
var %bg %gum.colour.background, %txt $+ %gum.colour.text, %punc $+ %gum.colour.punctuation
var %caps $+ %gum.colour.capitals, %nick $+ %gum.colour.nicknames
var %punc2 $+ $base($right(%punc,-1),10,10,2), %punc3 $+(%punc,$chr(44),%bg)
; Preparing various variables
var %regex, %chanregex, %puncregex, %nicks, %chans, %chanlist, %i 1
; Tokenize the text instead of putting it in a variable, to avoid mIRC's variable evaluation for simple maths..
tokenize 32 $remove($strip($1-,rc),)
; Create a list of channels to be matched in the text, escaped to prepare it for regex.
while ($chan(%i)) {
%chanlist = $+(%chanlist,|\Q,$v1,\E)
inc %i
}
; Set the channel regular expression (for finding channels, both in channel and PM)
%chanregex = /(?<=\s|[(,+%@&~?!]|(?<!\w)[])(?=#[^\s,+%@&~]{3})( $+ $right(%chanlist,-1) $+ )(?=[[:punct:]]*[\s,]|[](?!\w))/gi
; Set a slightly different nickname regular expression for queries as opposed to channels
; Queries only match you and the nick you PM, while channels match any possible nickname (and channel) to avoid big loops
if ($query($target)) %regex = /(?<=\s|\s[[{]|(?<!\w)[]|[.,'"<(+%@&~/\\])(\Q $+ $me $+ \E|\Q $+ $target $+ \E)(?=[[:punct:]]*\s|['"/\\=*@.,]|[](?!\w))/gi
elseif ($chan) %regex = /(?<=\s|(?<!\w)[]|[.,'"<(+%@&~/\\])(?!\d)([^-,./:-@~ ×÷]{3,})(?=[[:punct:]]*[\s,]|[/\\=*@.,]|['"](?=\S{3,}\s|[\s,])|[](?!\w))/gi
; Prepare the symbols/capitals/smileys regular expression (for simplicity later)
%puncregex = /((?i:\b[OVUX][_.]+[OVUX]\b|[:;=][A-Z]\b|\b[A-Z][:;=]\B|\b(?:X[DOP]|[DOP]X)\b|[^A-Z\s])+|[A-Z]+)/g
; If we're not sending text to a PM or channel, exit
else return
; Now we'll move the channels (all known) into a variable and put ctrl+o in their place (to avoid confusion with ctrl+r)
tokenize 32 $mid($regsubex(chans,/ $1- /,$iif(%gum.colour.highlightchan,%chanregex,),),3,-2)
; A simple loop to move the matched channels into the %chans variable
%i = 1
while ($regml(chans,%i)) {
%chans = %chans $v1
inc %i
}
; Now we'll move the nicknames into a variable (known and potential alike) and put a ctrl+r in their place
tokenize 32 $mid($regsubex(nicks,/ $1- /,$iif(%gum.colour.highlightnick,%regex,),),3,-2)
; Another simple loop to move the matched nicknames into the %nicks variable
%i = 1
while ($regml(nicks,%i)) {
%nicks = %nicks $v1
inc %i
}
; If we were sending to a channel, remove potential nicknames which don't exist in the channel (and put them back into the text)
; Modified to also cater for channel matches
if ($chan) {
var %nn, %n $numtok(%nicks,32)
while (%n) {
%nn = $gettok(%nicks,%n,32)
if (%nn !ison $chan) && ($me !ison %nn) {
tokenize 32 $regsubex($1-,//g,$iif(\n == %n,%nn,))
%nicks = $deltok(%nicks,%n,32)
}
dec %n
}
}
; Now remove those pesky extra ctrl+r characters in %nicks
%nicks = $remtok(%nicks,,0,32)
; Colour capital letters, emoticons and punctuation in one line since this negates a need for workarounds of any kind
tokenize 32 $regsubex($1-,%puncregex,$+($iif(\1 isalpha && !$istok(XD.DX.XO.OX.XP.PX,\1,46),%caps,$iif($left(\1,1) isnum,%punc2,$iif($left(\1,1) == $chr(44) && $mid(\1,2,1) isnum,%punc3,%punc))),\1,%txt))
; Loop through each channel, colouring it and putting it back in its original place
if (%chans) tokenize 32 $regsubex($1-,//g,$+(%nick,$gettok(%chans,\n,32),%txt))
; Loop through each nickname, colouring it and putting it back in its original place
if (%nicks) tokenize 32 $regsubex($1-,//g,$+(%nick,$gettok(%nicks,\n,32),%txt))
; Finalise colouring and remove unnecessary colours
tokenize 32 $regsubex($+(%txt,$1-,),/(?:\d\d?(?:\x2C\d\d?)?)+/g,)
tokenize 32 $regsubex($1-,/\d\d?(?:\x2C\d\d?)? /g,$chr(32) )
while ($1- != $regsubex($1-,/(\d\d?)(?:\x2C\d\d?)?([^]+)(\d\d?)(?:\x2C\d\d?)?/g,$iif(\1 == \3,\1\2,\1\2\3))) tokenize 32 $v2
; Put the background colour at the start (minimise character use as much as possible, even though it's a lot of code for that)
; This prevents requiring two colour codes at the start for no reason
; Also added check to add bold character to the start (if applicable)
tokenize 32 $regsubex($1-,/^(\d\d?)(?!\x2C\d)(?=(.))/,$+($iif(%gum.colour.bold,),,$base(\1,10,10,1),$chr(44),$iif(\2 isnum,$base(%bg,10,10,2),%bg)))
; Message to target
msg $target $1-
}
#gum.colour end
; Creating the menu for this script
menu channel,query {
-
Gummo Colour
.$iif($group(#gum.colour).status == on,Disable,Enable) $+ : {
$iif($group(#gum.colour).status == on,.disable,.enable) #gum.colour
echo $color(info) -a Gummo's Colour Script is now $upper($group(#gum.colour).status) $+ .
}
.-
.$gum.colour.greyed Background
..$submenu($gum.colour.submenu(background,$1))
.$gum.colour.greyed Text
..$submenu($gum.colour.submenu(text,$1))
.$gum.colour.greyed Punctuation
..$submenu($gum.colour.submenu(punctuation,$1))
.$gum.colour.greyed Capitals
..$submenu($gum.colour.submenu(capitals,$1))
.$gum.colour.greyed Nicknames
..$submenu($gum.colour.submenu(nicknames,$1))
.-
.$gum.colour.greyed(%gum.colour.easymodes) Easy Modes: {
%gum.colour.easymodes = $iif(%gum.colour.easymodes,$false,$true)
echo $color(info) -a Easy modes (typing a mode and then pressing ctrl+enter to set) are now $iif(%gum.colour.easymodes,enabled,disabled) $+ .
}
.$gum.colour.greyed(%gum.colour.highlightnick) Highlight Nicks: {
%gum.colour.highlightnick = $iif(%gum.colour.highlightnick,$false,$true)
echo $color(info) -a Nickname highlighting is now $iif(%gum.colour.highlightnick,enabled,disabled) $+ .
}
.$gum.colour.greyed(%gum.colour.highlightchan) Highlight Chans: {
%gum.colour.highlightchan = $iif(%gum.colour.highlightchan,$false,$true)
echo $color(info) -a Channel highlighting (as opposed to nickname highlighting) is now $iif(%gum.colour.highlightchan,enabled,disabled) $+ .
}
.$gum.colour.greyed(%gum.colour.bold) Bold Text: {
%gum.colour.bold = $iif(%gum.colour.bold,$false,$true)
echo $color(info) -a Bold text is now $iif(%gum.colour.bold,enabled,disabled) $+ .
}
.-
.$gum.colour.greyed Presets
..$submenu($gum.colour.presetmenu($1))
.-
.$gum.colour.greyed Reset to Defaults:if ($input(Are you really sure you want to reset to defaults? All of your current settings (other than presets) will be lost!,y,Reset to Defaults?)) gum.colour.reset -hard
}
; Special submenu for selecting a colour to save time coding
alias -l gum.colour.submenu {
; The alias will never call 0, so we make a workaround
var %n $2 - 1
var %cmd :set % $+ gum.colour. $+ $$1
if (%n isnum 0-15) return $iif($(% $+ gum.colour. $+ $1,2) == %n,$style(1)) $colourname(%n) $+ %cmd %n
; We can't put 99 here or it wouldn't work, so we'll just pretend it's 16 :)
if ($1 == background) && (%n == 16) return $iif(%gum.colour.background == 99,$style(1)) $colourname(99) $+ %cmd 99
}
; Special submenu for sorted presets (from temporary list, created elsewhere
alias gum.colour.presetmenu {
if ($1 == 1) return Save As...:gum.colour.presetsave
if ($1 == 2) return Refresh List:gum.colour.presetrefresh
if ($1 == 3) return -
if ($1 isnum) && ($gettok(%gum.colour.presetlist,$calc($1 - 3),44)) return $replace($v1,$chr(151),$chr(32)) $+ :gum.colour.presetload $v1
}
; Simplify the menu a little by checking whether to grey-out and/or tick the options via simple maths
alias -l gum.colour.greyed {
var %x 0
if ($group(#gum.colour).status != on) %x = %x + 2
; Allow for a tick when a variable was speficied and evaluated to $true
if ($1 == $true) %x = %x + 1
return $style(%x)
}
; Alias to reset variables to defaults (hard setting replaces ALL variables, soft or unspecified only fixes variables)
alias -l gum.colour.reset {
var %forced $false
if ($1 == -hard) %forced = $true
if ((%gum.colour.background !isnum 0-15) && (%gum.colour.background != 99)) || (%forced) set %gum.colour.background 1
if (%gum.colour.text !isnum 0-15) || (%forced) set %gum.colour.text 3
if (%gum.colour.punctuation !isnum 0-15) || (%forced) set %gum.colour.punctuation 0
if (%gum.colour.capitals !isnum 0-15) || (%forced) set %gum.colour.capitals 9
if (%gum.colour.nicknames !isnum 0-15) || (%forced) set %gum.colour.nicknames 11
if (%gum.colour.easymodes == $null) || (%forced) set %gum.colour.easymodes $true
if (%gum.colour.highlightnick == $null) || (%forced) set %gum.colour.highlightnick $true
if (%gum.colour.highlightchan == $null) || (%forced) set %gum.colour.highlightchan $true
if (%gum.colour.bold == $null) || (%forced) set %gum.colour.bold $false
; Refresh the preset colours list while we're at it
gum.colour.presetrefresh
; If forced (hard reset), the user will expect to know
if (%forced) echo $color(info) -a Gummo's Colour Script settings reset to defaults.
}
; This alias will load the specified preset colours
alias -l gum.colour.presetload {
var %settings $readini(gum.colour.ini,Presets,$$1)
var %names background,text,punctuation,capitals,nicknames
var %i 1
while ($gettok(%names,%i,44)) {
set $+(%,gum.colour.,$v1) $gettok(%settings,%i,44)
inc %i
}
; Let the user know we just loaded a preset
echo $color(info) -a Preset colour configuration $qt($replace($1,$chr(151),$chr(32))) loaded.
}
; This alias will save the current colour configuration as a preset (with confirmation for over-write)
alias -l gum.colour.presetsave {
var %settings, %i 1
var %names background,text,punctuation,capitals,nicknames
var %name $input(Please enter a name to save for this colour preset:,e,Enter Preset Name)
; Replace spaces with a special dash (ASCII 151) to enable spaces in names and remove any commas for compatibility
%name = $replace(%name,$chr(32),$chr(151),$chr(44),$null)
if (%name) {
; Check for identical named colour preset
if (!$readini(gum.colour.ini,Presets,%name)) || ($input(There is already a preset called $qt(%name) $+ . Do you want to over-write this preset?,y,Preset Already Exists)) {
while ($gettok(%names,%i,44)) {
%settings = $addtok(%settings,$($+(%,gum.colour.,$v1),2),44)
inc %i
}
; Write the data and let the user know (delete any existing entry first to enable case-sensitive renaming)
remini gum.colour.ini Presets %name
writeini gum.colour.ini Presets %name %settings
echo $color(info) -a Preset colour configuration $qt(%name) saved.
; Refresh the presets list of it won't appear in there
gum.colour.presetrefresh
}
}
}
; This alias refreshes the list of presets (doing it as the menu opens is too intensive)
alias -l gum.colour.presetrefresh {
var %presets, %i
%i = $ini(gum.colour.ini,Presets,0)
while (%i) {
%presets = $addtok(%presets,$ini(gum.colour.ini,Presets,%i),44)
dec %i
}
; Sort the list of presets for purely aesthetic purposes
%presets = $sorttok(%presets,44,a)
set %gum.colour.presetlist %presets
}
; Use this $colourname alias as you wish; customise it such that it matches your colours 0-15.
alias colourname {
; I know this could be done with a $gettok but then it would be harder to understand (and change, for that matter)
var %ret
if ($1 == 0) %ret = White
if ($1 == 1) %ret = Black
if ($1 == 2) %ret = Dark Blue
if ($1 == 3) %ret = Dark Green
if ($1 == 4) %ret = Red
if ($1 == 5) %ret = Maroon
if ($1 == 6) %ret = Purple
if ($1 == 7) %ret = Orange
if ($1 == 8) %ret = Yellow
if ($1 == 9) %ret = Light Green
if ($1 == 10) %ret = Teal
if ($1 == 11) %ret = Light Blue
if ($1 == 12) %ret = Blue
if ($1 == 13) %ret = Pink
if ($1 == 14) %ret = Dark Grey
if ($1 == 15) %ret = Light Grey
if ($1 == 99) %ret = No Background
return %ret
}
; This just says thanks when they load the script, obviously
on *:load: {
echo $color(info) -a ---
echo $color(info) -a Thanks for using Gummo's Colour Script. :D
echo $color(info) -a Right-click in a channel or PM to customise.
echo $color(info) -a ---
}
; Reset any missing variables upon startup ('soft' settings)
on *:start: {
gum.colour.reset -soft
}
on *:unload: {
unset %gum.colour.*
echo $color(info) -a ---
echo $color(info) -a Thanks for using Gummo's Colour Script, sorry you want to remove it. :P
echo $color(info) -a All variables related to this script have been removed.
if ($isfile(gum.colour.ini)) {
if ($input(The presets configuration file $chr(40) $+ gum.colour.ini $+ $chr(41) has not been deleted. Would you like to delete it?,y,Delete Presets?)) {
.remove gum.colour.ini
echo $color(info) -a Presets configuration file deleted.
}
else echo $color(info) -a Presets configuration file remains.
}
echo $color(info) -a ---
}