mIRC Home    About    Download    Register    News    Help

Print Thread
antiflood #223730 31/07/10 11:04 PM
Joined: Jul 2010
Posts: 3
2
26736243 Offline OP
Self-satisified door
OP Offline
Self-satisified door
2
Joined: Jul 2010
Posts: 3
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 
}

Re: antiflood [Re: 26736243] #223732 31/07/10 11:19 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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 
  }
}

Re: antiflood [Re: 26736243] #223747 01/08/10 04:19 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: antiflood [Re: Tomao] #223772 01/08/10 03:11 PM
Joined: Apr 2010
Posts: 941
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 941
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

Last edited by FroggieDaFrog; 01/08/10 03:26 PM.

I am SReject
My Stuff
Re: antiflood [Re: FroggieDaFrog] #223774 01/08/10 03:17 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
No, it'll still work without $().
Quote:
/^\S+(v| $)/i
You miss a delimiter (forward slash).

Re: antiflood [Re: FroggieDaFrog] #223776 01/08/10 03:34 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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

Re: antiflood [Re: Tomao] #223790 01/08/10 07:02 PM
Joined: Apr 2010
Posts: 941
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 941
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 $()

Last edited by FroggieDaFrog; 01/08/10 07:03 PM.

I am SReject
My Stuff
Re: antiflood [Re: FroggieDaFrog] #223792 01/08/10 07:09 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Well, you do know the dollar sign in regex has its special meaning too?

Re: antiflood [Re: Tomao] #223793 01/08/10 07:49 PM
Joined: Apr 2010
Posts: 941
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 941
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.


I am SReject
My Stuff
Re: antiflood [Re: FroggieDaFrog] #223794 01/08/10 07:53 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
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


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: antiflood [Re: jaytea] #223795 01/08/10 08:27 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: antiflood [Re: 26736243] #223917 03/08/10 09:37 AM
Joined: Jul 2010
Posts: 3
2
26736243 Offline OP
Self-satisified door
OP Offline
Self-satisified door
2
Joined: Jul 2010
Posts: 3
Thanks!!! grin