mIRC Homepage
Posted By: 26736243 antiflood - 31/07/10 11:04 PM
How could add a antiflood, of 10 seconds per user?
Code:
on $*:text:$(/^[!](ping|commands)$/Si):#mIRC: {
  if $regml(1) = ping { 
    mode $me -T 
    ctcp $nick ping
  }
  if $regml(1) = commands { 
  .play $nick play/commands.txt 10 
  }
}

on 1:ctcpreply:ping*: { 
  .notice $nick PONG!: $iif($calc($ctime - $2) <= 1,$v1 second.,$v1 seconds.) 
  mode $me +T 
}
Posted By: Horstl Re: antiflood - 31/07/10 11:19 PM
For my part, I prefer hash tables to store/check this kind of temporary data
Code:
on $*:text:$(/^\!(ping|commands)$/Si):#mIRC: {
  if $hget(noflood,$+($cid,.,$fulladdress)) { return }
  else { hinc -mu10 noflood $+($cid,.,$fulladdress) }
  if $regml(1) = ping { 
    mode $me -T 
    ctcp $nick ping
  }
  elseif $regml(1) = commands { 
    .play $nick play/commands.txt 10 
  }
}
Posted By: Tomao Re: antiflood - 01/08/10 04:19 AM
For the regex part, you don't need to specify another if statement to reference another command, just else will do it...since you only have two of them...so it's either true or false.
Quote:
on $*:text:/^!(ping|commands)$/Si:#mIRC: {
if $regml(1) == ping {
;do something
}
else {
;do something else
}
And you don't need to enclose regex with $() because there is no identifier used to be evaluated.
Posted By: FroggieDaFrog Re: antiflood - 01/08/10 03:11 PM
Quote:
And you don't need to enclose regex with $() because there is no identifier used to be evaluated.

It's not needed with this, but it might be needed for things such as:
Code:
/^\S+(v| $)/i
Posted By: Tomao Re: antiflood - 01/08/10 03:17 PM
No, it'll still work without $().
Quote:
/^\S+(v| $)/i
You miss a delimiter (forward slash).
Posted By: Tomao Re: antiflood - 01/08/10 03:34 PM
I think you're looking at this pattern:
Code:
/^\S+v( |$)/i
This will make sure it triggers on
Quote:
blahv blah
and not
Quote:
blahvblah
Posted By: FroggieDaFrog Re: antiflood - 01/08/10 07:02 PM
no. THe reason I showed it the way I did, was so u could see:
Code:
on $*:TEXT:/^\S+(v| $)/i:#:{ }

when this event triggeres it might see "$)/i" as an identifer,
hence why u would surround the matchtext with $()
Posted By: Tomao Re: antiflood - 01/08/10 07:09 PM
Well, you do know the dollar sign in regex has its special meaning too?
Posted By: FroggieDaFrog Re: antiflood - 01/08/10 07:49 PM
Yes, I'm pretty good with the ol' regex. smile

was just saying that when mIRC parses the event match-text it might have parts seen as an identifer on occations without the $() around it.
Posted By: jaytea Re: antiflood - 01/08/10 07:53 PM
Originally Posted By: FroggieDaFrog
no. THe reason I showed it the way I did, was so u could see:
Code:
on $*:TEXT:/^\S+(v| $)/i:#:{ }

when this event triggeres it might see "$)/i" as an identifer,
hence why u would surround the matchtext with $()


that is, if anything, an example of where you would certainly not want to enclose the matchtext in $(). malformed expression aside, surrounding it with $() will have mIRC attempt to evaluate $)/i as an identifier. without it, mIRC will leave the expression alone and handle all parts of it literally which is, presumably, what we want :P
Posted By: Tomao Re: antiflood - 01/08/10 08:27 PM
I agree with jaytea.

One thing I don't get is the pattern demonstrated by Froggie. (unless it's a random, trivial example) It'll match anything starting with one or more nonwhite space characters, followed by a capital or lower letter v, or followed by a space. Sorry, but I don't see how this pattern is any of the benefits for the match...

Quote:
malformed expression aside
perhaps that's what you meant with the expression constructed incorrectly?

Code:
/^\S+(v| )$/
<-this, however, will make some sense to me, because it'll make sure it ends with the uppercase of lowercase v, or proceeded by a space. At least it has a purpose.
Posted By: 26736243 Re: antiflood - 03/08/10 09:37 AM
Thanks!!! grin
© mIRC Discussion Forums