on *:UNLOAD:{
if ($hget($table)) {
hfree $table
}
if ($isfile($fname)) {
remove $qt($fname)
}
}
alias -l table return colorex
alias -l fname return $scriptdir $+ $table $+ .dat
alias -l names return (action|ctcp|highlight|info|info2|invite|join|kick|mode|nick|normal|notice|notify|other|own|part|quit|topic|wallops|whois)(?: text)?
;; /color
;; $/color()
;; Behavior is the same as native /color & $color but supports the extended color palette
alias color {
;; if the extended colorpalette table does exist, create it
if (!$hget($table)) {
hmake $table 10
if ($isfile($fname)) {
hload $table $qt($fname)
}
}
;; if called as an identifier
if ($isid) {
;; if the entry exists in the table, return the value
if ($0 == 1 && $hget($fname, $1) !== $Null) {
return $v1
}
;; otherwise pass the parameters to the native $color() identifier and return the result
var %x = 0, %call
while (%x < $0) {
inc %x
%call = $addtok(%call, $ $+ %x, 44)
}
%call = $!~color( $+ %call $+ ) $+ $iif($prop !== $null, . $+ $prop)
return $( %call ,2)
}
;; if called as a command
else {
var %pattern = /^ $+ $names 0*(\d?\d)(?<!99)$/i
var %switches
;; remove switches from parameters
if (-* iswm $1) {
%switches = $1
tokenize 32 $2-
}
;; /color -l
;; reload the hashtable from file
if (l isincs $1 && $isfile($fname)) {
hload $table $qt($fname)
}
;; if called as /color name index
if (!%switches && $regex($1-, %pattern)) {
var %name = $lower($regml(1))
var %idx = $regml(2)
;; the index is in the extended palette store it in the table
if (%idx > 15) {
hadd $table %name %idx
hsave $table $qt($fname)
}
;; otherwise
else {
;; remove the named entry from the table
if ($hget($table, %name) != $null) {
hdel $table %name
hsave $table $qt($fname)
}
;; call the native /color command
!color %name %index
}
}
;; For all other calls, use mIRC's native /color
else {
!color %switches $1-
}
}
}
#echooverride off
alias echo {
if ($isid) {
return
}
;; If the extended color table hasn't been loaded
;; create the hashtable and load the palette if it exists
if (!$hget($table)) {
hmake $table 10
if ($isfile($fname)) {
hload $table $qt($fname)
}
}
;; $regml(1) = switches
;; $regml(2) = double quotes or null
;; $regml(3) = color name
;; $regml(4) = rest of /echo parameters
var %pattern = /^(?:\d+ )?(-[^c]*c[^c]*)("?) $+ $names $+ \2 (.*)$/
;; intercept '/echo -c color_name ...' and translate it to '/echo color_index ...'
;; consider not including switches if the switches parameter is reduced to -
if ($regex(namedcolor, $1-, %pattern) && $hget($table, $regml(namedcolor, 3)) !== $null) {
!echo $v1 $removexcs($regml(namedcolor, 1), c) $regml(namedcolor, 4)
}
;; Otherwise, pass the parameters as-is to the native echo command
else {
!echo $1-
}
}
#echooverride end