I can't say that i have fully tested this, but based on what i read in those two threads, i wrote this little script.
It takes a nickname and a given text as you would receive them in a text event and checks whether any highlight matches it.
; Returns whether a given string would trigger a highlight
; $1 The nick that said the text
; $2- The text
alias isHighlight {
var %nick = $1
var %message = $2-
var %text
var %highlightIdx = 1
var %highlightText = $_highlight( %highlightIdx ).text
var %highlightRegex = $_highlight( %highlightIdx ).regex
var %highlightCS = $_highlight( %highlightIdx ).cs
var %highlightNicks = $_highlight( %highlightIdx ).nicks
var %highlightMessages = $_highlight( %highlightIdx ).messages
while ( %highlightText != $null ) {
%text = $null
if ( %highlightNicks ) %text = $+( %text, $chr( 32 ), %nick )
if ( %highlightMessages ) %text = $+( %text, $chr( 32 ), %message )
if ( !%highlightCS ) {
%text = $lower( %text )
%highlightText = $lower( %highlightText )
}
if ( %highlightRegex ) {
if ( $regex( %text, %highlightText ) > 0 ) return $true
}
elseif ( ( ? isin %highlightText ) || ( * isin %highlightText ) ) {
if ( %highlightText iswmcs %text ) return $true
}
else {
if ( $istokcs( %text, %highlightText, 32 ) ) return $true
}
inc %highlightIdx
%highlightText = $_highlight( %highlightIdx ).text
%highlightRegex = $_highlight( %highlightIdx ).regex
%highlightCS = $_highlight( %highlightIdx ).cs
%highlightNicks = $_highlight( %highlightIdx ).nicks
%highlightMessages = $_highlight( %highlightIdx ).messages
}
return $false
}
Oh, and if someone can tell me if (and how) you can override an identifier (like $highlight) properly, please let me know
Suggestions are highly welcome.
Credits to Horstl for his inspiration on this.
edit: Case-sensitive settings are now respected.