Simple Highlight

By Cados on Nov 18, 2010

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),)
  }
}

Comments

Sign in to comment.
Gummo   -  Nov 22, 2010

Oh, I realise that $highlight() seems to be the best solution, which is why I explicitly stated that I wasn't using my script in a regular fashion. People tend to get my names wrong and they aren't common words so I'm not concerned about whether it's in a word or not in my case.

 Respond  
napa182   -  Nov 22, 2010

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.

 Respond  
jaytea   -  Nov 22, 2010

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

 Respond  
Jethro   -  Nov 21, 2010

Gummo, if you ever find an "advanced" matching method, other than the $highlight(), and it's infallible, I'll keep my eyes peeled for it.

 Respond  
napa182   -  Nov 21, 2010

Gummo Said:

Napa, did you check when someone uses a number? jaytea used $lf to get around that.

I haven't ran into any problems yet with the use of a number by using just $highlight($1-), but if others do then they can use $highlight($1- $lf)

 Respond  
Gummo   -  Nov 21, 2010

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.

 Respond  
napa182   -  Nov 21, 2010

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.

 Respond  
Jethro   -  Nov 21, 2010

This should stand out better than it is:

var %p ! , . ?
  if $wildtok($strip($1-),$+($me,$gettok(%p,$numtok(%p,32),32)),1,32) {

Edit: That still won't work if $me isn't followed by the punctuation marks though. I still find regex favorable for this.

 Respond  
Sorasyn   -  Nov 21, 2010

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.

 Respond  
Jethro   -  Nov 21, 2010

Well, I believe this will solve the matter Gummo has described:> \B\Q $+ $me $+ \E\b

 Respond  
Jethro   -  Nov 21, 2010

Gummo and SunndyD, you guys are all talk but no workaround or solution is demonstrated.

 Respond  
Sorasyn   -  Nov 21, 2010

$wildtok() used correctly can be just as powerful as any other method, it can even surpass $findtok() and $istok().

 Respond  
Gummo   -  Nov 21, 2010

$me doesn't only contain letters, numbers and - meaning a \b will often not match correctly, eg "]," has no word boundary (neither character is a word character).

 Respond  
Jethro   -  Nov 19, 2010

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
 Respond  
jaytea   -  Nov 19, 2010

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)) {
 Respond  
Jethro   -  Nov 19, 2010

SunnyD, I'd not use $wildtok...you should use $istok with a simple while loop like so:

on *:text:*:#:highcheck $1-
on *:action:*:#:highcheck $1-
alias -l highcheck {
if $istok($strip($1-),$me,32) { 
     ;custom window and highlights here
    }
}
 Respond  
Sorasyn   -  Nov 18, 2010

I edited his snippet :P I used $wildtok() on mine I think lol

 Respond  
napa182   -  Nov 18, 2010

you should also take advantage of $event as i showed you in my edited version of it

 Respond  
blackvenomm666   -  Nov 18, 2010

i agree with napa and jethro listen to em

 Respond  
Jethro   -  Nov 18, 2010

napa's is well recommended. SunnyD's uses isin, which will likely result in false positive if someone has a similar nickname as yours. I don't see why you need two same routines per event. One is enough using an alias, just as napa's shown you above.

 Respond  
Cados   -  Nov 18, 2010

Ah, I see. I'll update it for both.

 Respond  
napa182   -  Nov 18, 2010

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),)
  }
}
 Respond  
Sorasyn   -  Nov 18, 2010

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.

 Respond  
sk68   -  Nov 18, 2010

whats wrong with just

if (!@Highlight) { window -hw2 @Highlight }
        aline -hp @Highlight $fulldate 6Action Highlight: 00 $+ $1- 10by 12 $+ $nick 10in 7 $+ $chan 10on 3 $+ $server $+ 9( $+ $network $+ )
      }

?

 Respond  
Cados   -  Nov 18, 2010

One's for an action highlight and one's for a text highlight.

 Respond  
sk68   -  Nov 18, 2010
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 $+ )
    }
 Respond  
Cados   -  Nov 18, 2010

I'll try that and where do you see the same line twice?

 Respond  
sk68   -  Nov 18, 2010

You really should get into the habit of using $+(1,2,3) it looks cleaner :| other than that its so simple theres not much to rip on.

I take it back. Why do you have the same line twice? >_>

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.