I think there's no easy AND accurate way to detect highlighting with scripted means, which I want to demonstrate below.
The $highlight identifier allows cycling through all highlight entries:
alias listhighlight {
var %nr = 1
while ($highlight(%nr)) {
echo -na HIGHLIGHT nr. %nr is $v1
echo -na SETTINGS: match regex: $iif($highlight(%nr).regex,yes,no) $&
• match nicks: $iif($highlight(%nr).nicks,yes,no) $&
• message: $iif($highlight(%nr).message,$v1,none) $&
• flash: $iif($highlight(%nr).flash,$v1 times,no) $&
• tip: $iif($highlight(%nr).tip,$v1 seconds,no) $&
• sound: $iif($highlight(%nr).sound,$v1,none) • colour: $iif($highlight(%nr).colour,$v1,none)
inc %nr
}
}
Side Note: $highlight().regex and $highlight().tip are not officially documentated, and I did not find the property for case seinsitive by guessing so far...
One can return if highlight is enabled or not as well.. $highlight (without property).
But the trouble begins when
trying to catch all highlights correctly. For example:
on *:text:*:*: {
if ($highlight($1-)) { echo -anc highlight Highlight triggers (matching: $highlight($1-).text $+ ) }
}
This works apparently well. But $highlight uses the syntax $highlight(N/text). Now,
if text == N? That is: if someone sends the message "1"?
Therefore, one needs to go the other way round (evaluate all highlight entries against the given text).
Pseudocode:
event or text to loop {
while $highlight(N) {
if (the highlight is a regex) { check for (regex(text,highlight) }
elseif (the highlight contains wildcards) { check for (highlight iswm text) }
else { check for (istok(highlight,text,32)) }
}
}
And this does not even take the "case sensitive" switch into account.... to me, that seems quite intricately.
Thus, I am looking forward for (I'm aware of the fact that this has been requested before)
- an
ishighlight operator:
if (<text> ishl) { }
... allowing easy loops through blocks of text
and / or (more important):
- an
$ishighlight identifier returning $true/$false for on text/on action events:
if ($ishiglight) { }
... allowing easy event-related highlight scripting
PS: In addition, a switch
ignore -h(ighlight) would be most welcome. S
Sorry for the lengthy post