mIRC Home    About    Download    Register    News    Help

Print Thread
#168138 04/01/07 11:03 AM
L
learn3r
learn3r
L
Code:
on *:text:!rose*:#:{
  msg # $nick gives $2 a bunch roses showing his/her love.
}


I made a simple commands on my bot
but some users are using it like hell
can anyone pls make a anti flood on this simple code
thanks

Joined: Feb 2003
Posts: 806
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 806
Code:
on *:text:!rose*:#:{

  ; Set your anti-flood configuration here.
  ; I've set it to ignore an user for 300 seconds (5 minutes)
  ; if (s)he says "!rose" for at least 3 times in 5 seconds.
  var %lines = 3, %secs = 5, %ignore = 300

  var %id = $+(%,flood.,$cid,$site,#)

  inc $iif(!$var($(%id)),-u $+ %secs) $(%id)
  if ($(%id,2) >= %lines) {
    .ignore -cu $+ %ignore $nick 4
    .notice $nick Anti-flood: you're now ignored for $duration(%ignore)
  }
  else { msg # $nick gives $2 a bunch roses showing his/her love. }
}


Please note that I haven't tested the code.

S
Scripto
Scripto
S
A simple flood control....

Code:
 
on *:text:!rose*:#:{
  if (%rose) halt
  set -u5 %rose 1
  msg # $nick gives $2 a bunch roses showing his/her love.
}


This sets the control, then allows it to be messaged once. The bot ignores the trigger while %rose exists. Which in this case -u5 is 5 seconds, you can set that to any increment in seconds, 10, 15, 60, 300 seconds if you so choose.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
That's the way I usually do it as well, though using return instead of halt is a preferable way to stop a script's execution. The other example is a nicer way that lets the user who flooded know that he/she was ignored. It all depends what you want to have happen. With the ignore, that user can't use any commands for the bot during that time period and it affects just that one person. With the other method, no one can use this one command during the time perdiod and the nick who flooded would still be able to use other commands. The downside that I see with ignoring one nick as a method of flood prevention is that a lot of clones can still flood you off with that one command.

Joined: Feb 2003
Posts: 806
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 806
Originally Posted By: Riamus2
The downside that I see with ignoring one nick as a method of flood prevention is that a lot of clones can still flood you off with that one command.


Yeah, I realized that too. It's possible, though, to implement a 2nd flood detection that's directed "globally" and let it interact with the "personal" one. However, I feel that maybe the code is too complex as it is (I can't stop myself complicating these things, lol)... I guess I'd prefer the simpler way.


Link Copied to Clipboard