mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
I would really like an identifier that signals me whether a received line of text triggered a highlight.

Joined: Dec 2002
Posts: 2,033
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,033

There have been some similar requests here and here. I recall seeing a couple of others, you may want to do a search if you're interested.

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You are already notified if you enable tips for that highlight match, or have I got the wrong idea here?

Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
Ah, yes, i see. I hope this makes it into the next release.

And, as i want my script distributable, i don't want to rely on users having to enable a feature, like tips, in mirc.

Last edited by gencha; 07/03/08 04:21 PM.
Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
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.

Code:
; 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 wink

Suggestions are highly welcome.

Credits to Horstl for his inspiration on this.

edit: Case-sensitive settings are now respected.

Last edited by gencha; 07/03/08 09:13 PM.
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
How do you mean override?

Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
Like you could do:
Code:
alias echo {
  !echo $1- :)
}

Like overriding the internal mirc command with my own. When i tried that with $highlight it didn't work for me.

Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
Code:
alias highlight {
if ($isid) return isid
else echo -a ok
}


/highlight will echo in the active window "ok"
/!highlight will call the internal command
$highlight will call the internal commmand
$/highlight will return isid

so $/aliasname is what you want but this have to be used carefuly imo smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2004
Posts: 22
G
gencha Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
Ah, i see. That's interesting on the one hand, but doesn't provide a real advantage over my current solution *g*
Good to know nevertheless.
Thanks


Link Copied to Clipboard