Jut a simple highlight notifier. It doesn't get any simpler than this. :D All highlights are sent to a window(@Highlight) and are pasted in this format:
Thu Nov 18 16:34:34 2010 Text Highlight: Aries by Tidum in #Trelt on irc.kickassanime.org(Rizon)
Thu Nov 18 16:35:14 2010 Action Highlight: smacks Aries with a trout by Rathed in #Trelt on irc.kickassanime.org(Rizon)
on *:TEXT:*:#:$highcheck($1-)
on *:ACTION:*:#:$highcheck($1-)
alias -l highcheck {
if ($regex($1-,/\Q $+ $me $+ \E/iS)) {
beep 5 500
$iif(!@Highlight,window -hw2 @Highlight)
aline -hp @Highlight $fulldate 04 $event Highlight: 00 $1- 10by 12 $nick 10in 7 # 10on 03 $server 09 $+(,$chr(40),$network,$chr(41),)
}
}
jaytea Said:
napa, are you suggesting we use/distribute code that we know to be flawed just because the situation in which it fails is rare and we haven't encountered it yet?
I never suggested you use/distribute anything.
but I understand what you mean by covering anything that may and can go wrong.
napa, are you suggesting we use/distribute code that we know to be flawed just because the situation in which it fails is rare and we haven't encountered it yet?
this reminds me of a comment i read here a little while ago, something about claiming a certain small line of code was correct simply because it was used within a much larger script that appeared to work properly.
we should not judge a single line of code such as 'if ($highlight($1-)) {' by its performance in larger scripts; instead, we should examine it in isolation, consider what it's being used for, and try to identify potential problems. if we are using it to detect lines of text ($1-) matched by an entry in our highlight list, and we know that $highlight() can also be used to return the Nth entry in the list, then it should be clear that the following IRC mmessage will result in a false positive:
<Nick> 1
this should be enough of a potential problem to warrant a 3 character fix, with an optional comment describing it since the reason for $lf there might not be clear to your future self or someone looking through your code.
Gummo, i believe what Jethro means to say is that mIRC's highlight system (which supports both the standard 'not surrounded by alphanumeric characters' check i described before, regular expressions, and even evaluates variables and identifiers used as highlight entries) is usually powerful enough for most applications. using it over theme related on TEXT etc. events wherever possible, even in ways that might be considered clumsy and hack-ish, is advisable since things like nick colors (/cnick) and excess spaces are handled implicitly by mIRC. here's an example of using the highlight system in such as way (colouring messages based on channel status), last post in: http://trout.snt.utwente.nl/ubbthreads/ubbthreads.php?ubb=showflat&Board=3&Number=225765
I have never used $highlight() because I need more advanced matching for my highlight script, but yes, regex won't achieve what that can do and thinking that \b or \B is going to work is a common mistake leaving many people confused as to why their script won't match something they think it should.
Napa, did you check when someone uses a number? jaytea used $lf to get around that.
I agree with jaytea about the use of $highlight
this seems to work just as long you have the nicks added in ur highlight list
on *:text:*:#:$highcheck($1-)
on *:action:*:#:$highcheck($1-)
alias -l highcheck {
if ($highlight($1- $lf) && !$($+(%,f,$wildsite),2)) {
inc -u15 $+(%,f,$wildsite)
noop $tip(Highlight,Nick Highlight,$nick highlighted you$&
in a $event message in channel # Saying: $crlf $1-,15)
}
}
Or use the highlight dialog mirc provides an set up a tip message from there.
Consider this my 2 cents in a solution or workaround. :P
To detect tokens that start with your nick and any characters following: Eg. SunnyD! or SunnyDD -- I realize it has its weaknesses but for people who don't understand $regex() like some do, it can serve as a sufficient substitute.
$wildtok($1-,$+($me,*),1,32)
or to detect any token that matches your current nick. EG. SunnyD
$wildtok($1-,$me,1,32)
Alas this version works the same as any other token identifier.
Yeah my bad. For my example, a while loop wasn't needed, especially for a single match. I guess I was spaced out. lol Yeah the if ($istok($strip($1-),$me,32)) { would have done the trick just fine. But using $istok has also come with a downside: if someone uses, "Hi Jaytea, can you help me?" it won't trigger because of the comma being in the way.
About napa's regex, he could have added the word boundary character so it matches for the $me the way it is, and is not constrained by the punctuation characters:
/\b\Q $+ $me $+ \E\b/iS
napa's check is no better than isin; the only potential advantage it has over a plain if ($me isin $1-) is the ignoring of control codes in $1- with //S (which can, of course, also be achieved with $strip($1-)). it even fails where isin doesn't: when $me contains '\E'. an unlikely occurrence, but something to consider in general.
i can't tell if this is intended to work with mIRC's highlight system (ie. detect when an incoming line matches an entry on your highlight list) but if it is, it is not trivial to make a regular expression that behaves as mIRC's highlight system does. mIRC's highlight matching routine is simple only in terms of mIRC script: if an incoming line contains an entry in your highlight list, and it does not have a non-alphanumeric character (think: isalnum) on either side, then it matches successfully. the problem is, there is no construct in PCRE, mIRC's regex flavour, that behaves as isalnum does. replicating the highlight detection in regex requires you to provide the whole list of characters which mIRC considers alphanumeric (or the list of non-alphanumeric ones).
there are around 17,500 non-alphanumeric Unicode characters, and around 350 distinct contiguous ranges of such characters. creating a regular expression with this information would be, i'm sure you'll agree, tedious.
thankfully, mIRC has $highlight(), which lets you test whether a line matches an entry on your highlight list:
if ($highlight($1- $lf)) {
$lf can't be a part of an incoming message nor, presumably, part of your highlight entry; we can use it to turn $1- non-numerical, since $highlight(N) is used to return the Nth entry in the highlight list.
Jethro_, $me can't contain a space. what you have essentially checks:
if ($istok($strip($1-), $me, 32)) {
just another way to go about it...
on *:TEXT:*:#:$highcheck($1-)
on *:ACTION:*:#:$highcheck($1-)
alias -l highcheck {
if ($regex($1-,/\Q $+ $me $+ \E/iS)) {
beep 5 500
$iif(!@Highlight,window -hw2 @Highlight)
aline -hp @Highlight $fulldate 04 $event Highlight: 00 $1- 10by 12 $nick 10in 7 # 10on 03 $server 09 $+(,$chr(40),$network,$chr(41),)
}
}
He means you can re-construct it to reduce redundancy. instead of:
on 1:TEXT:*:#:{
if ($me isin $1-) {
beep 5
if (!@Highlight) {
window -hw2 @Highlight
aline -hp @Highlight $fulldate 4Text Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
else {
aline -hp @Highlight $fulldate 4Text Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
}
}
It could be:
on 1:TEXT:*:#:{
if ($me isin $1-) {
beep 5
if (!@Highlight) {
window -hw2 @Highlight
}
aline -hp @Highlight $fulldate 4Text Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
}
So it evaluates as if the window isn't present then it creates one AND writes the highlight into the window, OR it just writes to the specified window. Also if it piques your curiosity you could script in multi-server support. A highlight window for each server instead of sifting through one large window.
No worries I got grilled on the same thing when I posted a similar snippet. Suggestions helped me a lot.
if (!@Highlight) {
window -hw2 @Highlight
aline -hp @Highlight $fulldate 6Action Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
else {
aline -hp @Highlight $fulldate 6Action Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
aaaand
if (!@Highlight) {
window -hw2 @Highlight
aline -hp @Highlight $fulldate 4Text Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}
else {
aline -hp @Highlight $fulldate 4Text Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
}