This script will colour your text in when you press enter (unless you type a /command, or if you are pasting lots of text, or if you press ctrl+enter instead of enter). A note about pasting, though.. It will only identify pasting from single line editboxes. Press ctrl+enter to not colour large blocks of text.
So basically I'm sick of people asking me to fix their ripped version of the original script which coloured text like this, so I finally got around to converting my current version such that it no longer is limited by the maximum length of a mIRC variable (thereby making me willing to release it).
It's faster, more accurate and optimised to use the smallest number of characters possible (to let you send the longest message possible).
TO INSTALL:
Just copy it all and paste it into a new remotes script file.
It uses a lot of regex, so it might be a little confusing to read.
TO CUSTOMISE:
Right-click in a channel and you can use the "Gummo Colour" menu to access the settings. :)
If you have changed mIRC's in-built colours from the defaults, $colourname will return the wrong name. Simply edit that alias to fix it. You are free to use $colourname for any purpose.
Note that numbers are coloured the same way as punctuation, as are emoticons.. I felt no need to colour them differently. See screenshot.
Also note that it will only highlight nicknames and channels which are at least 3 characters long when typed into a channel. Any shorter and it gets annoying (for me at least) but you can change it if you really want, just ask and I'll let you know how.
Enjoy and let me know of any problems or suggestions you have. :)
NOTE: This script is designed for mIRC 6.35
UPDATES:
4.1:
• Added support for bolds/underlines in text
4.2:
• Added channel highlighting, not just nicknames for channels
4.3:
• Improved the channel highlighting and made it work for PMs
4.4:
• Added options for nickname and channel highlighting
• Added bold text option (disabled by default)
• Changed the way the options section works so you just click to change it (tick indicates status)
• Made most of the menu greyed out when the script is disabled
• Removed annoying messages when setting defaults
4.5:
• Made the script more modular
• Added a simple colour preset system with a cached presets list (reading from ini files is slow for menus)
• You can refresh the preset list manually if you edit gum.colour.ini file directly (and carefully)
• Added a 'Reset to Defaults' option at the bottom of the menu
• Preset configuration file can be removed upon unloading the script, if you choose yes in a popup
• Added support for spaces in preset names
4.5.1:
• Fixed an issue with mIRC's script engine where it will evaluate simple maths such as "3 + 5" when set as a variable even it was the returned value of a function.. Talk about annoying.
4.6:
• Fully optimised for people who use the same colour for multiple options, allowing for longer messages.
4.6.1:
• Fixed an error where nicknames weren't being highlighted in private messages.
4.6.2:
• Improved nickname highlighting slightly
• Fixed error in code logic which was not apparent with mIRC v6.35
; -------------------------------------------------
; --------- 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 ---
}
Slyvar, to make a multi-colour text is rather simple to achieve by using $regsubex():
alias multicolour {
return $regsubex($1,/(?<=^| )(.)/g,$+($chr(3),$r(0,15),\1))
}
Then use
//echo -a $multicolour(Your Text Here)
msg $target $multicolour($1-)
And the text can be outputted as:> What is going on?every single time with a different color combination randomly.
Gummo, the question I'm asking here is unrelated to this snippet, but I thought you could assist me with a forum request that I've hit the wall:> Can some one make me a script for random bold and underline Nick completer. I want nick to be random letter bold and underline that bold letter, where ever the nick is in sentence
For example:
Hello JOhnThe bold and underline will be at random. They should not stay at the same place. May I pick your brain for this code to be made possible? Thank you.
Updated to version 4.4.. Changes are as follows:
• Added options for nickname and channel highlighting
• Added bold text option (disabled by default)
• Changed the way the options section works so you just click to change it (tick indicates status)
• Made most of the menu greyed out when the script is disabled
• Removed annoying messages when setting defaults
Sure, I'll make a screenshot. One of the later versions of the ripped script is on Hawkee, actually (a few versions of it were made with no credit to the ripper who converted it either :P). I made the original version for a friend who requested each feature after I finished the others, so it was in a hacky workaround format which happened to be suitable for on/off switches. The guy who did it just put my regex into a new script.
I don't really like it not just because it was ripped but also because it's really inefficient. When I made the first version of the new script, I took a different approach which turned out a lot better.
I then tried changing some things to improve the speed and now finally changed the method for release. :)
YOU CAN DO CONTROL U