mIRC Home    About    Download    Register    News    Help

Print Thread
#237617 22/05/12 07:15 AM
Joined: Dec 2011
Posts: 22
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Dec 2011
Posts: 22
'on HIGHLIGHT' that would trigger when something in your highlights list was triggered so that you could stop/modify the highlight (but not the text)

Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
This has been requested in the past but an operator like "if ($1- ishl) { }" would be better: you could use it inside an on text event to know if you have to highlight, but you could use it anywhere else too.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #237637 22/05/12 06:41 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The functionality of an operator-like condition already exists:

Code:
if ($highlight($1-) != $null) { ... }


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #237638 22/05/12 08:09 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Yeah but this doesn't really work, it fails on a case where $1- is a number for example

Edit: https://forums.mirc.com/ubbthreads.php?ubb=showflat&Board=6&Number=218616&Searchpage=3&Main=40604&Words=%24highlight&topic=0&Search=true#Post218616

Last edited by Wims; 22/05/12 08:18 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #237639 22/05/12 10:08 PM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
No, it does really work, you just have to pay attention to the $0 == 1 && $1 isnum case, as mentioned in the referenced thread. That's not really a significant workaround.

Note that as mentioned in the thread, this is an inherent limitation in mIRC syntax, not the identifier. The solution is not to switch everything over to operators, that would only limit mIRC more as a language. Note also that operators themselves already suffer from similar syntactic ambiguities (like: if (ishl ishl ishl) { ... }), so creating an operator doesn't really solve every case either.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #241372 14/04/13 03:40 PM
Joined: Dec 2002
Posts: 36
T
Ameglian cow
Offline
Ameglian cow
T
Joined: Dec 2002
Posts: 36
I know it's an older thread, but I am finetuning a script right now and had the same problem.

Sure I can check the case text==number. But an ON HIGHLIGHT could have much better performance, because mirc have to trigger this event only when a highlight occures.

A ON TEXT will be triggered every time, so during a high traffic chat ( flood attack) this can make some problems.


cu

TC / Mario
TC_Hessen #241376 15/04/13 06:28 AM
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
Originally Posted By: TC_Hessen
A ON TEXT will be triggered every time, so during a high traffic chat ( flood attack) this can make some problems.


Eh, a hypothetical performance problem is not a real performance problem. Come back with benchmarks and I'll buy it. Also you can't really consider malicious floods since (a) you would probably trigger mIRC's internal Flood protection or (b) you could easily script your own (disable groups on a timer). Keep in mind that you would want this same flood protection for your ON HIGHLIGHT script too, since with well crafted data, a flood could trigger ON HIGHLIGHT as many times as the ON TEXT script listed above. High legitimate traffic is really the only issue that would be of concern.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
TC_Hessen #241378 15/04/13 09:20 AM
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You can use levels on users, when a word is "highlighted" add the user that trigged it to a level, then unset the level after 3 - 5 sec. Or disable all hightligts with the #group off/on as argv0 said.


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
argv0 #262303 18/01/18 11:23 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
No, this really does not work. checking if $0 == 1 && $1 isnum is not enough to make it correct, as explained in this thread. My argument remains, having an operator for if statement like ishl would be much better than an event such as on highlight, on highlight would not allow you to check for highlight against any given string, which would be limited.

Bumping this because it came up on IRC again, even if there is actually a way to script this, it becomes non trivial, an ishl operator would be very nice to have.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #262306 19/01/18 10:26 AM
Joined: Dec 2002
Posts: 5,412
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,412
There are no plans to add anymore named operators. They only exist for backwards compatibility. All new methods use the $identifier() format. Does $highlight(text) not do what you are asking already?

Khaled #262307 19/01/18 12:46 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Ah well that's good to know.

The problem of $highlight is that non technical user cannot just use "if ($highlight(text)) { do something }"

The above code fails on various occasion:

if 'text' is a number, you get a false positive, if you check the simple "if (text !isnum)", it fails on 1.1, but 1.1 for 'text' wouldn't be a problem in if ($highlight(text)).

If your highlight entry is set to use the method 'nick', you cannot use if ($highlight(text)), you have to loop over $highlight(N), check if that entry is a nick method match with $highlight(N).nicks, then use the nickname, such as $nick, rather than the 'text', in a custom if statement (which would depends if you are using regex match or wildcard (and this is extremely tricky because I believe non regex match are handled in a very special way by mIRC, a bit like how hotlink are handling surrounding characters to nickname, even for a non-beginner user, one has to figure out how mIRC is making the match exactly))

So basically one has to always loop over $highlight(N) and check the various property .regex .cs .nicks and use the appropriate if statements, something like what horst was mentioning in the thread I linked to in my previous post, also more or less shown here

It cannot be expected for non tech user to figure out all of this, it's not impossible to do for sure, $highlight() does provide a way to do it, but I still think mIRC should have something for it.

Perhaps something like $ishighlight(text,[nickname]) returning $true/$false, with a corresponding $ishighlight.type returning the type ("message", "nickname", or "both") and $ishighlight.entry returning the Nth entry (returning the entry itself would be an issue to access $highlight() properly, if it's a number for example) of the last call to $ishighlight()

Last edited by Wims; 19/01/18 12:48 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #262313 20/01/18 01:37 PM
Joined: Jul 2006
Posts: 4,146
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,146
Correction: $ishighlight.type couldn't possibly return "both", it would return the type of match that was used to find a match, which can only be "message" or "nickname"


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard